added missing arguments to configure method of combobox, fixed switch canvas positioning

This commit is contained in:
Tom Schimansky 2022-10-23 13:18:48 +02:00
parent db563b3511
commit 90d11e2f3f
4 changed files with 38 additions and 25 deletions

View File

@ -5,7 +5,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
ToDo: ToDo:
- combine widget and spacing scaling to ui scaling
- complete other theme files - complete other theme files
- auto-scaling of images - auto-scaling of images
- image tuple for light/dark mode - image tuple for light/dark mode
@ -32,6 +31,7 @@ ToDo:
- Removed setter and getter functions like set_text in CTkButton - Removed setter and getter functions like set_text in CTkButton
- Removed bg and background attribute from CTk and CTkToplevel, always use fg_color - Removed bg and background attribute from CTk and CTkToplevel, always use fg_color
- Removed Settings class and moved settings to widget and window classes - Removed Settings class and moved settings to widget and window classes
- removed customtkinter.set_spacing_scaling(), now set_widget_scaling() is used for spacing too
### Fixed ### Fixed

View File

@ -223,15 +223,14 @@ class CTkComboBox(CTkBaseClass):
self._create_grid() self._create_grid()
require_redraw = True require_redraw = True
if "state" in kwargs:
self._state = kwargs.pop("state")
self._entry.configure(state=self._state)
require_redraw = True
if "fg_color" in kwargs: if "fg_color" in kwargs:
self._fg_color = kwargs.pop("fg_color") self._fg_color = kwargs.pop("fg_color")
require_redraw = True require_redraw = True
if "border_color" in kwargs:
self._border_color = kwargs.pop("border_color")
require_redraw = True
if "button_color" in kwargs: if "button_color" in kwargs:
self._button_color = kwargs.pop("button_color") self._button_color = kwargs.pop("button_color")
require_redraw = True require_redraw = True
@ -240,10 +239,23 @@ class CTkComboBox(CTkBaseClass):
self._button_hover_color = kwargs.pop("button_hover_color") self._button_hover_color = kwargs.pop("button_hover_color")
require_redraw = True require_redraw = True
if "dropdown_fg_color" in kwargs:
self._dropdown_menu.configure(fg_color=kwargs.pop("dropdown_fg_color"))
if "dropdown_hover_color" in kwargs:
self._dropdown_menu.configure(hover_color=kwargs.pop("dropdown_hover_color"))
if "dropdown_text_color" in kwargs:
self._dropdown_menu.configure(text_color=kwargs.pop("dropdown_text_color"))
if "text_color" in kwargs: if "text_color" in kwargs:
self._text_color = kwargs.pop("text_color") self._text_color = kwargs.pop("text_color")
require_redraw = True require_redraw = True
if "text_color_disabled" in kwargs:
self._text_color_disabled = kwargs.pop("text_color_disabled")
require_redraw = True
if "font" in kwargs: if "font" in kwargs:
if isinstance(self._font, CTkFont): if isinstance(self._font, CTkFont):
self._font.remove_size_configure_callback(self._update_font) self._font.remove_size_configure_callback(self._update_font)
@ -253,31 +265,27 @@ class CTkComboBox(CTkBaseClass):
self._update_font() self._update_font()
if "hover" in kwargs: if "dropdown_font" in kwargs:
self._hover = kwargs.pop("hover") self._dropdown_menu.configure(font=kwargs.pop("dropdown_font"))
if "command" in kwargs:
self._command = kwargs.pop("command")
if "variable" in kwargs:
self._variable = kwargs.pop("variable")
self._entry.configure(textvariable=self._variable)
if "values" in kwargs: if "values" in kwargs:
self._values = kwargs.pop("values") self._values = kwargs.pop("values")
self._dropdown_menu.configure(values=self._values) self._dropdown_menu.configure(values=self._values)
if "dropdown_fg_color" in kwargs: if "state" in kwargs:
self._dropdown_menu.configure(fg_color=kwargs.pop("dropdown_fg_color")) self._state = kwargs.pop("state")
self._entry.configure(state=self._state)
require_redraw = True
if "dropdown_hover_color" in kwargs: if "hover" in kwargs:
self._dropdown_menu.configure(hover_color=kwargs.pop("dropdown_hover_color")) self._hover = kwargs.pop("hover")
if "dropdown_text_color" in kwargs: if "variable" in kwargs:
self._dropdown_menu.configure(text_color=kwargs.pop("dropdown_text_color")) self._variable = kwargs.pop("variable")
self._entry.configure(textvariable=self._variable)
if "dropdown_font" in kwargs: if "command" in kwargs:
self._dropdown_menu.configure(font=kwargs.pop("dropdown_font")) self._command = kwargs.pop("command")
if "justify" in kwargs: if "justify" in kwargs:
self._entry.configure(justify=kwargs.pop("justify")) self._entry.configure(justify=kwargs.pop("justify"))

View File

@ -104,7 +104,7 @@ class CTkSwitch(CTkBaseClass):
highlightthickness=0, highlightthickness=0,
width=self._apply_widget_scaling(self._switch_width), width=self._apply_widget_scaling(self._switch_width),
height=self._apply_widget_scaling(self._switch_height)) height=self._apply_widget_scaling(self._switch_height))
self._canvas.grid(row=0, column=0, sticky="nswe") self._canvas.grid(row=0, column=0, sticky="")
self._draw_engine = DrawEngine(self._canvas) self._draw_engine = DrawEngine(self._canvas)
self._canvas.bind("<Enter>", self._on_enter) self._canvas.bind("<Enter>", self._on_enter)

View File

@ -1,4 +1,5 @@
import customtkinter import customtkinter
import tkinter
from PIL import Image, ImageTk from PIL import Image, ImageTk
import os import os
@ -54,8 +55,12 @@ class App(customtkinter.CTk):
hover_color="#C77C78", command=self.button_function) hover_color="#C77C78", command=self.button_function)
self.button_5.grid(row=0, column=1, padx=20, pady=20) self.button_5.grid(row=0, column=1, padx=20, pady=20)
self.scaling_button = customtkinter.CTkSegmentedButton(self, values=[0.8, 0.9, 1.0, 1.1, 1.2, 1.5]) self.scaling_button = customtkinter.CTkSegmentedButton(self, values=[0.8, 0.9, 1.0, 1.1, 1.2, 1.5],
command=lambda v: customtkinter.set_widget_scaling(v))
self.scaling_button.grid(row=1, column=0, pady=(0, 20)) self.scaling_button.grid(row=1, column=0, pady=(0, 20))
self.mode_switch = customtkinter.CTkSwitch(self, text="darkmode", onvalue="dark", offvalue="light",
command=lambda: customtkinter.set_appearance_mode(self.mode_switch.get()))
self.mode_switch.grid(row=1, column=1, pady=(0, 20))
def load_image(self, path, image_size): def load_image(self, path, image_size):
""" load rectangular image with path relative to PATH """ """ load rectangular image with path relative to PATH """