2022-05-30 18:20:27 +03:00
|
|
|
import tkinter
|
2022-06-13 16:08:13 +03:00
|
|
|
import tkinter.ttk as ttk
|
2022-05-26 20:16:01 +03:00
|
|
|
import customtkinter
|
2022-05-25 18:04:00 +03:00
|
|
|
|
2022-05-30 18:20:27 +03:00
|
|
|
app = customtkinter.CTk()
|
2022-06-02 02:25:13 +03:00
|
|
|
app.title('Test OptionMenu ComboBox.py')
|
2022-05-30 18:20:27 +03:00
|
|
|
app.geometry('400x300')
|
2022-05-25 18:04:00 +03:00
|
|
|
|
2022-05-30 18:20:27 +03:00
|
|
|
|
|
|
|
def select_callback(choice):
|
2022-05-25 18:04:00 +03:00
|
|
|
choice = variable.get()
|
2022-05-30 17:46:36 +03:00
|
|
|
print("display_selected", choice)
|
2022-05-25 18:04:00 +03:00
|
|
|
|
|
|
|
|
2022-05-30 18:20:27 +03:00
|
|
|
countries = ['Bahamas', 'Canada', 'Cuba', 'United States']
|
|
|
|
|
|
|
|
variable = tkinter.StringVar()
|
2022-05-26 20:16:01 +03:00
|
|
|
variable.set("test")
|
2022-05-25 18:04:00 +03:00
|
|
|
|
2022-06-13 16:08:13 +03:00
|
|
|
optionmenu_tk = tkinter.OptionMenu(app, variable, *countries, command=select_callback)
|
|
|
|
optionmenu_tk.pack(pady=10, padx=10)
|
2022-05-25 18:04:00 +03:00
|
|
|
|
2022-05-30 18:20:27 +03:00
|
|
|
optionmenu_1 = customtkinter.CTkOptionMenu(app, variable=variable, values=countries, command=select_callback)
|
2022-06-02 02:25:13 +03:00
|
|
|
optionmenu_1.pack(pady=20, padx=10)
|
2022-05-25 18:04:00 +03:00
|
|
|
|
2022-06-13 16:08:13 +03:00
|
|
|
combobox_tk = ttk.Combobox(app, values=countries)
|
|
|
|
combobox_tk.pack(pady=10, padx=10)
|
2022-06-02 00:50:50 +03:00
|
|
|
|
|
|
|
combobox_1 = customtkinter.CTkComboBox(app, variable=variable, values=countries, command=select_callback)
|
2022-06-02 02:25:13 +03:00
|
|
|
combobox_1.pack(pady=20, padx=10)
|
2022-06-02 00:50:50 +03:00
|
|
|
|
2022-05-30 18:20:27 +03:00
|
|
|
app.mainloop()
|