Another go at the scollable column (this time for sure!)
This commit is contained in:
parent
20435d98b1
commit
7530ed0a89
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/python3
|
#!/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'
|
port = 'PySimpleGUI'
|
||||||
|
|
||||||
|
@ -5092,8 +5092,6 @@ class TkFixedFrame(tk.Frame):
|
||||||
# ---------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------- #
|
||||||
# TkScrollableFrame (Used by Column) #
|
# TkScrollableFrame (Used by Column) #
|
||||||
# ---------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------- #
|
||||||
|
|
||||||
|
|
||||||
class TkScrollableFrame(tk.Frame):
|
class TkScrollableFrame(tk.Frame):
|
||||||
"""
|
"""
|
||||||
A frame with one or two scrollbars. Used to make Columns with scrollbars
|
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)
|
tk.Frame.__init__(self, master, **kwargs)
|
||||||
# create a canvas object and a vertical scrollbar for scrolling it
|
# 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 = tk.Scrollbar(self, orient=tk.VERTICAL)
|
||||||
self.vscrollbar.pack(side='right', fill="y", expand="false")
|
self.vscrollbar.pack(side='right', fill="y", expand="false")
|
||||||
|
|
||||||
|
@ -5136,14 +5137,28 @@ class TkScrollableFrame(tk.Frame):
|
||||||
self.config(borderwidth=0, highlightthickness=0)
|
self.config(borderwidth=0, highlightthickness=0)
|
||||||
|
|
||||||
# Canvas can be: master, canvas, TKFrame
|
# Canvas can be: master, canvas, TKFrame
|
||||||
if sys.platform.startswith('linux'):
|
|
||||||
self.canvas.bind('<4>', self.yscroll, add='+')
|
self.TKFrame.bind("<Enter>", self.hookMouseWheel)
|
||||||
self.canvas.bind('<5>', self.yscroll, add='+')
|
self.TKFrame.bind("<Leave>", self.unhookMouseWheel)
|
||||||
else:
|
|
||||||
# Windows and MacOS
|
# self.canvas.bind_all('<4>', self.yscroll, add='+')
|
||||||
self.canvas.bind("<MouseWheel>", self.yscroll, add='+')
|
# self.canvas.bind_all('<5>', self.yscroll, add='+')
|
||||||
self.canvas.bind("<Shift-MouseWheel>", self.xscroll, add='+')
|
# self.canvas.bind_all("<MouseWheel>", self.yscroll, add='+')
|
||||||
self.canvas.bind('<Configure>', self.set_scrollregion)
|
# self.canvas.bind_all("<Shift-MouseWheel>", self.xscroll, add='+')
|
||||||
|
|
||||||
|
self.bind('<Configure>', 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("<MouseWheel>", self.yscroll, add='+')
|
||||||
|
self.TKFrame.bind_all("<Shift-MouseWheel>", self.xscroll, add='+')
|
||||||
|
|
||||||
|
def unhookMouseWheel(self, e):
|
||||||
|
self.TKFrame.unbind_all('<4>')
|
||||||
|
self.TKFrame.unbind_all('<5>')
|
||||||
|
self.TKFrame.unbind_all("<MouseWheel>")
|
||||||
|
self.TKFrame.unbind_all("<Shift-MouseWheel>")
|
||||||
|
|
||||||
def resize_frame(self, e):
|
def resize_frame(self, e):
|
||||||
self.canvas.itemconfig(self.frame_id, height=e.height, width=e.width)
|
self.canvas.itemconfig(self.frame_id, height=e.height, width=e.width)
|
||||||
|
|
Loading…
Reference in New Issue