fixed geomtry method for CTk and CTkToplevel

This commit is contained in:
Tom Schimansky 2022-07-17 21:45:29 +02:00
parent 6bfddda399
commit ddd49377d4
2 changed files with 5 additions and 4 deletions

View File

@ -143,6 +143,7 @@ class CTk(tkinter.Tk):
def apply_geometry_scaling(self, geometry_string): def apply_geometry_scaling(self, geometry_string):
value_list = re.split(r"[x+-]", geometry_string) value_list = re.split(r"[x+-]", geometry_string)
separator_list = re.split(r"\d+", geometry_string) separator_list = re.split(r"\d+", geometry_string)
print(separator_list)
if len(value_list) == 2: if len(value_list) == 2:
scaled_width = str(round(int(value_list[0]) * self.window_scaling)) scaled_width = str(round(int(value_list[0]) * self.window_scaling))
@ -151,7 +152,7 @@ class CTk(tkinter.Tk):
elif len(value_list) == 4: elif len(value_list) == 4:
scaled_width = str(round(int(value_list[0]) * self.window_scaling)) scaled_width = str(round(int(value_list[0]) * self.window_scaling))
scaled_height = str(round(int(value_list[1]) * self.window_scaling)) scaled_height = str(round(int(value_list[1]) * self.window_scaling))
return f"{scaled_width}x{scaled_height}{separator_list[1]}{value_list[2]}{separator_list[2]}{value_list[3]}" return f"{scaled_width}x{scaled_height}{separator_list[2]}{value_list[2]}{separator_list[3]}{value_list[3]}"
def reverse_geometry_scaling(self, scaled_geometry_string): def reverse_geometry_scaling(self, scaled_geometry_string):
value_list = re.split(r"[x+-]", scaled_geometry_string) value_list = re.split(r"[x+-]", scaled_geometry_string)
@ -164,7 +165,7 @@ class CTk(tkinter.Tk):
elif len(value_list) == 4: elif len(value_list) == 4:
width = str(round(int(value_list[0]) / self.window_scaling)) width = str(round(int(value_list[0]) / self.window_scaling))
height = str(round(int(value_list[1]) / self.window_scaling)) height = str(round(int(value_list[1]) / self.window_scaling))
return f"{width}x{height}{separator_list[1]}{value_list[2]}{separator_list[2]}{value_list[3]}" return f"{width}x{height}{separator_list[2]}{value_list[2]}{separator_list[3]}{value_list[3]}"
def apply_window_scaling(self, value): def apply_window_scaling(self, value):
if isinstance(value, (int, float)): if isinstance(value, (int, float)):

View File

@ -94,7 +94,7 @@ class CTkToplevel(tkinter.Toplevel):
elif len(value_list) == 4: elif len(value_list) == 4:
scaled_width = str(round(int(value_list[0]) * self.window_scaling)) scaled_width = str(round(int(value_list[0]) * self.window_scaling))
scaled_height = str(round(int(value_list[1]) * self.window_scaling)) scaled_height = str(round(int(value_list[1]) * self.window_scaling))
return f"{scaled_width}x{scaled_height}{separator_list[1]}{value_list[2]}{separator_list[2]}{value_list[3]}" return f"{scaled_width}x{scaled_height}{separator_list[2]}{value_list[2]}{separator_list[3]}{value_list[3]}"
def reverse_geometry_scaling(self, scaled_geometry_string): def reverse_geometry_scaling(self, scaled_geometry_string):
value_list = re.split(r"[x+-]", scaled_geometry_string) value_list = re.split(r"[x+-]", scaled_geometry_string)
@ -107,7 +107,7 @@ class CTkToplevel(tkinter.Toplevel):
elif len(value_list) == 4: elif len(value_list) == 4:
width = str(round(int(value_list[0]) / self.window_scaling)) width = str(round(int(value_list[0]) / self.window_scaling))
height = str(round(int(value_list[1]) / self.window_scaling)) height = str(round(int(value_list[1]) / self.window_scaling))
return f"{width}x{height}{separator_list[1]}{value_list[2]}{separator_list[2]}{value_list[3]}" return f"{width}x{height}{separator_list[2]}{value_list[2]}{separator_list[3]}{value_list[3]}"
def apply_window_scaling(self, value): def apply_window_scaling(self, value):
if isinstance(value, (int, float)): if isinstance(value, (int, float)):