mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
refined CTkCheckbox checkmark for polygon rendering
This commit is contained in:
@@ -328,9 +328,7 @@ class CTkCheckBox(tkinter.Frame):
|
|||||||
|
|
||||||
def select(self, from_variable_callback=False):
|
def select(self, from_variable_callback=False):
|
||||||
self.check_state = True
|
self.check_state = True
|
||||||
self.canvas.itemconfig("inner_parts",
|
self.draw()
|
||||||
fill=CTkThemeManager.single_color(self.fg_color, self.appearance_mode),
|
|
||||||
outline=CTkThemeManager.single_color(self.fg_color, self.appearance_mode))
|
|
||||||
|
|
||||||
if self.function is not None:
|
if self.function is not None:
|
||||||
self.function()
|
self.function()
|
||||||
@@ -342,9 +340,7 @@ class CTkCheckBox(tkinter.Frame):
|
|||||||
|
|
||||||
def deselect(self, from_variable_callback=False):
|
def deselect(self, from_variable_callback=False):
|
||||||
self.check_state = False
|
self.check_state = False
|
||||||
self.canvas.itemconfig("inner_parts",
|
self.draw()
|
||||||
fill=CTkThemeManager.single_color(self.bg_color, self.appearance_mode),
|
|
||||||
outline=CTkThemeManager.single_color(self.bg_color, self.appearance_mode))
|
|
||||||
|
|
||||||
if self.function is not None:
|
if self.function is not None:
|
||||||
self.function()
|
self.function()
|
||||||
|
@@ -639,7 +639,7 @@ class CTkDrawEngine:
|
|||||||
requires_recoloring = False
|
requires_recoloring = False
|
||||||
|
|
||||||
if self._rendering_method == "polygon_shapes" or self._rendering_method == "circle_shapes":
|
if self._rendering_method == "polygon_shapes" or self._rendering_method == "circle_shapes":
|
||||||
x, y, radius = width / 2, height / 2, size / 2.2
|
x, y, radius = width / 2, height / 2, size / 2.8
|
||||||
if not self._canvas.find_withtag("checkmark"):
|
if not self._canvas.find_withtag("checkmark"):
|
||||||
self._canvas.create_line(0, 0, 0, 0, tags=("checkmark", "create_line"), width=round(height / 8), joinstyle=tkinter.MITER, capstyle=tkinter.ROUND)
|
self._canvas.create_line(0, 0, 0, 0, tags=("checkmark", "create_line"), width=round(height / 8), joinstyle=tkinter.MITER, capstyle=tkinter.ROUND)
|
||||||
self._canvas.tag_raise("checkmark")
|
self._canvas.tag_raise("checkmark")
|
||||||
@@ -647,8 +647,8 @@ class CTkDrawEngine:
|
|||||||
|
|
||||||
self._canvas.coords("checkmark",
|
self._canvas.coords("checkmark",
|
||||||
x + radius, y - radius,
|
x + radius, y - radius,
|
||||||
x - radius / 4, y + radius,
|
x - radius / 4, y + radius * 0.8,
|
||||||
x - radius, y + radius / 4)
|
x - radius, y + radius / 6)
|
||||||
elif self._rendering_method == "font_shapes":
|
elif self._rendering_method == "font_shapes":
|
||||||
if not self._canvas.find_withtag("checkmark"):
|
if not self._canvas.find_withtag("checkmark"):
|
||||||
self._canvas.create_text(0, 0, text="Z", font=("CustomTkinter_shapes_font", -size), tags=("checkmark", "create_text"), anchor=tkinter.CENTER)
|
self._canvas.create_text(0, 0, text="Z", font=("CustomTkinter_shapes_font", -size), tags=("checkmark", "create_text"), anchor=tkinter.CENTER)
|
||||||
|
@@ -6,8 +6,6 @@ import sys
|
|||||||
customtkinter.set_appearance_mode("System") # Modes: "System" (standard), "Dark", "Light"
|
customtkinter.set_appearance_mode("System") # Modes: "System" (standard), "Dark", "Light"
|
||||||
customtkinter.set_default_color_theme("blue") # Themes: "blue" (standard), "green", "dark-blue"
|
customtkinter.set_default_color_theme("blue") # Themes: "blue" (standard), "green", "dark-blue"
|
||||||
|
|
||||||
customtkinter.CTkSettings.preferred_drawing_method = "circle_shapes"
|
|
||||||
|
|
||||||
|
|
||||||
class App(customtkinter.CTk):
|
class App(customtkinter.CTk):
|
||||||
|
|
||||||
@@ -187,6 +185,7 @@ class App(customtkinter.CTk):
|
|||||||
self.slider_1.set(0.2)
|
self.slider_1.set(0.2)
|
||||||
self.slider_2.set(0.7)
|
self.slider_2.set(0.7)
|
||||||
self.progressbar.set(0.5)
|
self.progressbar.set(0.5)
|
||||||
|
self.check_box_2.select()
|
||||||
|
|
||||||
def button_event(self):
|
def button_event(self):
|
||||||
print("Button pressed")
|
print("Button pressed")
|
||||||
|
Reference in New Issue
Block a user