fix checkmark recoloring after scaling

This commit is contained in:
Tom Schimansky 2022-10-15 13:58:51 +02:00
parent 9ffe61dd54
commit a7b278cca0
3 changed files with 21 additions and 16 deletions

View File

@ -5,6 +5,7 @@ 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:
-
- remove bg and background support for CTk and CTkToplevel (to be done) - remove bg and background support for CTk and CTkToplevel (to be done)
- enforce font size in pixel - enforce font size in pixel
- enforce font to be tuple - enforce font to be tuple
@ -13,17 +14,20 @@ ToDo:
## Unreleased - 2022-10-2 ## Unreleased - 2022-10-2
### Added ### Added
- added .cget() method to all widgets and windows - Added CTkTextbox with automatic x and y scrollbars, corner_radius, border_width, border_spacing
- added CTkTextbox with automatic x and y scrollbars, corner_radius, border_width, border_spacing - Added CTkSegmentedButton
- added CTkSegmentedButton - Added CTkTabview
- Added .cget() method to all widgets and windows
- Added .bind() and .focus() methods to almost all widgets
### Changed ### Changed
- changed 'text_font' attribute to 'font' in all widgets - Changed 'text_font' attribute to 'font' in all widgets
- changed 'dropdown_color' attribute to 'dropdown_fg_color' for combobox, optionmenu - Changed 'dropdown_color' attribute to 'dropdown_fg_color' for combobox, optionmenu
- changed 'orient' attribute of CTkProgressBar and CTkSlider to 'orientation' - Changed 'orient' attribute of CTkProgressBar and CTkSlider to 'orientation'
- Width and height attributes of CTkCheckBox, CTkRadioButton, CTkSwitch now describe the outer dimensions of the whole widget. The button/switch size is described by separate attributes like checkbox_width, checkbox_height
### Removed ### Removed
- removed setter and getter functions like set_text in CTkButton - Removed setter and getter functions like set_text in CTkButton
### Fixed ### Fixed

View File

@ -152,19 +152,20 @@ class CTkCheckBox(CTkBaseClass):
super().destroy() super().destroy()
def _draw(self, no_color_updates=False): def _draw(self, no_color_updates=False):
requires_recoloring = self._draw_engine.draw_rounded_rect_with_border(self._apply_widget_scaling(self._checkbox_width), requires_recoloring_1 = self._draw_engine.draw_rounded_rect_with_border(self._apply_widget_scaling(self._checkbox_width),
self._apply_widget_scaling(self._checkbox_height), self._apply_widget_scaling(self._checkbox_height),
self._apply_widget_scaling(self._corner_radius), self._apply_widget_scaling(self._corner_radius),
self._apply_widget_scaling(self._border_width)) self._apply_widget_scaling(self._border_width))
if self._check_state is True: if self._check_state is True:
self._draw_engine.draw_checkmark(self._apply_widget_scaling(self._checkbox_width), requires_recoloring_2 = self._draw_engine.draw_checkmark(self._apply_widget_scaling(self._checkbox_width),
self._apply_widget_scaling(self._checkbox_height), self._apply_widget_scaling(self._checkbox_height),
self._apply_widget_scaling(self._checkbox_height * 0.58)) self._apply_widget_scaling(self._checkbox_height * 0.58))
else: else:
requires_recoloring_2 = False
self._canvas.delete("checkmark") self._canvas.delete("checkmark")
if no_color_updates is False or requires_recoloring: if no_color_updates is False or requires_recoloring_1 or requires_recoloring_2:
self._bg_canvas.configure(bg=ThemeManager.single_color(self._bg_color, self._appearance_mode)) self._bg_canvas.configure(bg=ThemeManager.single_color(self._bg_color, self._appearance_mode))
self._canvas.configure(bg=ThemeManager.single_color(self._bg_color, self._appearance_mode)) self._canvas.configure(bg=ThemeManager.single_color(self._bg_color, self._appearance_mode))

View File

@ -16,7 +16,7 @@ tabview_1.delete("tab 42")
tabview_1.insert(1, "tab 42") tabview_1.insert(1, "tab 42")
tabview_1.delete("tab 42") tabview_1.delete("tab 42")
tabview_1.move(0, "tab 3") tabview_1.move(0, "tab 2")
b1 = customtkinter.CTkButton(master=tab_1, text="button tab 1") b1 = customtkinter.CTkButton(master=tab_1, text="button tab 1")
b1.pack(pady=20) b1.pack(pady=20)