简体   繁体   中英

Tkinter - Update data in OptionMenu

I have created an OptionMenu to display a list of usernames.

For example:

self.accounts_option_menu = ttk.OptionMenu(self, self.menu, user_name_list[0],
                                           *user_name_list, command=self.some_func)

At some point I want to update/change this list to be longer or shorter (removing or adding from the list). My question is: How can I achive that?

如果你把self.accounts_option_menu = ttk.OptionMenu(self, self.menu, user_name_list[0], *user_name_list, command=self.some_func)放在它自己的任何类的方法中,那么你应该能够做到通过调用该方法再次使用不同的列表。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM