added missing arguments to CTkSLider configure #1790

This commit is contained in:
Tom Schimansky 2023-07-08 21:24:59 +02:00
parent e116faf910
commit 9cfd5f4515
3 changed files with 33 additions and 14 deletions

View File

@ -1,4 +1,5 @@
import tkinter import tkinter
import tkinterDnD
from distutils.version import StrictVersion as Version from distutils.version import StrictVersion as Version
import sys import sys
import os import os
@ -12,8 +13,10 @@ from .widgets.appearance_mode import CTkAppearanceModeBaseClass
from customtkinter.windows.widgets.utility.utility_functions import pop_from_dict_by_set, check_kwargs_empty from customtkinter.windows.widgets.utility.utility_functions import pop_from_dict_by_set, check_kwargs_empty
TK_CLASS = tkinterDnD.Tk
class CTk(tkinter.Tk, CTkAppearanceModeBaseClass, CTkScalingBaseClass):
class CTk(TK_CLASS, CTkAppearanceModeBaseClass, CTkScalingBaseClass):
""" """
Main app window with dark titlebar on Windows and macOS. Main app window with dark titlebar on Windows and macOS.
For detailed information check out the documentation. For detailed information check out the documentation.
@ -35,7 +38,7 @@ class CTk(tkinter.Tk, CTkAppearanceModeBaseClass, CTkScalingBaseClass):
self._enable_macos_dark_title_bar() self._enable_macos_dark_title_bar()
# call init methods of super classes # call init methods of super classes
tkinter.Tk.__init__(self, **pop_from_dict_by_set(kwargs, self._valid_tk_constructor_arguments)) TK_CLASS.__init__(self, **pop_from_dict_by_set(kwargs, self._valid_tk_constructor_arguments))
CTkAppearanceModeBaseClass.__init__(self) CTkAppearanceModeBaseClass.__init__(self)
CTkScalingBaseClass.__init__(self, scaling_type="window") CTkScalingBaseClass.__init__(self, scaling_type="window")
check_kwargs_empty(kwargs, raise_error=True) check_kwargs_empty(kwargs, raise_error=True)

View File

@ -199,15 +199,30 @@ class CTkSlider(CTkBaseClass):
outline=self._apply_appearance_mode(self._button_color)) outline=self._apply_appearance_mode(self._button_color))
def configure(self, require_redraw=False, **kwargs): def configure(self, require_redraw=False, **kwargs):
if "state" in kwargs: if "corner_radius" in kwargs:
self._state = kwargs.pop("state") self._corner_radius = kwargs.pop("corner_radius")
self._set_cursor() require_redraw = True
if "button_corner_radius" in kwargs:
self._button_corner_radius = kwargs.pop("button_corner_radius")
require_redraw = True
if "border_width" in kwargs:
self._border_width = kwargs.pop("border_width")
require_redraw = True
if "button_length" in kwargs:
self._button_length = kwargs.pop("button_length")
require_redraw = True require_redraw = True
if "fg_color" in kwargs: if "fg_color" in kwargs:
self._fg_color = self._check_color_type(kwargs.pop("fg_color")) self._fg_color = self._check_color_type(kwargs.pop("fg_color"))
require_redraw = True require_redraw = True
if "border_color" in kwargs:
self._border_color = self._check_color_type(kwargs.pop("border_color"), transparency=True)
require_redraw = True
if "progress_color" in kwargs: if "progress_color" in kwargs:
self._progress_color = self._check_color_type(kwargs.pop("progress_color"), transparency=True) self._progress_color = self._check_color_type(kwargs.pop("progress_color"), transparency=True)
require_redraw = True require_redraw = True
@ -220,20 +235,17 @@ class CTkSlider(CTkBaseClass):
self._button_hover_color = self._check_color_type(kwargs.pop("button_hover_color")) self._button_hover_color = self._check_color_type(kwargs.pop("button_hover_color"))
require_redraw = True require_redraw = True
if "border_color" in kwargs:
self._border_color = self._check_color_type(kwargs.pop("border_color"), transparency=True)
require_redraw = True
if "border_width" in kwargs:
self._border_width = kwargs.pop("border_width")
require_redraw = True
if "from_" in kwargs: if "from_" in kwargs:
self._from_ = kwargs.pop("from_") self._from_ = kwargs.pop("from_")
if "to" in kwargs: if "to" in kwargs:
self._to = kwargs.pop("to") self._to = kwargs.pop("to")
if "state" in kwargs:
self._state = kwargs.pop("state")
self._set_cursor()
require_redraw = True
if "number_of_steps" in kwargs: if "number_of_steps" in kwargs:
self._number_of_steps = kwargs.pop("number_of_steps") self._number_of_steps = kwargs.pop("number_of_steps")
@ -255,6 +267,10 @@ class CTkSlider(CTkBaseClass):
else: else:
self._variable = None self._variable = None
if "orientation" in kwargs:
self._orientation = kwargs.pop("orientation")
require_redraw = True
super().configure(require_redraw=require_redraw, **kwargs) super().configure(require_redraw=require_redraw, **kwargs)
def cget(self, attribute_name: str) -> any: def cget(self, attribute_name: str) -> any:

View File

@ -28,7 +28,7 @@ button_1 = customtkinter.CTkButton(master=frame_1, command=button_callback)
button_1.pack(pady=10, padx=10) button_1.pack(pady=10, padx=10)
slider_1 = customtkinter.CTkSlider(master=frame_1, command=slider_callback, from_=0, to=1) slider_1 = customtkinter.CTkSlider(master=frame_1, command=slider_callback, from_=0, to=1)
slider_1.pack(pady=10, padx=10) slider_1.pack(pady=10, 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")