mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
Update CTkScrollableFrame
Now the user can : - Set a height of less than 200px in ScrollableFrame if the orientation is Vertical (Default). - Set a width of less than 200px in ScrollableFrame if the orientation is Horizontal. - Change the corner radius of the Scrollbar in ScrollableFrame. - Change the cursor of the Scrollbar (default now is 'hand 2').
This commit is contained in:
parent
e116faf910
commit
9caf657485
@ -30,19 +30,21 @@ class CTkScrollableFrame(tkinter.Frame, CTkAppearanceModeBaseClass, CTkScalingBa
|
|||||||
scrollbar_fg_color: Optional[Union[str, Tuple[str, str]]] = None,
|
scrollbar_fg_color: Optional[Union[str, Tuple[str, str]]] = None,
|
||||||
scrollbar_button_color: Optional[Union[str, Tuple[str, str]]] = None,
|
scrollbar_button_color: Optional[Union[str, Tuple[str, str]]] = None,
|
||||||
scrollbar_button_hover_color: Optional[Union[str, Tuple[str, str]]] = None,
|
scrollbar_button_hover_color: Optional[Union[str, Tuple[str, str]]] = None,
|
||||||
|
scrollbar_corner_radius: Optional[Union[int, str]] = None,
|
||||||
label_fg_color: Optional[Union[str, Tuple[str, str]]] = None,
|
label_fg_color: Optional[Union[str, Tuple[str, str]]] = None,
|
||||||
label_text_color: Optional[Union[str, Tuple[str, str]]] = None,
|
label_text_color: Optional[Union[str, Tuple[str, str]]] = None,
|
||||||
|
|
||||||
label_text: str = "",
|
label_text: str = "",
|
||||||
label_font: Optional[Union[tuple, CTkFont]] = None,
|
label_font: Optional[Union[tuple, CTkFont]] = None,
|
||||||
label_anchor: str = "center",
|
label_anchor: str = "center",
|
||||||
orientation: Literal["vertical", "horizontal"] = "vertical"):
|
orientation: Literal["vertical", "horizontal"] = "vertical",
|
||||||
|
scrollbar_cursor: str = "hand2"):
|
||||||
|
|
||||||
self._orientation = orientation
|
self._orientation = orientation
|
||||||
|
|
||||||
# dimensions independent of scaling
|
# dimensions independent of scaling
|
||||||
self._desired_width = width # _desired_width and _desired_height, represent desired size set by width and height
|
self._desired_width = width # _desired_width represent desired size set by width
|
||||||
self._desired_height = height
|
self._desired_height = height # _desired_height represent desired size set by height
|
||||||
|
|
||||||
self._parent_frame = CTkFrame(master=master, width=0, height=0, corner_radius=corner_radius,
|
self._parent_frame = CTkFrame(master=master, width=0, height=0, corner_radius=corner_radius,
|
||||||
border_width=border_width, bg_color=bg_color, fg_color=fg_color, border_color=border_color)
|
border_width=border_width, bg_color=bg_color, fg_color=fg_color, border_color=border_color)
|
||||||
@ -50,12 +52,12 @@ class CTkScrollableFrame(tkinter.Frame, CTkAppearanceModeBaseClass, CTkScalingBa
|
|||||||
self._set_scroll_increments()
|
self._set_scroll_increments()
|
||||||
|
|
||||||
if self._orientation == "horizontal":
|
if self._orientation == "horizontal":
|
||||||
self._scrollbar = CTkScrollbar(master=self._parent_frame, orientation="horizontal", command=self._parent_canvas.xview,
|
self._scrollbar = CTkScrollbar(master=self._parent_frame, orientation="horizontal", command=self._parent_canvas.xview, width=self._desired_width, cursor=scrollbar_cursor,
|
||||||
fg_color=scrollbar_fg_color, button_color=scrollbar_button_color, button_hover_color=scrollbar_button_hover_color)
|
corner_radius=scrollbar_corner_radius, fg_color=scrollbar_fg_color, button_color=scrollbar_button_color, button_hover_color=scrollbar_button_hover_color)
|
||||||
self._parent_canvas.configure(xscrollcommand=self._scrollbar.set)
|
self._parent_canvas.configure(xscrollcommand=self._scrollbar.set)
|
||||||
elif self._orientation == "vertical":
|
elif self._orientation == "vertical":
|
||||||
self._scrollbar = CTkScrollbar(master=self._parent_frame, orientation="vertical", command=self._parent_canvas.yview,
|
self._scrollbar = CTkScrollbar(master=self._parent_frame, orientation="vertical", command=self._parent_canvas.yview, height=self._desired_height, cursor=scrollbar_cursor,
|
||||||
fg_color=scrollbar_fg_color, button_color=scrollbar_button_color, button_hover_color=scrollbar_button_hover_color)
|
corner_radius=scrollbar_corner_radius, fg_color=scrollbar_fg_color, button_color=scrollbar_button_color, button_hover_color=scrollbar_button_hover_color)
|
||||||
self._parent_canvas.configure(yscrollcommand=self._scrollbar.set)
|
self._parent_canvas.configure(yscrollcommand=self._scrollbar.set)
|
||||||
|
|
||||||
self._label_text = label_text
|
self._label_text = label_text
|
||||||
|
Loading…
Reference in New Issue
Block a user