mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
added cget method to base class and button #395
This commit is contained in:
parent
d6075ad544
commit
d103fc42f1
@ -300,6 +300,38 @@ class CTkButton(CTkBaseClass):
|
|||||||
|
|
||||||
super().configure(require_redraw=require_redraw, **kwargs)
|
super().configure(require_redraw=require_redraw, **kwargs)
|
||||||
|
|
||||||
|
def cget(self, key: str) -> any:
|
||||||
|
if key == "fg_color":
|
||||||
|
return self._fg_color
|
||||||
|
elif key == "hover_color":
|
||||||
|
return self._hover_color
|
||||||
|
elif key == "border_color":
|
||||||
|
return self._border_color
|
||||||
|
elif key == "text_color":
|
||||||
|
return self._text_color
|
||||||
|
elif key == "text_color_disabled":
|
||||||
|
return self._text_color_disabled
|
||||||
|
elif key == "text":
|
||||||
|
return self._text
|
||||||
|
elif key == "textvariable":
|
||||||
|
return self._textvariable
|
||||||
|
elif key == "text_font":
|
||||||
|
return self._text_font
|
||||||
|
elif key == "command":
|
||||||
|
return self._command
|
||||||
|
elif key == "hover":
|
||||||
|
return self._hover
|
||||||
|
elif key == "border_width":
|
||||||
|
return self._border_width
|
||||||
|
elif key == "image":
|
||||||
|
return self._image
|
||||||
|
elif key == "compound":
|
||||||
|
return self._compound
|
||||||
|
elif key == "state":
|
||||||
|
return self._state
|
||||||
|
else:
|
||||||
|
return super().cget(key)
|
||||||
|
|
||||||
def _set_cursor(self):
|
def _set_cursor(self):
|
||||||
if Settings.cursor_manipulation_enabled:
|
if Settings.cursor_manipulation_enabled:
|
||||||
if self._state == tkinter.DISABLED:
|
if self._state == tkinter.DISABLED:
|
||||||
|
@ -133,6 +133,16 @@ class CTkBaseClass(tkinter.Frame):
|
|||||||
if require_redraw:
|
if require_redraw:
|
||||||
self._draw()
|
self._draw()
|
||||||
|
|
||||||
|
def cget(self, key: str):
|
||||||
|
if key == "bg_color":
|
||||||
|
return self._bg_color
|
||||||
|
elif key == "width":
|
||||||
|
return self._desired_width
|
||||||
|
elif key == "height":
|
||||||
|
return self._desired_height
|
||||||
|
else:
|
||||||
|
return super().cget(key)
|
||||||
|
|
||||||
def _update_dimensions_event(self, event):
|
def _update_dimensions_event(self, event):
|
||||||
# only redraw if dimensions changed (for performance), independent of scaling
|
# only redraw if dimensions changed (for performance), independent of scaling
|
||||||
if round(self._current_width) != round(event.width / self._widget_scaling) or round(self._current_height) != round(event.height / self._widget_scaling):
|
if round(self._current_width) != round(event.width / self._widget_scaling) or round(self._current_height) != round(event.height / self._widget_scaling):
|
||||||
|
Loading…
Reference in New Issue
Block a user