mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
added orientation for CTkSLider, CTkProgressBar
This commit is contained in:
@ -8,7 +8,7 @@ import re
|
||||
from typing import Union, Tuple
|
||||
|
||||
from ..appearance_mode_tracker import AppearanceModeTracker
|
||||
from ..theme_manager import CTkThemeManager
|
||||
from ..ctk_theme_manager import CTkThemeManager
|
||||
from ..scaling_tracker import ScalingTracker
|
||||
from ..ctk_settings import CTkSettings
|
||||
|
||||
@ -33,10 +33,10 @@ class CTk(tkinter.Tk):
|
||||
|
||||
self.current_width = 600 # initial window size, always without scaling
|
||||
self.current_height = 500
|
||||
self.min_width: Union[int, None] = None
|
||||
self.min_height: Union[int, None] = None
|
||||
self.max_width: Union[int, None] = None
|
||||
self.max_height: Union[int, None] = None
|
||||
self.min_width: int = 0
|
||||
self.min_height: int = 0
|
||||
self.max_width: int = 1_000_000
|
||||
self.max_height: int = 1_000_000
|
||||
self.last_resizable_args: Union[Tuple[list, dict], None] = None # (args, kwargs)
|
||||
|
||||
self.fg_color = CTkThemeManager.theme["color"]["window_bg_color"] if fg_color == "default_theme" else fg_color
|
||||
@ -86,7 +86,7 @@ class CTk(tkinter.Tk):
|
||||
|
||||
# set scaled min, max sizes and reapply resizable
|
||||
if self.last_resizable_args is not None:
|
||||
super().resizable(self.last_resizable_args[0], self.last_resizable_args[1]) # args, kwargs
|
||||
super().resizable(*self.last_resizable_args[0], **self.last_resizable_args[1]) # args, kwargs
|
||||
if self.min_width is not None or self.min_height is not None:
|
||||
super().minsize(self.apply_window_scaling(self.min_width), self.apply_window_scaling(self.min_height))
|
||||
if self.max_width is not None or self.max_height is not None:
|
||||
@ -94,6 +94,7 @@ class CTk(tkinter.Tk):
|
||||
|
||||
def destroy(self):
|
||||
AppearanceModeTracker.remove(self.set_appearance_mode)
|
||||
ScalingTracker.remove_window(self.set_scaling, self)
|
||||
self.disable_macos_dark_title_bar()
|
||||
super().destroy()
|
||||
|
||||
@ -122,11 +123,15 @@ class CTk(tkinter.Tk):
|
||||
def minsize(self, width=None, height=None):
|
||||
self.min_width = width
|
||||
self.min_height = height
|
||||
if self.current_width < width: self.current_width = width
|
||||
if self.current_height < height: self.current_height = height
|
||||
super().minsize(self.apply_window_scaling(self.min_width), self.apply_window_scaling(self.min_height))
|
||||
|
||||
def maxsize(self, width=None, height=None):
|
||||
self.max_width = width
|
||||
self.max_height = height
|
||||
if self.current_width > width: self.current_width = width
|
||||
if self.current_height > height: self.current_height = height
|
||||
super().maxsize(self.apply_window_scaling(self.max_width), self.apply_window_scaling(self.max_height))
|
||||
|
||||
def geometry(self, geometry_string):
|
||||
@ -134,7 +139,8 @@ class CTk(tkinter.Tk):
|
||||
|
||||
# update width and height attributes
|
||||
numbers = list(map(int, re.split(r"[x+]", geometry_string))) # split geometry string into list of numbers
|
||||
self.current_width, self.current_height = numbers[0], numbers[1]
|
||||
self.current_width = max(self.min_width, min(numbers[0], self.max_width)) # bound value between min and max
|
||||
self.current_height = max(self.min_height, min(numbers[1], self.max_height))
|
||||
|
||||
def apply_geometry_scaling(self, geometry_string):
|
||||
numbers = list(map(int, re.split(r"[x+]", geometry_string))) # split geometry string into list of numbers
|
||||
|
Reference in New Issue
Block a user