mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
small fixes for CTkComboBox
This commit is contained in:
@ -354,7 +354,7 @@ class DrawEngine:
|
|||||||
return requires_recoloring
|
return requires_recoloring
|
||||||
|
|
||||||
def draw_rounded_rect_with_border_vertical_split(self, width: Union[float, int], height: Union[float, int], corner_radius: Union[float, int],
|
def draw_rounded_rect_with_border_vertical_split(self, width: Union[float, int], height: Union[float, int], corner_radius: Union[float, int],
|
||||||
border_width: Union[float, int], left_section_width: int) -> bool:
|
border_width: Union[float, int], left_section_width: Union[float, int]) -> bool:
|
||||||
""" Draws a rounded rectangle with a corner_radius and border_width on the canvas which is split at left_section_width.
|
""" Draws a rounded rectangle with a corner_radius and border_width on the canvas which is split at left_section_width.
|
||||||
The border elements have the tags 'border_parts_left', 'border_parts_lright',
|
The border elements have the tags 'border_parts_left', 'border_parts_lright',
|
||||||
the main foreground elements have an 'inner_parts_left' and inner_parts_right' tag,
|
the main foreground elements have an 'inner_parts_left' and inner_parts_right' tag,
|
||||||
@ -362,6 +362,7 @@ class DrawEngine:
|
|||||||
|
|
||||||
returns bool if recoloring is necessary """
|
returns bool if recoloring is necessary """
|
||||||
|
|
||||||
|
left_section_width = round(left_section_width)
|
||||||
width = math.floor(width / 2) * 2 # round (floor) _current_width and _current_height and restrict them to even values only
|
width = math.floor(width / 2) * 2 # round (floor) _current_width and _current_height and restrict them to even values only
|
||||||
height = math.floor(height / 2) * 2
|
height = math.floor(height / 2) * 2
|
||||||
corner_radius = round(corner_radius)
|
corner_radius = round(corner_radius)
|
||||||
|
@ -61,8 +61,6 @@ class CTkComboBox(CTkBaseClass):
|
|||||||
# callback and hover functionality
|
# callback and hover functionality
|
||||||
self.function = command
|
self.function = command
|
||||||
self.variable = variable
|
self.variable = variable
|
||||||
self.variable_callback_blocked = False
|
|
||||||
self.variable_callback_name = None
|
|
||||||
self.state = state
|
self.state = state
|
||||||
self.hover = hover
|
self.hover = hover
|
||||||
self.click_animation_running = False
|
self.click_animation_running = False
|
||||||
@ -91,12 +89,13 @@ class CTkComboBox(CTkBaseClass):
|
|||||||
self.draw_engine = DrawEngine(self.canvas)
|
self.draw_engine = DrawEngine(self.canvas)
|
||||||
|
|
||||||
self.entry = tkinter.Entry(master=self,
|
self.entry = tkinter.Entry(master=self,
|
||||||
width=0,
|
state=self.state,
|
||||||
|
width=1,
|
||||||
bd=0,
|
bd=0,
|
||||||
highlightthickness=0,
|
highlightthickness=0,
|
||||||
font=self.apply_font_scaling(self.text_font))
|
font=self.apply_font_scaling(self.text_font))
|
||||||
left_section_width = self._current_width - self._current_height
|
left_section_width = self._current_width - self._current_height
|
||||||
self.entry.grid(row=0, column=0, rowspan=1, columnspan=1, sticky="w",
|
self.entry.grid(row=0, column=0, rowspan=1, columnspan=1, sticky="ew",
|
||||||
padx=(self.apply_widget_scaling(max(self.corner_radius, 3)),
|
padx=(self.apply_widget_scaling(max(self.corner_radius, 3)),
|
||||||
self.apply_widget_scaling(max(self._current_width - left_section_width + 3, 3))))
|
self.apply_widget_scaling(max(self._current_width - left_section_width + 3, 3))))
|
||||||
|
|
||||||
@ -112,16 +111,15 @@ class CTkComboBox(CTkBaseClass):
|
|||||||
self.bind('<Configure>', self.update_dimensions_event)
|
self.bind('<Configure>', self.update_dimensions_event)
|
||||||
|
|
||||||
if self.variable is not None:
|
if self.variable is not None:
|
||||||
self.variable_callback_name = self.variable.trace_add("write", self.variable_callback)
|
self.entry.configure(textvariable=self.variable)
|
||||||
self.set(self.variable.get(), from_variable_callback=True)
|
|
||||||
|
# if self.variable is not None:
|
||||||
|
# self.variable_callback_name = self.variable.trace_add("write", self.variable_callback)
|
||||||
|
# self.set(self.variable.get(), from_variable_callback=True)
|
||||||
|
|
||||||
def set_scaling(self, *args, **kwargs):
|
def set_scaling(self, *args, **kwargs):
|
||||||
super().set_scaling(*args, **kwargs)
|
super().set_scaling(*args, **kwargs)
|
||||||
|
|
||||||
if self.text_label is not None:
|
|
||||||
self.text_label.destroy()
|
|
||||||
self.text_label = None
|
|
||||||
|
|
||||||
self.canvas.configure(width=self.apply_widget_scaling(self._desired_width),
|
self.canvas.configure(width=self.apply_widget_scaling(self._desired_width),
|
||||||
height=self.apply_widget_scaling(self._desired_height))
|
height=self.apply_widget_scaling(self._desired_height))
|
||||||
self.draw()
|
self.draw()
|
||||||
@ -190,7 +188,7 @@ class CTkComboBox(CTkBaseClass):
|
|||||||
|
|
||||||
if "state" in kwargs:
|
if "state" in kwargs:
|
||||||
self.state = kwargs["state"]
|
self.state = kwargs["state"]
|
||||||
self.set_cursor()
|
self.entry.configure(state=self.state)
|
||||||
require_redraw = True
|
require_redraw = True
|
||||||
del kwargs["state"]
|
del kwargs["state"]
|
||||||
|
|
||||||
@ -227,17 +225,8 @@ class CTkComboBox(CTkBaseClass):
|
|||||||
del kwargs["command"]
|
del kwargs["command"]
|
||||||
|
|
||||||
if "variable" in kwargs:
|
if "variable" in kwargs:
|
||||||
if self.variable is not None: # remove old callback
|
|
||||||
self.variable.trace_remove("write", self.variable_callback_name)
|
|
||||||
|
|
||||||
self.variable = kwargs["variable"]
|
self.variable = kwargs["variable"]
|
||||||
|
self.entry.configure(textvariable=self.variable)
|
||||||
if self.variable is not None and self.variable != "":
|
|
||||||
self.variable_callback_name = self.variable.trace_add("write", self.variable_callback)
|
|
||||||
self.set(self.variable.get(), from_variable_callback=True)
|
|
||||||
else:
|
|
||||||
self.variable = None
|
|
||||||
|
|
||||||
del kwargs["variable"]
|
del kwargs["variable"]
|
||||||
|
|
||||||
if "width" in kwargs:
|
if "width" in kwargs:
|
||||||
@ -248,13 +237,17 @@ class CTkComboBox(CTkBaseClass):
|
|||||||
self.set_dimensions(height=kwargs["height"])
|
self.set_dimensions(height=kwargs["height"])
|
||||||
del kwargs["height"]
|
del kwargs["height"]
|
||||||
|
|
||||||
|
if "values" in kwargs:
|
||||||
|
self.values = kwargs["values"]
|
||||||
|
del kwargs["values"]
|
||||||
|
|
||||||
super().configure(*args, **kwargs)
|
super().configure(*args, **kwargs)
|
||||||
|
|
||||||
if require_redraw:
|
if require_redraw:
|
||||||
self.draw()
|
self.draw()
|
||||||
|
|
||||||
def on_enter(self, event=0):
|
def on_enter(self, event=0):
|
||||||
if self.hover is True and self.state == tkinter.NORMAL:
|
if self.hover is True and self.state == tkinter.NORMAL and len(self.values) > 0:
|
||||||
if sys.platform == "darwin" and len(self.values) > 0 and Settings.cursor_manipulation_enabled:
|
if sys.platform == "darwin" and len(self.values) > 0 and Settings.cursor_manipulation_enabled:
|
||||||
self.canvas.configure(cursor="pointinghand")
|
self.canvas.configure(cursor="pointinghand")
|
||||||
elif sys.platform.startswith("win") and len(self.values) > 0 and Settings.cursor_manipulation_enabled:
|
elif sys.platform.startswith("win") and len(self.values) > 0 and Settings.cursor_manipulation_enabled:
|
||||||
@ -289,30 +282,21 @@ class CTkComboBox(CTkBaseClass):
|
|||||||
if self.click_animation_running:
|
if self.click_animation_running:
|
||||||
self.on_enter()
|
self.on_enter()
|
||||||
|
|
||||||
def variable_callback(self, var_name, index, mode):
|
|
||||||
if not self.variable_callback_blocked:
|
|
||||||
self.set(self.variable.get(), from_variable_callback=True)
|
|
||||||
|
|
||||||
def set(self, value: str, from_variable_callback: bool = False):
|
def set(self, value: str, from_variable_callback: bool = False):
|
||||||
self.current_value = value
|
self.current_value = value
|
||||||
|
|
||||||
self.entry.delete(0, tkinter.END)
|
self.entry.delete(0, tkinter.END)
|
||||||
self.entry.insert(0, self.current_value)
|
self.entry.insert(0, self.current_value)
|
||||||
|
|
||||||
if self.variable is not None and not from_variable_callback:
|
|
||||||
self.variable_callback_blocked = True
|
|
||||||
self.variable.set(self.current_value)
|
|
||||||
self.variable_callback_blocked = False
|
|
||||||
|
|
||||||
if not from_variable_callback:
|
if not from_variable_callback:
|
||||||
if self.function is not None:
|
if self.function is not None:
|
||||||
self.function(self.current_value)
|
self.function(self.current_value)
|
||||||
|
|
||||||
def get(self) -> str:
|
def get(self) -> str:
|
||||||
return self.current_value
|
return self.entry.get()
|
||||||
|
|
||||||
def clicked(self, event=0):
|
def clicked(self, event=0):
|
||||||
if self.state is not tkinter.DISABLED:
|
if self.state is not tkinter.DISABLED and len(self.values) > 0:
|
||||||
self.open_dropdown_menu()
|
self.open_dropdown_menu()
|
||||||
|
|
||||||
# click animation: change color with .on_leave() and back to normal after 100ms with click_animation()
|
# click animation: change color with .on_leave() and back to normal after 100ms with click_animation()
|
||||||
|
@ -93,7 +93,6 @@ class CTkOptionMenu(CTkBaseClass):
|
|||||||
self.canvas.bind("<Button-1>", self.clicked)
|
self.canvas.bind("<Button-1>", self.clicked)
|
||||||
self.bind('<Configure>', self.update_dimensions_event)
|
self.bind('<Configure>', self.update_dimensions_event)
|
||||||
|
|
||||||
self.set_cursor()
|
|
||||||
self.draw() # initial draw
|
self.draw() # initial draw
|
||||||
|
|
||||||
if self.variable is not None:
|
if self.variable is not None:
|
||||||
@ -169,23 +168,21 @@ class CTkOptionMenu(CTkBaseClass):
|
|||||||
self.text_label.configure(bg=ThemeManager.single_color(self.fg_color, self._appearance_mode))
|
self.text_label.configure(bg=ThemeManager.single_color(self.fg_color, self._appearance_mode))
|
||||||
|
|
||||||
def open_dropdown_menu(self):
|
def open_dropdown_menu(self):
|
||||||
if len(self.values) > 0:
|
self.dropdown_menu = DropdownMenu(x_position=self.winfo_rootx(),
|
||||||
self.dropdown_menu = DropdownMenu(x_position=self.winfo_rootx(),
|
y_position=self.winfo_rooty() + self.apply_widget_scaling(self._current_height + 4),
|
||||||
y_position=self.winfo_rooty() + self.apply_widget_scaling(self._current_height + 4),
|
width=self._current_width,
|
||||||
width=self._current_width,
|
values=self.values,
|
||||||
values=self.values,
|
command=self.set,
|
||||||
command=self.set,
|
fg_color=self.dropdown_color,
|
||||||
fg_color=self.dropdown_color,
|
button_hover_color=self.dropdown_hover_color,
|
||||||
button_hover_color=self.dropdown_hover_color,
|
button_color=self.dropdown_color,
|
||||||
button_color=self.dropdown_color,
|
text_color=self.dropdown_text_color)
|
||||||
text_color=self.dropdown_text_color)
|
|
||||||
|
|
||||||
def configure(self, *args, **kwargs):
|
def configure(self, *args, **kwargs):
|
||||||
require_redraw = False # some attribute changes require a call of self.draw() at the end
|
require_redraw = False # some attribute changes require a call of self.draw() at the end
|
||||||
|
|
||||||
if "state" in kwargs:
|
if "state" in kwargs:
|
||||||
self.state = kwargs["state"]
|
self.state = kwargs["state"]
|
||||||
self.set_cursor()
|
|
||||||
require_redraw = True
|
require_redraw = True
|
||||||
del kwargs["state"]
|
del kwargs["state"]
|
||||||
|
|
||||||
@ -246,29 +243,19 @@ class CTkOptionMenu(CTkBaseClass):
|
|||||||
if "values" in kwargs:
|
if "values" in kwargs:
|
||||||
self.values = kwargs["values"]
|
self.values = kwargs["values"]
|
||||||
del kwargs["values"]
|
del kwargs["values"]
|
||||||
self.set_cursor()
|
|
||||||
|
|
||||||
super().configure(*args, **kwargs)
|
super().configure(*args, **kwargs)
|
||||||
|
|
||||||
if require_redraw:
|
if require_redraw:
|
||||||
self.draw()
|
self.draw()
|
||||||
|
|
||||||
def set_cursor(self):
|
|
||||||
if Settings.cursor_manipulation_enabled:
|
|
||||||
if self.state == tkinter.DISABLED:
|
|
||||||
if sys.platform == "darwin" and len(self.values) > 0 and Settings.cursor_manipulation_enabled:
|
|
||||||
self.configure(cursor="arrow")
|
|
||||||
elif sys.platform.startswith("win") and len(self.values) > 0 and Settings.cursor_manipulation_enabled:
|
|
||||||
self.configure(cursor="arrow")
|
|
||||||
|
|
||||||
elif self.state == tkinter.NORMAL:
|
|
||||||
if sys.platform == "darwin" and len(self.values) > 0 and Settings.cursor_manipulation_enabled:
|
|
||||||
self.configure(cursor="pointinghand")
|
|
||||||
elif sys.platform.startswith("win") and len(self.values) > 0 and Settings.cursor_manipulation_enabled:
|
|
||||||
self.configure(cursor="hand2")
|
|
||||||
|
|
||||||
def on_enter(self, event=0):
|
def on_enter(self, event=0):
|
||||||
if self.hover is True and self.state == tkinter.NORMAL:
|
if self.hover is True and self.state == tkinter.NORMAL and len(self.values) > 0:
|
||||||
|
if sys.platform == "darwin" and len(self.values) > 0 and Settings.cursor_manipulation_enabled:
|
||||||
|
self.configure(cursor="pointinghand")
|
||||||
|
elif sys.platform.startswith("win") and len(self.values) > 0 and Settings.cursor_manipulation_enabled:
|
||||||
|
self.configure(cursor="hand2")
|
||||||
|
|
||||||
# set color of inner button parts to hover color
|
# set color of inner button parts to hover color
|
||||||
self.canvas.itemconfig("inner_parts_right",
|
self.canvas.itemconfig("inner_parts_right",
|
||||||
outline=ThemeManager.single_color(self.button_hover_color, self._appearance_mode),
|
outline=ThemeManager.single_color(self.button_hover_color, self._appearance_mode),
|
||||||
@ -278,6 +265,11 @@ class CTkOptionMenu(CTkBaseClass):
|
|||||||
self.click_animation_running = False
|
self.click_animation_running = False
|
||||||
|
|
||||||
if self.hover is True:
|
if self.hover is True:
|
||||||
|
if sys.platform == "darwin" and len(self.values) > 0 and Settings.cursor_manipulation_enabled:
|
||||||
|
self.configure(cursor="arrow")
|
||||||
|
elif sys.platform.startswith("win") and len(self.values) > 0 and Settings.cursor_manipulation_enabled:
|
||||||
|
self.configure(cursor="arrow")
|
||||||
|
|
||||||
# set color of inner button parts
|
# set color of inner button parts
|
||||||
self.canvas.itemconfig("inner_parts_right",
|
self.canvas.itemconfig("inner_parts_right",
|
||||||
outline=ThemeManager.single_color(self.button_color, self._appearance_mode),
|
outline=ThemeManager.single_color(self.button_color, self._appearance_mode),
|
||||||
@ -312,7 +304,7 @@ class CTkOptionMenu(CTkBaseClass):
|
|||||||
return self.current_value
|
return self.current_value
|
||||||
|
|
||||||
def clicked(self, event=0):
|
def clicked(self, event=0):
|
||||||
if self.state is not tkinter.DISABLED:
|
if self.state is not tkinter.DISABLED and len(self.values) > 0:
|
||||||
self.open_dropdown_menu()
|
self.open_dropdown_menu()
|
||||||
|
|
||||||
# click animation: change color with .on_leave() and back to normal after 100ms with click_animation()
|
# click animation: change color with .on_leave() and back to normal after 100ms with click_animation()
|
||||||
|
@ -97,6 +97,7 @@ class DropdownMenu(tkinter.Toplevel):
|
|||||||
hover_color=self.button_hover_color,
|
hover_color=self.button_hover_color,
|
||||||
corner_radius=self.button_corner_radius,
|
corner_radius=self.button_corner_radius,
|
||||||
command=lambda i=index: self.button_callback(i))
|
command=lambda i=index: self.button_callback(i))
|
||||||
|
button.text_label.configure(anchor="w")
|
||||||
button.text_label.grid(row=0, column=0, rowspan=2, columnspan=2, sticky="w")
|
button.text_label.grid(row=0, column=0, rowspan=2, columnspan=2, sticky="w")
|
||||||
button.grid(row=index, column=0,
|
button.grid(row=index, column=0,
|
||||||
padx=x_spacing,
|
padx=x_spacing,
|
||||||
|
@ -4,56 +4,60 @@ import customtkinter
|
|||||||
customtkinter.set_appearance_mode("dark") # Modes: "System" (standard), "Dark", "Light"
|
customtkinter.set_appearance_mode("dark") # Modes: "System" (standard), "Dark", "Light"
|
||||||
customtkinter.set_default_color_theme("blue") # Themes: "blue" (standard), "green", "dark-blue"
|
customtkinter.set_default_color_theme("blue") # Themes: "blue" (standard), "green", "dark-blue"
|
||||||
|
|
||||||
app = customtkinter.CTk() # create CTk window like you do with the Tk window
|
app = customtkinter.CTk()
|
||||||
app.geometry("400x540")
|
app.geometry("400x580")
|
||||||
app.title("CustomTkinter simple_example.py")
|
app.title("CustomTkinter simple_example.py")
|
||||||
|
|
||||||
|
|
||||||
def button_function():
|
def button_callback():
|
||||||
print("Button click")
|
print("Button click", combobox_1.get())
|
||||||
|
|
||||||
|
|
||||||
def slider_function(value):
|
def slider_callback(value):
|
||||||
progressbar_1.set(value)
|
progressbar_1.set(value)
|
||||||
|
|
||||||
|
|
||||||
y_padding = 13
|
|
||||||
|
|
||||||
frame_1 = customtkinter.CTkFrame(master=app)
|
frame_1 = customtkinter.CTkFrame(master=app)
|
||||||
frame_1.pack(pady=20, padx=60, fill="both", expand=True)
|
frame_1.pack(pady=20, padx=60, fill="both", expand=True)
|
||||||
|
|
||||||
label_1 = customtkinter.CTkLabel(master=frame_1, justify=tkinter.LEFT)
|
label_1 = customtkinter.CTkLabel(master=frame_1, justify=tkinter.LEFT)
|
||||||
label_1.pack(pady=y_padding, padx=10)
|
label_1.pack(pady=12, padx=10)
|
||||||
|
|
||||||
progressbar_1 = customtkinter.CTkProgressBar(master=frame_1)
|
progressbar_1 = customtkinter.CTkProgressBar(master=frame_1)
|
||||||
progressbar_1.pack(pady=y_padding, padx=10)
|
progressbar_1.pack(pady=12, padx=10)
|
||||||
|
|
||||||
button_1 = customtkinter.CTkButton(master=frame_1, command=button_function)
|
button_1 = customtkinter.CTkButton(master=frame_1, command=button_callback)
|
||||||
button_1.pack(pady=y_padding, padx=10)
|
button_1.pack(pady=12, padx=10)
|
||||||
|
|
||||||
slider_1 = customtkinter.CTkSlider(master=frame_1, command=slider_function, from_=0, to=1)
|
slider_1 = customtkinter.CTkSlider(master=frame_1, command=slider_callback, from_=0, to=1)
|
||||||
slider_1.pack(pady=y_padding, padx=10)
|
slider_1.pack(pady=12, padx=10)
|
||||||
slider_1.set(0.5)
|
slider_1.set(0.5)
|
||||||
|
|
||||||
entry_1 = customtkinter.CTkEntry(master=frame_1, placeholder_text="CTkEntry")
|
entry_1 = customtkinter.CTkEntry(master=frame_1, placeholder_text="CTkEntry")
|
||||||
entry_1.pack(pady=y_padding, padx=10)
|
entry_1.pack(pady=12, padx=10)
|
||||||
|
|
||||||
optionmenu_1 = customtkinter.CTkOptionMenu(frame_1, values=["Option 1", "Option 2", "Option 42"])
|
s = customtkinter.StringVar(value="test")
|
||||||
optionmenu_1.pack(pady=10, padx=10)
|
|
||||||
|
optionmenu_1 = customtkinter.CTkOptionMenu(frame_1, values=["Option 1", "Option 2", "Option 42"], variable=s)
|
||||||
|
optionmenu_1.pack(pady=12, padx=10)
|
||||||
optionmenu_1.set("CTkOptionMenu")
|
optionmenu_1.set("CTkOptionMenu")
|
||||||
|
|
||||||
|
combobox_1 = customtkinter.CTkComboBox(frame_1, values=["Option 1", "Option 2", "Option 42"], variable=s)
|
||||||
|
combobox_1.pack(pady=12, padx=10)
|
||||||
|
optionmenu_1.set("CTkComboBox")
|
||||||
|
|
||||||
checkbox_1 = customtkinter.CTkCheckBox(master=frame_1)
|
checkbox_1 = customtkinter.CTkCheckBox(master=frame_1)
|
||||||
checkbox_1.pack(pady=y_padding, padx=10)
|
checkbox_1.pack(pady=12, padx=10)
|
||||||
|
|
||||||
radiobutton_var = tkinter.IntVar(value=1)
|
radiobutton_var = tkinter.IntVar(value=1)
|
||||||
|
|
||||||
radiobutton_1 = customtkinter.CTkRadioButton(master=frame_1, variable=radiobutton_var, value=1)
|
radiobutton_1 = customtkinter.CTkRadioButton(master=frame_1, variable=radiobutton_var, value=1)
|
||||||
radiobutton_1.pack(pady=y_padding, padx=10)
|
radiobutton_1.pack(pady=12, padx=10)
|
||||||
|
|
||||||
radiobutton_2 = customtkinter.CTkRadioButton(master=frame_1, variable=radiobutton_var, value=2)
|
radiobutton_2 = customtkinter.CTkRadioButton(master=frame_1, variable=radiobutton_var, value=2)
|
||||||
radiobutton_2.pack(pady=y_padding, padx=10)
|
radiobutton_2.pack(pady=12, padx=10)
|
||||||
|
|
||||||
switch_1 = customtkinter.CTkSwitch(master=frame_1)
|
switch_1 = customtkinter.CTkSwitch(master=frame_1)
|
||||||
switch_1.pack(pady=y_padding, padx=10)
|
switch_1.pack(pady=12, padx=10)
|
||||||
|
|
||||||
app.mainloop()
|
app.mainloop()
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import tkinter
|
import tkinter
|
||||||
|
import tkinter.ttk as ttk
|
||||||
import customtkinter
|
import customtkinter
|
||||||
|
|
||||||
app = customtkinter.CTk()
|
app = customtkinter.CTk()
|
||||||
@ -22,4 +23,10 @@ optionmenu_tk.pack(pady=10, padx=10)
|
|||||||
optionmenu_1 = customtkinter.CTkOptionMenu(app, variable=variable, values=countries, command=select_callback)
|
optionmenu_1 = customtkinter.CTkOptionMenu(app, variable=variable, values=countries, command=select_callback)
|
||||||
optionmenu_1.pack(pady=10, padx=10)
|
optionmenu_1.pack(pady=10, padx=10)
|
||||||
|
|
||||||
|
combobox_tk = ttk.Combobox(app, values=countries)
|
||||||
|
combobox_tk.pack(pady=10, padx=10)
|
||||||
|
|
||||||
|
combobox_1 = customtkinter.CTkComboBox(app, variable=variable, values=countries, command=select_callback)
|
||||||
|
combobox_1.pack(pady=10, padx=10)
|
||||||
|
|
||||||
app.mainloop()
|
app.mainloop()
|
@ -73,8 +73,8 @@ switch_1.pack(pady=20, padx=10)
|
|||||||
optionmenu_var = tkinter.StringVar(value="test")
|
optionmenu_var = tkinter.StringVar(value="test")
|
||||||
optionmenu_1 = customtkinter.CTkOptionMenu(master=app, variable=optionmenu_var, values=["Option 1", "Option 2", "Option 3"])
|
optionmenu_1 = customtkinter.CTkOptionMenu(master=app, variable=optionmenu_var, values=["Option 1", "Option 2", "Option 3"])
|
||||||
optionmenu_1.pack(pady=20, padx=10)
|
optionmenu_1.pack(pady=20, padx=10)
|
||||||
optionmenu_2 = customtkinter.CTkOptionMenu(master=app, values=["Option 1", "Option 2", "Option 3"])
|
combobox_1 = customtkinter.CTkComboBox(master=app, values=["Option 1", "Option 2", "Option 3"])
|
||||||
optionmenu_2.pack(pady=20, padx=10)
|
combobox_1.pack(pady=20, padx=10)
|
||||||
optionmenu_2.configure(variable=optionmenu_var)
|
combobox_1.configure(variable=optionmenu_var)
|
||||||
|
|
||||||
app.mainloop()
|
app.mainloop()
|
||||||
|
@ -48,5 +48,10 @@ optionmenu_1.pack(pady=10, padx=10)
|
|||||||
button_6 = customtkinter.CTkButton(master=app, text="Disable/Enable optionmenu_1", command=lambda: change_state(optionmenu_1))
|
button_6 = customtkinter.CTkButton(master=app, text="Disable/Enable optionmenu_1", command=lambda: change_state(optionmenu_1))
|
||||||
button_6.pack(padx=20, pady=(10, 20))
|
button_6.pack(padx=20, pady=(10, 20))
|
||||||
|
|
||||||
|
combobox_1 = customtkinter.CTkComboBox(app, values=["test 1", "test 2"])
|
||||||
|
combobox_1.pack(pady=10, padx=10)
|
||||||
|
button_7 = customtkinter.CTkButton(master=app, text="Disable/Enable combobox_1", command=lambda: change_state(combobox_1))
|
||||||
|
button_7.pack(padx=20, pady=(10, 20))
|
||||||
|
|
||||||
|
|
||||||
app.mainloop()
|
app.mainloop()
|
||||||
|
Reference in New Issue
Block a user