mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
changed combobox and optionemnu command to only get triggered by manual selection #440
This commit is contained in:
parent
66f9fa2386
commit
c16c891115
@ -33,8 +33,7 @@ pip3 install customtkinter
|
|||||||
|
|
||||||
The **official** documentation can be found in the Wiki Tab here:
|
The **official** documentation can be found in the Wiki Tab here:
|
||||||
|
|
||||||
### **--> [Documentation](https://github.com/TomSchimansky/CustomTkinter/wiki)**.
|
**--> [Documentation](https://github.com/TomSchimansky/CustomTkinter/wiki)**.
|
||||||
|
|
||||||
|
|
||||||
## Example Program
|
## Example Program
|
||||||
To test customtkinter you can try this simple example with only a single button:
|
To test customtkinter you can try this simple example with only a single button:
|
||||||
|
@ -268,7 +268,7 @@ class CTkComboBox(CTkBaseClass):
|
|||||||
outline=ThemeManager.single_color(self.button_color, self._appearance_mode),
|
outline=ThemeManager.single_color(self.button_color, self._appearance_mode),
|
||||||
fill=ThemeManager.single_color(self.button_color, self._appearance_mode))
|
fill=ThemeManager.single_color(self.button_color, self._appearance_mode))
|
||||||
|
|
||||||
def set(self, value: str, from_variable_callback: bool = False):
|
def set(self, value: str, from_variable_callback: bool = False, from_dropdown_menu_callback: bool = False):
|
||||||
self.current_value = value
|
self.current_value = value
|
||||||
|
|
||||||
if self.state == "readonly":
|
if self.state == "readonly":
|
||||||
@ -280,7 +280,7 @@ class CTkComboBox(CTkBaseClass):
|
|||||||
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 not from_variable_callback:
|
if from_dropdown_menu_callback:
|
||||||
if self.command is not None:
|
if self.command is not None:
|
||||||
self.command(self.current_value)
|
self.command(self.current_value)
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ class CTkOptionMenu(CTkBaseClass):
|
|||||||
if not self.variable_callback_blocked:
|
if not self.variable_callback_blocked:
|
||||||
self.set(self.variable.get(), from_variable_callback=True)
|
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, from_dropdown_menu_callback: bool = False):
|
||||||
self.current_value = value
|
self.current_value = value
|
||||||
|
|
||||||
self.text_label.configure(text=self.current_value)
|
self.text_label.configure(text=self.current_value)
|
||||||
@ -289,7 +289,7 @@ class CTkOptionMenu(CTkBaseClass):
|
|||||||
self.variable.set(self.current_value)
|
self.variable.set(self.current_value)
|
||||||
self.variable_callback_blocked = False
|
self.variable_callback_blocked = False
|
||||||
|
|
||||||
if not from_variable_callback:
|
if from_dropdown_menu_callback:
|
||||||
if self.command is not None:
|
if self.command is not None:
|
||||||
self.command(self.current_value)
|
self.command(self.current_value)
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ class DropdownMenu(tkinter.Menu):
|
|||||||
|
|
||||||
def button_callback(self, value):
|
def button_callback(self, value):
|
||||||
if self.command is not None:
|
if self.command is not None:
|
||||||
self.command(value)
|
self.command(value, from_dropdown_menu_callback=True)
|
||||||
|
|
||||||
def configure(self, **kwargs):
|
def configure(self, **kwargs):
|
||||||
if "values" in kwargs:
|
if "values" in kwargs:
|
||||||
|
@ -27,10 +27,10 @@ optionmenu_2 = customtkinter.CTkOptionMenu(app, variable=variable, values=countr
|
|||||||
dynamic_resizing=False)
|
dynamic_resizing=False)
|
||||||
optionmenu_2.pack(pady=20, padx=10)
|
optionmenu_2.pack(pady=20, padx=10)
|
||||||
|
|
||||||
combobox_tk = ttk.Combobox(app, values=countries)
|
combobox_tk = ttk.Combobox(app, values=countries, textvariable=variable)
|
||||||
combobox_tk.pack(pady=10, padx=10)
|
combobox_tk.pack(pady=10, padx=10)
|
||||||
|
|
||||||
combobox_1 = customtkinter.CTkComboBox(app, variable=None, values=countries, command=select_callback, width=300)
|
combobox_1 = customtkinter.CTkComboBox(app, variable=variable, values=countries, command=select_callback, width=300)
|
||||||
combobox_1.pack(pady=20, padx=10)
|
combobox_1.pack(pady=20, padx=10)
|
||||||
|
|
||||||
def set_new_scaling(scaling):
|
def set_new_scaling(scaling):
|
||||||
|
Loading…
Reference in New Issue
Block a user