Merge pull request #3243 from PySimpleGUI/Dev-latest

Added code to Window.visibility_changed and Column.contents_changed()
This commit is contained in:
PySimpleGUI 2020-08-04 08:37:00 -04:00 committed by GitHub
commit b5c19c294d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 8 deletions

View File

@ -1,5 +1,5 @@
#!/usr/bin/python3 #!/usr/bin/python3
version = __version__ = "4.28.0 Released 3-Aug-2020" version = __version__ = "4.28.0.1 Unreleased 3-Aug-2020\nAdded a referesh to visiblity_changed (an existing function but blank), added Column.contents_changed which will update the scrollbar so corrently match the contents."
port = 'PySimpleGUI' port = 'PySimpleGUI'
@ -5640,6 +5640,7 @@ class Column(Element):
self.TKColFrame = None self.TKColFrame = None
self.Scrollable = scrollable self.Scrollable = scrollable
self.VerticalScrollOnly = vertical_scroll_only self.VerticalScrollOnly = vertical_scroll_only
self.RightClickMenu = right_click_menu self.RightClickMenu = right_click_menu
bg = background_color if background_color is not None else DEFAULT_BACKGROUND_COLOR bg = background_color if background_color is not None else DEFAULT_BACKGROUND_COLOR
self.ContainerElemementNumber = Window._GetAContainerNumber() self.ContainerElemementNumber = Window._GetAContainerNumber()
@ -5762,6 +5763,15 @@ class Column(Element):
if self.ParentPanedWindow: if self.ParentPanedWindow:
self.ParentPanedWindow.add(self.TKColFrame) self.ParentPanedWindow.add(self.TKColFrame)
def contents_changed(self):
"""
When a scrollable column has part of its layout changed by making elements visibile or invisible, then this function
should be called so that the new scroll area is computed to match the new contents.
"""
self.TKColFrame.canvas.config(scrollregion=self.TKColFrame.canvas.bbox('all'))
add_row = AddRow add_row = AddRow
layout = Layout layout = Layout
set_focus = Element.SetFocus set_focus = Element.SetFocus
@ -8337,14 +8347,12 @@ class Window:
pass pass
def VisibilityChanged(self): def visibility_changed(self):
""" """
Not used in tkinter, but supplied becuase it is used in Qt. Want to remain source code compatible so that if When making an element in a column or someplace that has a scrollbar, then you'll want to call this function
you are making this call in your PySimpleGUIQt code, you can switch to PySimpleGUI and it will not complain prior to the column's contents_changed() method.
about a missing method. Just know that in this version of PySimpleGUI, it does nothing
""" """
# A dummy function. Needed in Qt but not tkinter self.refresh()
return
def SetTransparentColor(self, color): def SetTransparentColor(self, color):
@ -8675,7 +8683,7 @@ class Window:
set_transparent_color = SetTransparentColor set_transparent_color = SetTransparentColor
size = Size size = Size
un_hide = UnHide un_hide = UnHide
visibility_changed = VisibilityChanged VisibilityChanged = visibility_changed
# #
# def __exit__(self, *a): # def __exit__(self, *a):