From 7530ed0a895455ad21bafac7b1c497cc6b6b8f4f Mon Sep 17 00:00:00 2001 From: PySimpleGUI Date: Fri, 3 Apr 2020 18:12:32 -0400 Subject: [PATCH] Another go at the scollable column (this time for sure!) --- PySimpleGUI.py | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 187d4039..0ccab25d 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -version = __version__ = "4.18.0.13 Unreleased - Print and MLine.Print fixed sep char handling, popup_get_date, icon parm popup_animated, popup button size (6,1), NEW CALENDAR chooser integrated, Graph.draw_lines, color chooser set parent window, scrollable column scrollwheel fixed, autoscroll parm for Multiline.print" +version = __version__ = "4.18.0.14 Unreleased - Print and MLine.Print fixed sep char handling, popup_get_date, icon parm popup_animated, popup button size (6,1), NEW CALENDAR chooser integrated, Graph.draw_lines, color chooser set parent window, scrollable column scrollwheel fixed, autoscroll parm for Multiline.print" port = 'PySimpleGUI' @@ -5092,8 +5092,6 @@ class TkFixedFrame(tk.Frame): # ---------------------------------------------------------------------- # # TkScrollableFrame (Used by Column) # # ---------------------------------------------------------------------- # - - class TkScrollableFrame(tk.Frame): """ A frame with one or two scrollbars. Used to make Columns with scrollbars @@ -5108,6 +5106,9 @@ class TkScrollableFrame(tk.Frame): """ tk.Frame.__init__(self, master, **kwargs) # create a canvas object and a vertical scrollbar for scrolling it + + # Okay, we're gonna make a list. Containing the y-min, x-min, y-max, and x-max of the frame + self.vscrollbar = tk.Scrollbar(self, orient=tk.VERTICAL) self.vscrollbar.pack(side='right', fill="y", expand="false") @@ -5136,14 +5137,28 @@ class TkScrollableFrame(tk.Frame): self.config(borderwidth=0, highlightthickness=0) # Canvas can be: master, canvas, TKFrame - if sys.platform.startswith('linux'): - self.canvas.bind('<4>', self.yscroll, add='+') - self.canvas.bind('<5>', self.yscroll, add='+') - else: - # Windows and MacOS - self.canvas.bind("", self.yscroll, add='+') - self.canvas.bind("", self.xscroll, add='+') - self.canvas.bind('', self.set_scrollregion) + + self.TKFrame.bind("", self.hookMouseWheel) + self.TKFrame.bind("", self.unhookMouseWheel) + + # self.canvas.bind_all('<4>', self.yscroll, add='+') + # self.canvas.bind_all('<5>', self.yscroll, add='+') + # self.canvas.bind_all("", self.yscroll, add='+') + # self.canvas.bind_all("", self.xscroll, add='+') + + self.bind('', self.set_scrollregion) + + def hookMouseWheel(self, e): + self.TKFrame.bind_all('<4>', self.yscroll, add='+') + self.TKFrame.bind_all('<5>', self.yscroll, add='+') + self.TKFrame.bind_all("", self.yscroll, add='+') + self.TKFrame.bind_all("", self.xscroll, add='+') + + def unhookMouseWheel(self, e): + self.TKFrame.unbind_all('<4>') + self.TKFrame.unbind_all('<5>') + self.TKFrame.unbind_all("") + self.TKFrame.unbind_all("") def resize_frame(self, e): self.canvas.itemconfig(self.frame_id, height=e.height, width=e.width)