mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
0c7abdaec5 | |||
a1cd4abddd | |||
eeeb85ec0d | |||
df1420cd02 | |||
856aa2e1a8 |
15
CHANGELOG.md
15
CHANGELOG.md
@ -1,6 +1,17 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
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).
|
||||||
|
|
||||||
*This document is a WIP.*
|
## [4.0.0] - 2022-05-22
|
||||||
|
### Added
|
||||||
|
- This changelog file
|
||||||
|
- Adopted semantic versioning
|
||||||
|
- Added HighDPI scaling to all widgets and geometry managers (place, pack, grid)
|
||||||
|
- Restructured CTkSettings and renamed a few manager classes
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
- A few unnecessary tests
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
__version__ = "4.0.0"
|
__version__ = "4.0.1"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
@ -2,7 +2,6 @@ import tkinter
|
|||||||
|
|
||||||
from .ctk_canvas import CTkCanvas
|
from .ctk_canvas import CTkCanvas
|
||||||
from ..theme_manager import ThemeManager
|
from ..theme_manager import ThemeManager
|
||||||
from ..settings import Settings
|
|
||||||
from ..draw_engine import DrawEngine
|
from ..draw_engine import DrawEngine
|
||||||
from .widget_base_class import CTkBaseClass
|
from .widget_base_class import CTkBaseClass
|
||||||
|
|
||||||
@ -20,6 +19,7 @@ class CTkEntry(CTkBaseClass):
|
|||||||
border_color="default_theme",
|
border_color="default_theme",
|
||||||
width=120,
|
width=120,
|
||||||
height=30,
|
height=30,
|
||||||
|
state=tkinter.NORMAL,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
|
|
||||||
# transfer basic functionality (bg_color, size, appearance_mode, scaling) to CTkBaseClass
|
# transfer basic functionality (bg_color, size, appearance_mode, scaling) to CTkBaseClass
|
||||||
@ -42,6 +42,8 @@ class CTkEntry(CTkBaseClass):
|
|||||||
self.placeholder_text_active = False
|
self.placeholder_text_active = False
|
||||||
self.pre_placeholder_arguments = {} # some set arguments of the entry will be changed for placeholder and then set back
|
self.pre_placeholder_arguments = {} # some set arguments of the entry will be changed for placeholder and then set back
|
||||||
|
|
||||||
|
self.state = state
|
||||||
|
|
||||||
self.corner_radius = ThemeManager.theme["shape"]["button_corner_radius"] if corner_radius == "default_theme" else corner_radius
|
self.corner_radius = ThemeManager.theme["shape"]["button_corner_radius"] if corner_radius == "default_theme" else corner_radius
|
||||||
self.border_width = ThemeManager.theme["shape"]["entry_border_width"] if border_width == "default_theme" else border_width
|
self.border_width = ThemeManager.theme["shape"]["entry_border_width"] if border_width == "default_theme" else border_width
|
||||||
|
|
||||||
@ -57,6 +59,7 @@ class CTkEntry(CTkBaseClass):
|
|||||||
width=1,
|
width=1,
|
||||||
highlightthickness=0,
|
highlightthickness=0,
|
||||||
font=self.apply_font_scaling(self.text_font),
|
font=self.apply_font_scaling(self.text_font),
|
||||||
|
state=self.state,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
self.entry.grid(column=0, row=0, sticky="we",
|
self.entry.grid(column=0, row=0, sticky="we",
|
||||||
padx=self.apply_widget_scaling(self.corner_radius) if self.corner_radius >= 6 else self.apply_widget_scaling(6))
|
padx=self.apply_widget_scaling(self.corner_radius) if self.corner_radius >= 6 else self.apply_widget_scaling(6))
|
||||||
@ -138,6 +141,11 @@ class CTkEntry(CTkBaseClass):
|
|||||||
def configure(self, *args, **kwargs):
|
def configure(self, *args, **kwargs):
|
||||||
require_redraw = False # some attribute changes require a call of self.draw() at the end
|
require_redraw = False # some attribute changes require a call of self.draw() at the end
|
||||||
|
|
||||||
|
if "state" in kwargs:
|
||||||
|
self.state = kwargs["state"]
|
||||||
|
self.entry.configure(state=self.state)
|
||||||
|
del kwargs["state"]
|
||||||
|
|
||||||
if "bg_color" in kwargs:
|
if "bg_color" in kwargs:
|
||||||
if kwargs["bg_color"] is None:
|
if kwargs["bg_color"] is None:
|
||||||
self.bg_color = self.detect_color_of_master()
|
self.bg_color = self.detect_color_of_master()
|
||||||
|
@ -2,7 +2,6 @@ import tkinter
|
|||||||
|
|
||||||
from .ctk_canvas import CTkCanvas
|
from .ctk_canvas import CTkCanvas
|
||||||
from ..theme_manager import ThemeManager
|
from ..theme_manager import ThemeManager
|
||||||
from ..settings import Settings
|
|
||||||
from ..draw_engine import DrawEngine
|
from ..draw_engine import DrawEngine
|
||||||
from .widget_base_class import CTkBaseClass
|
from .widget_base_class import CTkBaseClass
|
||||||
|
|
||||||
@ -68,6 +67,8 @@ class CTkLabel(CTkBaseClass):
|
|||||||
self.text_label.configure(font=self.apply_font_scaling(self.text_font))
|
self.text_label.configure(font=self.apply_font_scaling(self.text_font))
|
||||||
self.text_label.grid(row=0, column=0, padx=self.apply_widget_scaling(self.corner_radius))
|
self.text_label.grid(row=0, column=0, padx=self.apply_widget_scaling(self.corner_radius))
|
||||||
|
|
||||||
|
self.draw()
|
||||||
|
|
||||||
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.current_width),
|
requires_recoloring = self.draw_engine.draw_rounded_rect_with_border(self.apply_widget_scaling(self.current_width),
|
||||||
self.apply_widget_scaling(self.current_height),
|
self.apply_widget_scaling(self.current_height),
|
||||||
|
@ -13,6 +13,7 @@ class CTkSwitch(CTkBaseClass):
|
|||||||
text="CTkSwitch",
|
text="CTkSwitch",
|
||||||
text_font="default_theme",
|
text_font="default_theme",
|
||||||
text_color="default_theme",
|
text_color="default_theme",
|
||||||
|
text_color_disabled="default_theme",
|
||||||
bg_color=None,
|
bg_color=None,
|
||||||
border_color=None,
|
border_color=None,
|
||||||
fg_color="default_theme",
|
fg_color="default_theme",
|
||||||
@ -30,6 +31,7 @@ class CTkSwitch(CTkBaseClass):
|
|||||||
offvalue=0,
|
offvalue=0,
|
||||||
variable=None,
|
variable=None,
|
||||||
textvariable=None,
|
textvariable=None,
|
||||||
|
state=tkinter.NORMAL,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
|
|
||||||
# transfer basic functionality (bg_color, size, appearance_mode, scaling) to CTkBaseClass
|
# transfer basic functionality (bg_color, size, appearance_mode, scaling) to CTkBaseClass
|
||||||
@ -42,6 +44,7 @@ class CTkSwitch(CTkBaseClass):
|
|||||||
self.button_color = ThemeManager.theme["color"]["switch_button"] if button_color == "default_theme" else button_color
|
self.button_color = ThemeManager.theme["color"]["switch_button"] if button_color == "default_theme" else button_color
|
||||||
self.button_hover_color = ThemeManager.theme["color"]["switch_button_hover"] if button_hover_color == "default_theme" else button_hover_color
|
self.button_hover_color = ThemeManager.theme["color"]["switch_button_hover"] if button_hover_color == "default_theme" else button_hover_color
|
||||||
self.text_color = ThemeManager.theme["color"]["text"] if text_color == "default_theme" else text_color
|
self.text_color = ThemeManager.theme["color"]["text"] if text_color == "default_theme" else text_color
|
||||||
|
self.text_color_disabled = ThemeManager.theme["color"]["text_button_disabled"] if text_color_disabled == "default_theme" else text_color_disabled
|
||||||
|
|
||||||
# text
|
# text
|
||||||
self.text = text
|
self.text = text
|
||||||
@ -55,6 +58,7 @@ class CTkSwitch(CTkBaseClass):
|
|||||||
self.button_length = ThemeManager.theme["shape"]["switch_button_length"] if button_length == "default_theme" else button_length
|
self.button_length = ThemeManager.theme["shape"]["switch_button_length"] if button_length == "default_theme" else button_length
|
||||||
self.hover_state = False
|
self.hover_state = False
|
||||||
self.check_state = False # True if switch is activated
|
self.check_state = False # True if switch is activated
|
||||||
|
self.state = state
|
||||||
self.onvalue = onvalue
|
self.onvalue = onvalue
|
||||||
self.offvalue = offvalue
|
self.offvalue = offvalue
|
||||||
|
|
||||||
@ -119,10 +123,16 @@ class CTkSwitch(CTkBaseClass):
|
|||||||
|
|
||||||
def set_cursor(self):
|
def set_cursor(self):
|
||||||
if Settings.cursor_manipulation_enabled:
|
if Settings.cursor_manipulation_enabled:
|
||||||
if sys.platform == "darwin" and Settings.cursor_manipulation_enabled:
|
if self.state == tkinter.DISABLED:
|
||||||
self.canvas.configure(cursor="pointinghand")
|
if sys.platform == "darwin" and Settings.cursor_manipulation_enabled:
|
||||||
elif sys.platform.startswith("win") and Settings.cursor_manipulation_enabled:
|
self.canvas.configure(cursor="arrow")
|
||||||
self.canvas.configure(cursor="hand2")
|
elif sys.platform.startswith("win") and Settings.cursor_manipulation_enabled:
|
||||||
|
self.canvas.configure(cursor="arrow")
|
||||||
|
else:
|
||||||
|
if sys.platform == "darwin" and Settings.cursor_manipulation_enabled:
|
||||||
|
self.canvas.configure(cursor="pointinghand")
|
||||||
|
elif sys.platform.startswith("win") and Settings.cursor_manipulation_enabled:
|
||||||
|
self.canvas.configure(cursor="hand2")
|
||||||
|
|
||||||
def draw(self, no_color_updates=False):
|
def draw(self, no_color_updates=False):
|
||||||
|
|
||||||
@ -178,7 +188,11 @@ class CTkSwitch(CTkBaseClass):
|
|||||||
if self.textvariable is not None:
|
if self.textvariable is not None:
|
||||||
self.text_label.configure(textvariable=self.textvariable)
|
self.text_label.configure(textvariable=self.textvariable)
|
||||||
|
|
||||||
self.text_label.configure(fg=ThemeManager.single_color(self.text_color, self.appearance_mode))
|
if self.state == tkinter.DISABLED:
|
||||||
|
self.text_label.configure(fg=(ThemeManager.single_color(self.text_color_disabled, self.appearance_mode)))
|
||||||
|
else:
|
||||||
|
self.text_label.configure(fg=ThemeManager.single_color(self.text_color, self.appearance_mode))
|
||||||
|
|
||||||
self.text_label.configure(bg=ThemeManager.single_color(self.bg_color, self.appearance_mode))
|
self.text_label.configure(bg=ThemeManager.single_color(self.bg_color, self.appearance_mode))
|
||||||
|
|
||||||
self.set_text(self.text)
|
self.set_text(self.text)
|
||||||
@ -189,54 +203,59 @@ class CTkSwitch(CTkBaseClass):
|
|||||||
self.text_label.configure(text=self.text)
|
self.text_label.configure(text=self.text)
|
||||||
|
|
||||||
def toggle(self, event=None):
|
def toggle(self, event=None):
|
||||||
if self.check_state is True:
|
if self.state is not tkinter.DISABLED:
|
||||||
self.check_state = False
|
if self.check_state is True:
|
||||||
else:
|
self.check_state = False
|
||||||
self.check_state = True
|
else:
|
||||||
|
self.check_state = True
|
||||||
|
|
||||||
self.draw(no_color_updates=True)
|
self.draw(no_color_updates=True)
|
||||||
|
|
||||||
if self.callback_function is not None:
|
if self.callback_function is not None:
|
||||||
self.callback_function()
|
self.callback_function()
|
||||||
|
|
||||||
if self.variable is not None:
|
if self.variable is not None:
|
||||||
self.variable_callback_blocked = True
|
self.variable_callback_blocked = True
|
||||||
self.variable.set(self.onvalue if self.check_state is True else self.offvalue)
|
self.variable.set(self.onvalue if self.check_state is True else self.offvalue)
|
||||||
self.variable_callback_blocked = False
|
self.variable_callback_blocked = False
|
||||||
|
|
||||||
def select(self, from_variable_callback=False):
|
def select(self, from_variable_callback=False):
|
||||||
self.check_state = True
|
if self.state is not tkinter.DISABLED or from_variable_callback:
|
||||||
|
self.check_state = True
|
||||||
|
|
||||||
self.draw(no_color_updates=True)
|
self.draw(no_color_updates=True)
|
||||||
|
|
||||||
if self.callback_function is not None:
|
if self.callback_function is not None:
|
||||||
self.callback_function()
|
self.callback_function()
|
||||||
|
|
||||||
if self.variable is not None and not from_variable_callback:
|
if self.variable is not None and not from_variable_callback:
|
||||||
self.variable_callback_blocked = True
|
self.variable_callback_blocked = True
|
||||||
self.variable.set(self.onvalue)
|
self.variable.set(self.onvalue)
|
||||||
self.variable_callback_blocked = False
|
self.variable_callback_blocked = False
|
||||||
|
|
||||||
def deselect(self, from_variable_callback=False):
|
def deselect(self, from_variable_callback=False):
|
||||||
self.check_state = False
|
if self.state is not tkinter.DISABLED or from_variable_callback:
|
||||||
|
self.check_state = False
|
||||||
|
|
||||||
self.draw(no_color_updates=True)
|
self.draw(no_color_updates=True)
|
||||||
|
|
||||||
if self.callback_function is not None:
|
if self.callback_function is not None:
|
||||||
self.callback_function()
|
self.callback_function()
|
||||||
|
|
||||||
if self.variable is not None and not from_variable_callback:
|
if self.variable is not None and not from_variable_callback:
|
||||||
self.variable_callback_blocked = True
|
self.variable_callback_blocked = True
|
||||||
self.variable.set(self.offvalue)
|
self.variable.set(self.offvalue)
|
||||||
self.variable_callback_blocked = False
|
self.variable_callback_blocked = False
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
return self.onvalue if self.check_state is True else self.offvalue
|
return self.onvalue if self.check_state is True else self.offvalue
|
||||||
|
|
||||||
def on_enter(self, event=0):
|
def on_enter(self, event=0):
|
||||||
self.hover_state = True
|
self.hover_state = True
|
||||||
self.canvas.itemconfig("slider_parts", fill=ThemeManager.single_color(self.button_hover_color, self.appearance_mode),
|
|
||||||
outline=ThemeManager.single_color(self.button_hover_color, self.appearance_mode))
|
if self.state is not tkinter.DISABLED:
|
||||||
|
self.canvas.itemconfig("slider_parts", fill=ThemeManager.single_color(self.button_hover_color, self.appearance_mode),
|
||||||
|
outline=ThemeManager.single_color(self.button_hover_color, self.appearance_mode))
|
||||||
|
|
||||||
def on_leave(self, event=0):
|
def on_leave(self, event=0):
|
||||||
self.hover_state = False
|
self.hover_state = False
|
||||||
@ -253,6 +272,12 @@ class CTkSwitch(CTkBaseClass):
|
|||||||
def configure(self, *args, **kwargs):
|
def configure(self, *args, **kwargs):
|
||||||
require_redraw = False # some attribute changes require a call of self.draw() at the end
|
require_redraw = False # some attribute changes require a call of self.draw() at the end
|
||||||
|
|
||||||
|
if "state" in kwargs:
|
||||||
|
self.state = kwargs["state"]
|
||||||
|
self.set_cursor()
|
||||||
|
require_redraw = True
|
||||||
|
del kwargs["state"]
|
||||||
|
|
||||||
if "fg_color" in kwargs:
|
if "fg_color" in kwargs:
|
||||||
self.fg_color = kwargs["fg_color"]
|
self.fg_color = kwargs["fg_color"]
|
||||||
require_redraw = True
|
require_redraw = True
|
||||||
|
@ -69,7 +69,6 @@ class CTk(tkinter.Tk):
|
|||||||
if self.current_width != round(detected_width / self.window_scaling) or self.current_height != round(detected_height / self.window_scaling):
|
if self.current_width != round(detected_width / self.window_scaling) or self.current_height != round(detected_height / self.window_scaling):
|
||||||
self.current_width = round(detected_width / self.window_scaling) # adjust current size according to new size given by event
|
self.current_width = round(detected_width / self.window_scaling) # adjust current size according to new size given by event
|
||||||
self.current_height = round(detected_height / self.window_scaling) # current_width and current_height are independent of the scale
|
self.current_height = round(detected_height / self.window_scaling) # current_width and current_height are independent of the scale
|
||||||
print("update_dimensions_event:", self.current_width)
|
|
||||||
|
|
||||||
def set_scaling(self, new_widget_scaling, new_spacing_scaling, new_window_scaling):
|
def set_scaling(self, new_widget_scaling, new_spacing_scaling, new_window_scaling):
|
||||||
self.window_scaling = new_window_scaling
|
self.window_scaling = new_window_scaling
|
||||||
@ -78,7 +77,6 @@ class CTk(tkinter.Tk):
|
|||||||
super().minsize(self.apply_window_scaling(self.current_width), self.apply_window_scaling(self.current_height))
|
super().minsize(self.apply_window_scaling(self.current_width), self.apply_window_scaling(self.current_height))
|
||||||
super().maxsize(self.apply_window_scaling(self.current_width), self.apply_window_scaling(self.current_height))
|
super().maxsize(self.apply_window_scaling(self.current_width), self.apply_window_scaling(self.current_height))
|
||||||
super().geometry(f"{self.apply_window_scaling(self.current_width)}x"+f"{self.apply_window_scaling(self.current_height)}")
|
super().geometry(f"{self.apply_window_scaling(self.current_width)}x"+f"{self.apply_window_scaling(self.current_height)}")
|
||||||
print("set_scaling:", self.apply_window_scaling(self.current_width), self.max_width, self.min_width)
|
|
||||||
|
|
||||||
# set new scaled min and max with 400ms delay (otherwise it won't work for some reason)
|
# set new scaled min and max with 400ms delay (otherwise it won't work for some reason)
|
||||||
self.after(400, self.set_scaled_min_max)
|
self.after(400, self.set_scaled_min_max)
|
||||||
@ -103,7 +101,6 @@ class CTk(tkinter.Tk):
|
|||||||
|
|
||||||
def mainloop(self, *args, **kwargs):
|
def mainloop(self, *args, **kwargs):
|
||||||
if not self.window_exists:
|
if not self.window_exists:
|
||||||
print("deiconify")
|
|
||||||
self.deiconify()
|
self.deiconify()
|
||||||
self.window_exists = True
|
self.window_exists = True
|
||||||
super().mainloop(*args, **kwargs)
|
super().mainloop(*args, **kwargs)
|
||||||
@ -133,7 +130,6 @@ class CTk(tkinter.Tk):
|
|||||||
super().maxsize(self.apply_window_scaling(self.max_width), self.apply_window_scaling(self.max_height))
|
super().maxsize(self.apply_window_scaling(self.max_width), self.apply_window_scaling(self.max_height))
|
||||||
|
|
||||||
def geometry(self, geometry_string):
|
def geometry(self, geometry_string):
|
||||||
print("geometry:", geometry_string)
|
|
||||||
super().geometry(self.apply_geometry_scaling(geometry_string))
|
super().geometry(self.apply_geometry_scaling(geometry_string))
|
||||||
|
|
||||||
# update width and height attributes
|
# update width and height attributes
|
||||||
|
@ -73,7 +73,6 @@ class CTkToplevel(tkinter.Toplevel):
|
|||||||
super().maxsize(self.apply_window_scaling(self.current_width), self.apply_window_scaling(self.current_height))
|
super().maxsize(self.apply_window_scaling(self.current_width), self.apply_window_scaling(self.current_height))
|
||||||
super().geometry(
|
super().geometry(
|
||||||
f"{self.apply_window_scaling(self.current_width)}x" + f"{self.apply_window_scaling(self.current_height)}")
|
f"{self.apply_window_scaling(self.current_width)}x" + f"{self.apply_window_scaling(self.current_height)}")
|
||||||
print("set_scaling:", self.apply_window_scaling(self.current_width), self.max_width, self.min_width)
|
|
||||||
|
|
||||||
# set new scaled min and max with 400ms delay (otherwise it won't work for some reason)
|
# set new scaled min and max with 400ms delay (otherwise it won't work for some reason)
|
||||||
self.after(400, self.set_scaled_min_max)
|
self.after(400, self.set_scaled_min_max)
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 395 KiB After Width: | Height: | Size: 395 KiB |
@ -40,13 +40,13 @@ class App(customtkinter.CTk):
|
|||||||
self.frame.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
|
self.frame.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
|
||||||
|
|
||||||
self.label_1 = customtkinter.CTkLabel(master=self.frame, width=200, height=60,
|
self.label_1 = customtkinter.CTkLabel(master=self.frame, width=200, height=60,
|
||||||
fg_color=("gray70", "gray35"), text="CustomTkinter\ninterface example")
|
fg_color=("gray70", "gray25"), text="CustomTkinter\ninterface example")
|
||||||
self.label_1.place(relx=0.5, rely=0.3, anchor=tkinter.CENTER)
|
self.label_1.place(relx=0.5, rely=0.3, anchor=tkinter.CENTER)
|
||||||
|
|
||||||
self.entry_1 = customtkinter.CTkEntry(master=self.frame, corner_radius=20, width=200, placeholder_text="username")
|
self.entry_1 = customtkinter.CTkEntry(master=self.frame, corner_radius=6, width=200, placeholder_text="username")
|
||||||
self.entry_1.place(relx=0.5, rely=0.52, anchor=tkinter.CENTER)
|
self.entry_1.place(relx=0.5, rely=0.52, anchor=tkinter.CENTER)
|
||||||
|
|
||||||
self.entry_2 = customtkinter.CTkEntry(master=self.frame, corner_radius=20, width=200, show="*", placeholder_text="password")
|
self.entry_2 = customtkinter.CTkEntry(master=self.frame, corner_radius=6, width=200, show="*", placeholder_text="password")
|
||||||
self.entry_2.place(relx=0.5, rely=0.6, anchor=tkinter.CENTER)
|
self.entry_2.place(relx=0.5, rely=0.6, anchor=tkinter.CENTER)
|
||||||
|
|
||||||
self.button_2 = customtkinter.CTkButton(master=self.frame, text="Login",
|
self.button_2 = customtkinter.CTkButton(master=self.frame, text="Login",
|
||||||
|
@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
github_url = "https://github.com/TomSchimansky/CustomTkinter"
|
github_url = "https://github.com/TomSchimansky/CustomTkinter"
|
||||||
|
|
||||||
[tool.tbump.version]
|
[tool.tbump.version]
|
||||||
current = "4.0.0"
|
current = "4.0.1"
|
||||||
|
|
||||||
# Example of a semver regexp.
|
# Example of a semver regexp.
|
||||||
# Make sure this matches current_version before
|
# Make sure this matches current_version before
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = customtkinter
|
name = customtkinter
|
||||||
version = 4.0.0
|
version = 4.0.1
|
||||||
description = Create modern looking GUIs with tkinter and Python
|
description = Create modern looking GUIs with Python
|
||||||
long_description = file: README.md
|
long_description = file: README.md
|
||||||
long_description_content_type = text/markdown
|
long_description_content_type = text/markdown
|
||||||
url = https://github.com/TomSchimansky/CustomTkinter
|
url = https://github.com/TomSchimansky/CustomTkinter
|
||||||
|
@ -32,7 +32,6 @@ class App(customtkinter.CTk):
|
|||||||
height=App.HEIGHT-40,
|
height=App.HEIGHT-40,
|
||||||
corner_radius=5)
|
corner_radius=5)
|
||||||
self.frame_left.place(relx=0.38, rely=0.5, anchor=tkinter.E)
|
self.frame_left.place(relx=0.38, rely=0.5, anchor=tkinter.E)
|
||||||
print(self.frame_left.widget_scaling)
|
|
||||||
|
|
||||||
self.frame_right = customtkinter.CTkFrame(master=self,
|
self.frame_right = customtkinter.CTkFrame(master=self,
|
||||||
width=350,
|
width=350,
|
||||||
@ -65,4 +64,4 @@ class App(customtkinter.CTk):
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app = App()
|
app = App()
|
||||||
app.start()
|
app.start()
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
import tkinter
|
|
||||||
import customtkinter # <- import the CustomTkinter module
|
|
||||||
|
|
||||||
customtkinter.set_appearance_mode("System") # Other: "Dark", "Light"
|
|
||||||
|
|
||||||
root_tk = customtkinter.CTk() # create CTk window like you do with the Tk window (you can also use normal tkinter.Tk window)
|
|
||||||
root_tk.geometry("400x240")
|
|
||||||
root_tk.title("CustomTkinter Test")
|
|
||||||
|
|
||||||
|
|
||||||
def change_button_2_state():
|
|
||||||
if button_2.state == tkinter.NORMAL:
|
|
||||||
button_2.configure(state=tkinter.DISABLED)
|
|
||||||
elif button_2.state == tkinter.DISABLED:
|
|
||||||
button_2.configure(state=tkinter.NORMAL)
|
|
||||||
|
|
||||||
|
|
||||||
def button_2_click():
|
|
||||||
print("button_2 clicked")
|
|
||||||
|
|
||||||
|
|
||||||
frame_1 = customtkinter.CTkFrame(master=root_tk, width=300, height=200, corner_radius=15)
|
|
||||||
frame_1.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
|
|
||||||
|
|
||||||
button_1 = customtkinter.CTkButton(master=frame_1, text="Disable/Enable Button_2",
|
|
||||||
corner_radius=10, command=change_button_2_state, width=200)
|
|
||||||
button_1.place(relx=0.5, rely=0.3, anchor=tkinter.CENTER)
|
|
||||||
|
|
||||||
button_2 = customtkinter.CTkButton(master=frame_1, text="Button_2",
|
|
||||||
corner_radius=10, command=button_2_click)
|
|
||||||
button_2.place(relx=0.5, rely=0.7, anchor=tkinter.CENTER)
|
|
||||||
|
|
||||||
root_tk.mainloop()
|
|
@ -15,11 +15,9 @@ class ExampleApp(customtkinter.CTk):
|
|||||||
window = customtkinter.CTkToplevel(self)
|
window = customtkinter.CTkToplevel(self)
|
||||||
window.geometry("400x200")
|
window.geometry("400x200")
|
||||||
|
|
||||||
print(window.master.winfo_class())
|
|
||||||
|
|
||||||
label = customtkinter.CTkLabel(window, text="CTkToplevel window")
|
label = customtkinter.CTkLabel(window, text="CTkToplevel window")
|
||||||
label.pack(side="top", fill="both", expand=True, padx=40, pady=40)
|
label.pack(side="top", fill="both", expand=True, padx=40, pady=40)
|
||||||
|
|
||||||
|
|
||||||
app = ExampleApp()
|
app = ExampleApp()
|
||||||
app.mainloop()
|
app.mainloop()
|
||||||
|
@ -25,7 +25,8 @@ def button_function():
|
|||||||
|
|
||||||
def slider_function(value):
|
def slider_function(value):
|
||||||
customtkinter.set_widget_scaling(value * 2)
|
customtkinter.set_widget_scaling(value * 2)
|
||||||
customtkinter.ScalingTracker.set_window_scaling(value * 2)
|
customtkinter.set_spacing_scaling(value * 2)
|
||||||
|
customtkinter.set_window_scaling(value * 2)
|
||||||
progressbar_1.set(value)
|
progressbar_1.set(value)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
import tkinter
|
|
||||||
|
|
||||||
app = tkinter.Tk()
|
|
||||||
app.geometry("600x500")
|
|
||||||
|
|
||||||
|
|
||||||
canvas = tkinter.Canvas(master=app, highlightthickness=0, bg="gray30")
|
|
||||||
canvas.pack(expand=True, fill="both")
|
|
||||||
|
|
||||||
text_1 = canvas.create_text(100, 100, text="⬤", font=('Helvetica', -4, 'bold'))
|
|
||||||
text_2 = canvas.create_text(100, 200, text="⬤", font=('Helvetica', -8, 'bold'))
|
|
||||||
text_3 = canvas.create_text(100, 300, text="⬤", font=('Helvetica', -12, 'bold'))
|
|
||||||
text_4 = canvas.create_text(100, 400, text="⬤", font=('Helvetica', -20, 'bold'))
|
|
||||||
text_5 = canvas.create_text(400, 400, text="⬤", font=('Helvetica', -100, 'bold'))
|
|
||||||
|
|
||||||
app.mainloop()
|
|
47
test/manual_integration_tests/test_widget_states.py
Normal file
47
test/manual_integration_tests/test_widget_states.py
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import tkinter
|
||||||
|
import customtkinter
|
||||||
|
|
||||||
|
|
||||||
|
root_tk = customtkinter.CTk()
|
||||||
|
root_tk.geometry("400x800")
|
||||||
|
root_tk.title("CustomTkinter Test")
|
||||||
|
|
||||||
|
|
||||||
|
def change_state(widget):
|
||||||
|
if widget.state == tkinter.NORMAL:
|
||||||
|
widget.configure(state=tkinter.DISABLED)
|
||||||
|
elif widget.state == tkinter.DISABLED:
|
||||||
|
widget.configure(state=tkinter.NORMAL)
|
||||||
|
|
||||||
|
|
||||||
|
def widget_click():
|
||||||
|
print("widget clicked")
|
||||||
|
|
||||||
|
|
||||||
|
button_1 = customtkinter.CTkButton(master=root_tk, text="button_1", command=widget_click)
|
||||||
|
button_1.pack(padx=20, pady=(20, 10))
|
||||||
|
button_2 = customtkinter.CTkButton(master=root_tk, text="Disable/Enable button_1", command=lambda: change_state(button_1))
|
||||||
|
button_2.pack(padx=20, pady=(10, 20))
|
||||||
|
|
||||||
|
switch_1 = customtkinter.CTkSwitch(master=root_tk, text="switch_1", command=widget_click)
|
||||||
|
switch_1.pack(padx=20, pady=(20, 10))
|
||||||
|
button_2 = customtkinter.CTkButton(master=root_tk, text="Disable/Enable switch_1", command=lambda: change_state(switch_1))
|
||||||
|
button_2.pack(padx=20, pady=(10, 20))
|
||||||
|
|
||||||
|
entry_1 = customtkinter.CTkEntry(master=root_tk, placeholder_text="entry_1")
|
||||||
|
entry_1.pack(padx=20, pady=(20, 10))
|
||||||
|
button_3 = customtkinter.CTkButton(master=root_tk, text="Disable/Enable entry_1", command=lambda: change_state(entry_1))
|
||||||
|
button_3.pack(padx=20, pady=(10, 20))
|
||||||
|
|
||||||
|
checkbox_1 = customtkinter.CTkCheckBox(master=root_tk, text="checkbox_1")
|
||||||
|
checkbox_1.pack(padx=20, pady=(20, 10))
|
||||||
|
button_4 = customtkinter.CTkButton(master=root_tk, text="Disable/Enable checkbox_1", command=lambda: change_state(checkbox_1))
|
||||||
|
button_4.pack(padx=20, pady=(10, 20))
|
||||||
|
|
||||||
|
radiobutton_1 = customtkinter.CTkRadioButton(master=root_tk, text="radiobutton_1")
|
||||||
|
radiobutton_1.pack(padx=20, pady=(20, 10))
|
||||||
|
button_5 = customtkinter.CTkButton(master=root_tk, text="Disable/Enable entry_1", command=lambda: change_state(radiobutton_1))
|
||||||
|
button_5.pack(padx=20, pady=(10, 20))
|
||||||
|
|
||||||
|
|
||||||
|
root_tk.mainloop()
|
@ -62,20 +62,15 @@ class TestCTk():
|
|||||||
|
|
||||||
customtkinter.ScalingTracker.set_window_scaling(1.5)
|
customtkinter.ScalingTracker.set_window_scaling(1.5)
|
||||||
self.root_ctk.geometry("300x400")
|
self.root_ctk.geometry("300x400")
|
||||||
self.root_ctk.update()
|
|
||||||
assert self.root_ctk.current_width == 300 and self.root_ctk.current_height == 400
|
assert self.root_ctk.current_width == 300 and self.root_ctk.current_height == 400
|
||||||
assert round(self.root_ctk.winfo_width()) == 450 and round(self.root_ctk.winfo_height()) == 600
|
assert self.root_ctk.window_scaling == 1.5 * customtkinter.ScalingTracker.get_window_dpi_scaling(self.root_ctk)
|
||||||
|
|
||||||
self.root_ctk.maxsize(400, 500)
|
self.root_ctk.maxsize(400, 500)
|
||||||
self.root_ctk.geometry("500x500")
|
self.root_ctk.geometry("500x500")
|
||||||
self.root_ctk.update()
|
|
||||||
assert self.root_ctk.current_width == 400 and self.root_ctk.current_height == 500
|
assert self.root_ctk.current_width == 400 and self.root_ctk.current_height == 500
|
||||||
assert round(self.root_ctk.winfo_width()) == 600 and round(self.root_ctk.winfo_height()) == 750
|
|
||||||
|
|
||||||
customtkinter.ScalingTracker.set_window_scaling(1)
|
customtkinter.ScalingTracker.set_window_scaling(1)
|
||||||
self.root_ctk.update()
|
|
||||||
assert self.root_ctk.current_width == 400 and self.root_ctk.current_height == 500
|
assert self.root_ctk.current_width == 400 and self.root_ctk.current_height == 500
|
||||||
assert round(self.root_ctk.winfo_width()) == 400 and round(self.root_ctk.winfo_height()) == 500
|
|
||||||
print("successful")
|
print("successful")
|
||||||
|
|
||||||
def test_configure(self):
|
def test_configure(self):
|
||||||
|
@ -64,20 +64,15 @@ class TestCTkToplevel():
|
|||||||
|
|
||||||
customtkinter.ScalingTracker.set_window_scaling(1.5)
|
customtkinter.ScalingTracker.set_window_scaling(1.5)
|
||||||
self.ctk_toplevel.geometry("300x400")
|
self.ctk_toplevel.geometry("300x400")
|
||||||
self.ctk_toplevel.update()
|
|
||||||
assert self.ctk_toplevel.current_width == 300 and self.ctk_toplevel.current_height == 400
|
assert self.ctk_toplevel.current_width == 300 and self.ctk_toplevel.current_height == 400
|
||||||
assert round(self.ctk_toplevel.winfo_width()) == 450 and round(self.ctk_toplevel.winfo_height()) == 600
|
assert self.root_ctk.window_scaling == 1.5 * customtkinter.ScalingTracker.get_window_dpi_scaling(self.root_ctk)
|
||||||
|
|
||||||
self.ctk_toplevel.maxsize(400, 500)
|
self.ctk_toplevel.maxsize(400, 500)
|
||||||
self.ctk_toplevel.geometry("500x500")
|
self.ctk_toplevel.geometry("500x500")
|
||||||
self.ctk_toplevel.update()
|
|
||||||
assert self.ctk_toplevel.current_width == 400 and self.ctk_toplevel.current_height == 500
|
assert self.ctk_toplevel.current_width == 400 and self.ctk_toplevel.current_height == 500
|
||||||
assert round(self.ctk_toplevel.winfo_width()) == 600 and round(self.ctk_toplevel.winfo_height()) == 750
|
|
||||||
|
|
||||||
customtkinter.ScalingTracker.set_window_scaling(1)
|
customtkinter.ScalingTracker.set_window_scaling(1)
|
||||||
self.ctk_toplevel.update()
|
|
||||||
assert self.ctk_toplevel.current_width == 400 and self.ctk_toplevel.current_height == 500
|
assert self.ctk_toplevel.current_width == 400 and self.ctk_toplevel.current_height == 500
|
||||||
assert round(self.ctk_toplevel.winfo_width()) == 400 and round(self.ctk_toplevel.winfo_height()) == 500
|
|
||||||
print("successful")
|
print("successful")
|
||||||
|
|
||||||
def test_configure(self):
|
def test_configure(self):
|
||||||
|
Reference in New Issue
Block a user