mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
fixed progressbar start stop speed increase #775, fixed transparent textbox #779, fixed binding for all widgets #250 #374 #380 #477 #480
This commit is contained in:
@ -102,6 +102,11 @@ class CTkComboBox(CTkBaseClass):
|
||||
font=self._apply_font_scaling(self._font))
|
||||
|
||||
self._create_grid()
|
||||
self._create_bindings()
|
||||
self._draw() # initial draw
|
||||
|
||||
if self._variable is not None:
|
||||
self._entry.configure(textvariable=self._variable)
|
||||
|
||||
# insert default value
|
||||
if len(self._values) > 0:
|
||||
@ -109,18 +114,15 @@ class CTkComboBox(CTkBaseClass):
|
||||
else:
|
||||
self._entry.insert(0, "CTkComboBox")
|
||||
|
||||
self._draw() # initial draw
|
||||
|
||||
# event bindings
|
||||
self._canvas.tag_bind("right_parts", "<Enter>", self._on_enter)
|
||||
self._canvas.tag_bind("dropdown_arrow", "<Enter>", self._on_enter)
|
||||
self._canvas.tag_bind("right_parts", "<Leave>", self._on_leave)
|
||||
self._canvas.tag_bind("dropdown_arrow", "<Leave>", self._on_leave)
|
||||
self._canvas.tag_bind("right_parts", "<Button-1>", self._clicked)
|
||||
self._canvas.tag_bind("dropdown_arrow", "<Button-1>", self._clicked)
|
||||
|
||||
if self._variable is not None:
|
||||
self._entry.configure(textvariable=self._variable)
|
||||
def _create_bindings(self, sequence: Optional[str] = None):
|
||||
""" set necessary bindings for functionality of widget, will overwrite other bindings """
|
||||
if sequence is None:
|
||||
self._canvas.tag_bind("right_parts", "<Enter>", self._on_enter)
|
||||
self._canvas.tag_bind("dropdown_arrow", "<Enter>", self._on_enter)
|
||||
self._canvas.tag_bind("right_parts", "<Leave>", self._on_leave)
|
||||
self._canvas.tag_bind("dropdown_arrow", "<Leave>", self._on_leave)
|
||||
self._canvas.tag_bind("right_parts", "<Button-1>", self._clicked)
|
||||
self._canvas.tag_bind("dropdown_arrow", "<Button-1>", self._clicked)
|
||||
|
||||
def _create_grid(self):
|
||||
self._canvas.grid(row=0, column=0, rowspan=1, columnspan=1, sticky="nsew")
|
||||
@ -391,17 +393,23 @@ class CTkComboBox(CTkBaseClass):
|
||||
def get(self) -> str:
|
||||
return self._entry.get()
|
||||
|
||||
def _clicked(self, event=0):
|
||||
def _clicked(self, event=None):
|
||||
if self._state is not tkinter.DISABLED and len(self._values) > 0:
|
||||
self._open_dropdown_menu()
|
||||
|
||||
def bind(self, sequence=None, command=None, add=None):
|
||||
def bind(self, sequence=None, command=None, add=True):
|
||||
""" called on the tkinter.Entry """
|
||||
return self._entry.bind(sequence, command, add)
|
||||
if add != "+" or add is not True:
|
||||
raise ValueError("'add' argument can only be '+' or True to preserve internal callbacks")
|
||||
self._entry.bind(sequence, command, add=True)
|
||||
|
||||
def unbind(self, sequence, funcid=None):
|
||||
def unbind(self, sequence=None, funcid=None):
|
||||
""" called on the tkinter.Entry """
|
||||
return self._entry.unbind(sequence, funcid)
|
||||
if funcid is not None:
|
||||
raise ValueError("'funcid' argument can only be None, because there is a bug in" +
|
||||
" tkinter and its not clear whether the internal callbacks will be unbinded or not")
|
||||
self._entry.unbind(sequence, None) # unbind all callbacks for sequence
|
||||
self._create_bindings(sequence=sequence) # restore internal callbacks for sequence
|
||||
|
||||
def focus(self):
|
||||
return self._entry.focus()
|
||||
|
Reference in New Issue
Block a user