A frame with one or two scrollbars. Used to make Columns with scrollbars
| 8041 | # TkScrollableFrame (Used by Column) # |
| 8042 | # ---------------------------------------------------------------------- # |
| 8043 | class TkScrollableFrame(tk.Frame): |
| 8044 | """ |
| 8045 | A frame with one or two scrollbars. Used to make Columns with scrollbars |
| 8046 | """ |
| 8047 | |
| 8048 | def __init__(self, master, vertical_only, horizontal_only, element, window, **kwargs): |
| 8049 | """ |
| 8050 | :param master: The parent widget |
| 8051 | :type master: (tk.Widget) |
| 8052 | :param vertical_only: if True the only a vertical scrollbar will be shown |
| 8053 | :type vertical_only: (bool) |
| 8054 | :param element: The element containing this object |
| 8055 | :type element: (Column) |
| 8056 | """ |
| 8057 | tk.Frame.__init__(self, master, **kwargs) |
| 8058 | # create a canvas object and a vertical scrollbar for scrolling it |
| 8059 | |
| 8060 | self.canvas = tk.Canvas(self) |
| 8061 | element.Widget = self.canvas |
| 8062 | # Okay, we're gonna make a list. Containing the y-min, x-min, y-max, and x-max of the frame |
| 8063 | element.element_frame = self |
| 8064 | if not horizontal_only: |
| 8065 | _make_ttk_scrollbar(element, 'v', window) |
| 8066 | element.vsb.pack(side='right', fill="y", expand="false") |
| 8067 | self.canvas.config(yscrollcommand=element.vsb.set) |
| 8068 | |
| 8069 | if not vertical_only: |
| 8070 | _make_ttk_scrollbar(element, 'h', window) |
| 8071 | element.hsb.pack(side='bottom', fill="x", expand="false") |
| 8072 | self.canvas.config(xscrollcommand=element.hsb.set) |
| 8073 | |
| 8074 | self.canvas.pack(side="left", fill="both", expand=True) |
| 8075 | |
| 8076 | if not vertical_only: |
| 8077 | element.hsb.config(command=self.xview_override) |
| 8078 | if not horizontal_only: |
| 8079 | element.vsb.config(command=self.yview_override) |
| 8080 | |
| 8081 | |
| 8082 | # reset the view |
| 8083 | self.canvas.xview_moveto(0) |
| 8084 | self.canvas.yview_moveto(0) |
| 8085 | |
| 8086 | # create a frame inside the canvas which will be scrolled with it |
| 8087 | self.TKFrame = tk.Frame(self.canvas, **kwargs) |
| 8088 | self.frame_id = self.canvas.create_window(0, 0, window=self.TKFrame, anchor="nw") |
| 8089 | self.canvas.config(borderwidth=0, highlightthickness=0) |
| 8090 | self.TKFrame.config(borderwidth=0, highlightthickness=0) |
| 8091 | self.config(borderwidth=0, highlightthickness=0) |
| 8092 | |
| 8093 | # Canvas can be: master, canvas, TKFrame |
| 8094 | |
| 8095 | # Chr0nic |
| 8096 | |
| 8097 | # self.unhookMouseWheel(None) |
| 8098 | # self.TKFrame.bind("<Enter>", self.hookMouseWheel) |
| 8099 | # self.TKFrame.bind("<Leave>", self.unhookMouseWheel) |
| 8100 | # self.bind('<Configure>', self.set_scrollregion) |