Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions customtkinter/windows/ctk_tk.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ def mainloop(self, *args, **kwargs):
super().mainloop(*args, **kwargs)

def resizable(self, width: bool = None, height: bool = None):
'''
Configures whether the window is resizable
by the user in the x or y direction
'''
current_resizable_values = super().resizable(width, height)
self._last_resizable_args = ([], {"width": width, "height": height})

Expand All @@ -172,6 +176,7 @@ def resizable(self, width: bool = None, height: bool = None):
return current_resizable_values

def minsize(self, width: int = None, height: int = None):
''' Sets a minimum size of the window in pixels'''
self._min_width = width
self._min_height = height
if self._current_width < width:
Expand All @@ -181,6 +186,7 @@ def minsize(self, width: int = None, height: int = None):
super().minsize(self._apply_window_scaling(self._min_width), self._apply_window_scaling(self._min_height))

def maxsize(self, width: int = None, height: int = None):
''' Sets a maximum size of the window in pixels '''
self._max_width = width
self._max_height = height
if self._current_width > width:
Expand All @@ -190,6 +196,7 @@ def maxsize(self, width: int = None, height: int = None):
super().maxsize(self._apply_window_scaling(self._max_width), self._apply_window_scaling(self._max_height))

def geometry(self, geometry_string: str = None):
''' This sets the size of a window in pixels, given as str in form "WIDTHxHEIGHT" '''
if geometry_string is not None:
super().geometry(self._apply_geometry_scaling(geometry_string))

Expand Down
15 changes: 12 additions & 3 deletions customtkinter/windows/widgets/ctk_scrollable_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,13 @@ def __init__(self,

self.bind("<Configure>", lambda e: self._parent_canvas.configure(scrollregion=self._parent_canvas.bbox("all")))
self._parent_canvas.bind("<Configure>", self._fit_frame_dimensions_to_canvas)
self.bind_all("<MouseWheel>", self._mouse_wheel_all, add="+")

if "linux" in sys.platform:
self.bind_all("<Button-4>", self._mouse_wheel_all, add="+")
self.bind_all("<Button-5>", self._mouse_wheel_all, add="+")
else:
self.bind_all("<MouseWheel>", self._mouse_wheel_all, add="+")

self.bind_all("<KeyPress-Shift_L>", self._keyboard_shift_press_all, add="+")
self.bind_all("<KeyPress-Shift_R>", self._keyboard_shift_press_all, add="+")
self.bind_all("<KeyRelease-Shift_L>", self._keyboard_shift_release_all, add="+")
Expand Down Expand Up @@ -243,6 +249,8 @@ def _set_scroll_increments(self):
self._parent_canvas.configure(xscrollincrement=1, yscrollincrement=1)
elif sys.platform == "darwin":
self._parent_canvas.configure(xscrollincrement=4, yscrollincrement=8)
else:
self._parent_canvas.configure(xscrollincrement=30, yscrollincrement=30)

def _mouse_wheel_all(self, event):
if self.check_if_master_is_canvas(event.widget):
Expand All @@ -263,10 +271,11 @@ def _mouse_wheel_all(self, event):
else:
if self._shift_pressed:
if self._parent_canvas.xview() != (0.0, 1.0):
self._parent_canvas.xview("scroll", -event.delta, "units")
self._parent_canvas.xview_scroll(-1 if event.num == 4 else 1, "units")
else:
if self._parent_canvas.yview() != (0.0, 1.0):
self._parent_canvas.yview("scroll", -event.delta, "units")
self._parent_canvas.yview_scroll(-1 if event.num == 4 else 1, "units")


def _keyboard_shift_press_all(self, event):
self._shift_pressed = True
Expand Down
2 changes: 1 addition & 1 deletion test/manual_integration_tests/test_scrollable_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
frame_5 = customtkinter.CTkScrollableFrame(app, orientation="vertical", label_text="CTkScrollableFrame", corner_radius=0)
frame_5.grid(row=0, column=2, rowspan=2, sticky="nsew")

for i in range(100):
for i in range(20):
customtkinter.CTkCheckBox(frame_1).grid(row=i, padx=10, pady=10)
customtkinter.CTkCheckBox(frame_2).grid(row=i, padx=10, pady=10)
customtkinter.CTkCheckBox(frame_3).grid(row=0, column=i, padx=10, pady=10)
Expand Down