mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
enhanced bind and unbind with double bind call on two tkinter widgets for some CTk widgets
This commit is contained in:
parent
8b85225133
commit
2964b39410
@ -409,10 +409,14 @@ class CTkButton(CTkBaseClass):
|
|||||||
|
|
||||||
self._command()
|
self._command()
|
||||||
|
|
||||||
def bind(self, sequence=None, command=None, add=None):
|
def bind(self, sequence: str = None, command: Callable = None, add: str = None) -> str:
|
||||||
""" called on the tkinter.Canvas """
|
""" called on the tkinter.Label and tkinter.Canvas """
|
||||||
return self._canvas.bind(sequence, command, add)
|
canvas_bind_return = self._canvas.bind(sequence, command, add)
|
||||||
|
label_bind_return = self._text_label.bind(sequence, command, add)
|
||||||
|
return canvas_bind_return + " + " + label_bind_return
|
||||||
|
|
||||||
def unbind(self, sequence, funcid=None):
|
def unbind(self, sequence: str, funcid: str = None):
|
||||||
""" called on the tkinter.Canvas """
|
""" called on the tkinter.Label and tkinter.Canvas """
|
||||||
return self._canvas.unbind(sequence, funcid)
|
canvas_bind_return, label_bind_return = funcid.split(" + ")
|
||||||
|
self._canvas.unbind(sequence, canvas_bind_return)
|
||||||
|
self._text_label.unbind(sequence, label_bind_return)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import tkinter
|
import tkinter
|
||||||
from typing import Union, Tuple
|
from typing import Union, Tuple, Callable
|
||||||
|
|
||||||
from .ctk_canvas import CTkCanvas
|
from .ctk_canvas import CTkCanvas
|
||||||
from ..theme_manager import ThemeManager
|
from ..theme_manager import ThemeManager
|
||||||
@ -182,10 +182,14 @@ class CTkLabel(CTkBaseClass):
|
|||||||
else:
|
else:
|
||||||
return super().cget(attribute_name) # cget of CTkBaseClass
|
return super().cget(attribute_name) # cget of CTkBaseClass
|
||||||
|
|
||||||
def bind(self, sequence=None, command=None, add=None):
|
def bind(self, sequence: str = None, command: Callable = None, add: str = None) -> str:
|
||||||
""" called on the tkinter.Label """
|
""" called on the tkinter.Label and tkinter.Canvas """
|
||||||
return self._text_label.bind(sequence, command, add)
|
canvas_bind_return = self._canvas.bind(sequence, command, add)
|
||||||
|
label_bind_return = self._text_label.bind(sequence, command, add)
|
||||||
|
return canvas_bind_return + " + " + label_bind_return
|
||||||
|
|
||||||
def unbind(self, sequence, funcid=None):
|
def unbind(self, sequence: str, funcid: str = None):
|
||||||
""" called on the tkinter.Label """
|
""" called on the tkinter.Label and tkinter.Canvas """
|
||||||
return self._text_label.unbind(sequence, funcid)
|
canvas_bind_return, label_bind_return = funcid.split(" + ")
|
||||||
|
self._canvas.unbind(sequence, canvas_bind_return)
|
||||||
|
self._text_label.unbind(sequence, label_bind_return)
|
||||||
|
@ -358,10 +358,14 @@ class CTkOptionMenu(CTkBaseClass):
|
|||||||
if self._state is not tkinter.DISABLED and len(self._values) > 0:
|
if self._state is not tkinter.DISABLED and len(self._values) > 0:
|
||||||
self._open_dropdown_menu()
|
self._open_dropdown_menu()
|
||||||
|
|
||||||
def bind(self, sequence=None, command=None, add=None):
|
def bind(self, sequence: str = None, command: Callable = None, add: str = None) -> str:
|
||||||
""" called on the tkinter.Label """
|
""" called on the tkinter.Label and tkinter.Canvas """
|
||||||
return self._text_label.bind(sequence, command, add)
|
canvas_bind_return = self._canvas.bind(sequence, command, add)
|
||||||
|
label_bind_return = self._text_label.bind(sequence, command, add)
|
||||||
|
return canvas_bind_return + " + " + label_bind_return
|
||||||
|
|
||||||
def unbind(self, sequence, funcid=None):
|
def unbind(self, sequence: str, funcid: str = None):
|
||||||
""" called on the tkinter.Label """
|
""" called on the tkinter.Label and tkinter.Canvas """
|
||||||
return self._text_label.unbind(sequence, funcid)
|
canvas_bind_return, label_bind_return = funcid.split(" + ")
|
||||||
|
self._canvas.unbind(sequence, canvas_bind_return)
|
||||||
|
self._text_label.unbind(sequence, label_bind_return)
|
||||||
|
@ -210,24 +210,3 @@ class CTkTextbox(CTkBaseClass):
|
|||||||
def get(self, index1, index2=None):
|
def get(self, index1, index2=None):
|
||||||
return self._textbox.get(index1, index2)
|
return self._textbox.get(index1, index2)
|
||||||
|
|
||||||
|
|
||||||
def yview(self, *args):
|
|
||||||
return self._textbox.yview(*args)
|
|
||||||
|
|
||||||
def xview(self, *args):
|
|
||||||
return self._textbox.xview(*args)
|
|
||||||
|
|
||||||
def focus(self):
|
|
||||||
return self._textbox.focus()
|
|
||||||
|
|
||||||
def tag_add(self, *args, **kwargs):
|
|
||||||
return self._textbox.tag_add(*args, **kwargs)
|
|
||||||
|
|
||||||
def tag_config(self, *args, **kwargs):
|
|
||||||
return self._textbox.tag_config(*args, **kwargs)
|
|
||||||
|
|
||||||
def tag_configure(self, *args, **kwargs):
|
|
||||||
return self._textbox.tag_configure(*args, **kwargs)
|
|
||||||
|
|
||||||
def tag_remove(self, *args, **kwargs):
|
|
||||||
return self._textbox.tag_remove(*args, **kwargs)
|
|
||||||
|
@ -127,6 +127,9 @@ class App(customtkinter.CTk):
|
|||||||
self.progressbar_1.configure(mode="indeterminnate")
|
self.progressbar_1.configure(mode="indeterminnate")
|
||||||
self.progressbar_1.start()
|
self.progressbar_1.start()
|
||||||
|
|
||||||
|
r = self.logo_label.bind("<Button-1>", lambda e: print("click"))
|
||||||
|
print(r, type(r))
|
||||||
|
|
||||||
def open_input_dialog(self):
|
def open_input_dialog(self):
|
||||||
dialog = customtkinter.CTkInputDialog(master=self, text="Type in a number:", title="CTkInputDialog")
|
dialog = customtkinter.CTkInputDialog(master=self, text="Type in a number:", title="CTkInputDialog")
|
||||||
print("CTkInputDialog:", dialog.get_input())
|
print("CTkInputDialog:", dialog.get_input())
|
||||||
@ -142,7 +145,6 @@ class App(customtkinter.CTk):
|
|||||||
def sidebar_button_callback(self):
|
def sidebar_button_callback(self):
|
||||||
print("sidebar_button click")
|
print("sidebar_button click")
|
||||||
self.entry.delete(0, tkinter.END)
|
self.entry.delete(0, tkinter.END)
|
||||||
print(self.textbox.get("0.0", "end"))
|
|
||||||
|
|
||||||
def on_closing(self, event=0):
|
def on_closing(self, event=0):
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
Loading…
Reference in New Issue
Block a user