Skip to content

Commit a34a4b7

Browse files
committed
Enhancement - support for horizontal scroll only for scrollable column element
1 parent fc29f80 commit a34a4b7

2 files changed

Lines changed: 24 additions & 18 deletions

File tree

PySimpleGUI/PySimpleGUI.py

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
"""
5656

57-
version = "6.1.5"
57+
version = "6.1.6"
5858

5959

6060

@@ -86,6 +86,7 @@
8686
6.1.3 1-Jun-2026 Another try at fixing the upgrade from github bug that shows wrong installed version number. This time for sure....
8787
6.1.4 2-Jun-2026 Display the Maint Release version number in the Home Window. Moved the install button
8888
6.1.5 2-Jun-2026 Added ability to specify timers using string "H:M:S" when calling Window.start_timer.
89+
6.1.6 3-Jun-2026 Enhancement - support for horizontal scroll only for scrollable column element
8990
"""
9091

9192

@@ -8061,7 +8062,7 @@ class TkScrollableFrame(tk.Frame):
80618062
A frame with one or two scrollbars. Used to make Columns with scrollbars
80628063
"""
80638064

8064-
def __init__(self, master, vertical_only, element, window, **kwargs):
8065+
def __init__(self, master, vertical_only, horizontal_only, element, window, **kwargs):
80658066
"""
80668067
:param master: The parent widget
80678068
:type master: (tk.Widget)
@@ -8077,26 +8078,23 @@ def __init__(self, master, vertical_only, element, window, **kwargs):
80778078
element.Widget = self.canvas
80788079
# Okay, we're gonna make a list. Containing the y-min, x-min, y-max, and x-max of the frame
80798080
element.element_frame = self
8080-
_make_ttk_scrollbar(element, 'v', window)
8081-
# element.vsb = tk.Scrollbar(self, orient=tk.VERTICAL)
8082-
element.vsb.pack(side='right', fill="y", expand="false")
8081+
if not horizontal_only:
8082+
_make_ttk_scrollbar(element, 'v', window)
8083+
element.vsb.pack(side='right', fill="y", expand="false")
8084+
self.canvas.config(yscrollcommand=element.vsb.set)
80838085

80848086
if not vertical_only:
80858087
_make_ttk_scrollbar(element, 'h', window)
8086-
# self.hscrollbar = tk.Scrollbar(self, orient=tk.HORIZONTAL)
80878088
element.hsb.pack(side='bottom', fill="x", expand="false")
80888089
self.canvas.config(xscrollcommand=element.hsb.set)
8089-
# self.canvas = tk.Canvas(self, )
8090-
# else:
8091-
# self.canvas = tk.Canvas(self)
80928090

8093-
self.canvas.config(yscrollcommand=element.vsb.set)
80948091
self.canvas.pack(side="left", fill="both", expand=True)
8095-
# element.vsb.config(command=self.canvas.yview)
8096-
element.vsb.config(command=self.yview_override)
8092+
80978093
if not vertical_only:
8098-
# element.hsb.config(command=self.canvas.xview)
80998094
element.hsb.config(command=self.xview_override)
8095+
if not horizontal_only:
8096+
element.vsb.config(command=self.yview_override)
8097+
81008098

81018099
# reset the view
81028100
self.canvas.xview_moveto(0)
@@ -8192,7 +8190,7 @@ class Column(Element):
81928190
"""
81938191

81948192
def __init__(self, layout, background_color=None, size=(None, None), s=(None, None), size_subsample_width=1, size_subsample_height=2, pad=None, p=None, scrollable=False,
8195-
vertical_scroll_only=False, right_click_menu=None, key=None, k=None, visible=True, justification=None, element_justification=None,
8193+
vertical_scroll_only=False, horizontal_scroll_only=False, right_click_menu=None, key=None, k=None, visible=True, justification=None, element_justification=None,
81968194
vertical_alignment=None, grab=None, expand_x=None, expand_y=None, metadata=None,
81978195
sbar_trough_color=None, sbar_background_color=None, sbar_arrow_color=None, sbar_width=None, sbar_arrow_width=None,
81988196
sbar_frame_color=None, sbar_relief=None):
@@ -8217,6 +8215,8 @@ def __init__(self, layout, background_color=None, size=(None, None), s=(None, No
82178215
:type scrollable: (bool)
82188216
:param vertical_scroll_only: if True then no horizontal scrollbar will be shown if a scrollable column
82198217
:type vertical_scroll_only: (bool)
8218+
:param horizontal_scroll_only: if True then no verticale scrollbar will be shown if a scrollable column
8219+
:type horizontal_scroll_only: (bool)
82208220
:param right_click_menu: A list of lists of Menu items to show when this element is right clicked. See user docs for exact format.
82218221
:type right_click_menu: List[List[ List[str] | str ]]
82228222
:param key: Value that uniquely identifies this element from all other elements. Used when Finding an element or in return values. Must be unique to the window
@@ -8267,6 +8267,7 @@ def __init__(self, layout, background_color=None, size=(None, None), s=(None, No
82678267
self.TKColFrame = None # type: tk.Frame
82688268
self.Scrollable = scrollable
82698269
self.VerticalScrollOnly = vertical_scroll_only
8270+
self.HorizontalScrollOnly = horizontal_scroll_only
82708271

82718272
self.RightClickMenu = right_click_menu
82728273
bg = background_color if background_color is not None else DEFAULT_BACKGROUND_COLOR
@@ -15829,12 +15830,17 @@ def _add_expansion(element, row_should_expand, row_fill_direction):
1582915830
element = element # type: Column
1583015831
# ----------------------- SCROLLABLE Column ----------------------
1583115832
if element.Scrollable:
15832-
element.Widget = element.TKColFrame = TkScrollableFrame(tk_row_frame, element.VerticalScrollOnly, element, toplevel_form) # do not use yet! not working
15833+
element.Widget = element.TKColFrame = TkScrollableFrame(tk_row_frame, element.VerticalScrollOnly, element.HorizontalScrollOnly, element, toplevel_form) # do not use yet! not working
1583315834
PackFormIntoFrame(element, element.TKColFrame.TKFrame, toplevel_form)
1583415835
element.TKColFrame.TKFrame.update()
1583515836
if element.Size == (None, None): # if no size specified, use column width x column height/2
15836-
element.TKColFrame.canvas.config(width=element.TKColFrame.TKFrame.winfo_reqwidth() // element.size_subsample_width,
15837-
height=element.TKColFrame.TKFrame.winfo_reqheight() // element.size_subsample_height)
15837+
width = element.TKColFrame.TKFrame.winfo_reqwidth()
15838+
if element.HorizontalScrollOnly:
15839+
width = width // element.size_subsample_width
15840+
height = element.TKColFrame.TKFrame.winfo_reqheight()
15841+
if element.VerticalScrollOnly:
15842+
height = height // element.size_subsample_height
15843+
element.TKColFrame.canvas.config(width=width, height=height)
1583815844
else:
1583915845
element.TKColFrame.canvas.config(width=element.TKColFrame.TKFrame.winfo_reqwidth() // element.size_subsample_width,
1584015846
height=element.TKColFrame.TKFrame.winfo_reqheight() // element.size_subsample_height)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def readme():
1111

1212
setuptools.setup(
1313
name="pysimplegui",
14-
version="6.1.5",
14+
version="6.1.6",
1515
author="PySimpleGUI",
1616
author_email="PySimpleGUI@PySimpleGUI.org",
1717
description="Python GUIs for Humans. Launched in 2018. NEW LGPL3 Version 6 released in 2026.",

0 commit comments

Comments
 (0)