CustomTkinter/test/manual_integration_tests/test_optionmenu_combobox.py

44 lines
1.4 KiB
Python
Raw Normal View History

2022-05-30 18:20:27 +03:00
import tkinter
2022-06-13 16:08:13 +03:00
import tkinter.ttk as ttk
import customtkinter
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')
app.geometry('400x500')
2022-05-30 18:20:27 +03:00
def select_callback(choice):
choice = variable.get()
2022-05-30 17:46:36 +03:00
print("display_selected", choice)
countries = ['Bahamas', 'Canada', 'Cuba', 'United States', "long sdhfhjgdshjafghdgshfhjdsfj"]
2022-05-30 18:20:27 +03:00
variable = tkinter.StringVar()
variable.set("test")
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-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-06-23 22:05:44 +03:00
optionmenu_2 = customtkinter.CTkOptionMenu(app, variable=variable, values=countries, command=select_callback,
dynamic_resizing=False)
optionmenu_2.pack(pady=20, padx=10)
combobox_tk = ttk.Combobox(app, values=countries, textvariable=variable)
2022-06-13 16:08:13 +03:00
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, width=300)
2022-06-02 02:25:13 +03:00
combobox_1.pack(pady=20, padx=10)
2022-06-02 00:50:50 +03:00
def set_new_scaling(scaling):
customtkinter.set_window_scaling(scaling)
customtkinter.set_widget_scaling(scaling)
scaling_slider = customtkinter.CTkSlider(app, command=set_new_scaling, from_=0, to=2)
scaling_slider.pack(pady=20, padx=10)
2022-05-30 18:20:27 +03:00
app.mainloop()