-
Notifications
You must be signed in to change notification settings - Fork 1
/
ui.py
29 lines (23 loc) · 988 Bytes
/
ui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import tkinter as tk
from tkinter import ttk
class ScrollableFrame(ttk.Frame):
def __init__(self, container, *args, **kwargs):
super().__init__(container, *args, **kwargs)
canvas = tk.Canvas(self)
scrollbar = ttk.Scrollbar(
self, orient="vertical", command=canvas.yview)
scrollbar_h = ttk.Scrollbar(
self, orient="horizontal", command=canvas.xview)
self.scrollable_frame = ttk.Frame(canvas)
self.scrollable_frame.bind(
"<Configure>",
lambda e: canvas.configure(
scrollregion=canvas.bbox("all")
)
)
canvas.create_window((0, 0), window=self.scrollable_frame, anchor="nw")
canvas.configure(yscrollcommand=scrollbar.set)
canvas.configure(xscrollcommand=scrollbar_h.set)
scrollbar_h.pack(side="bottom", fill="x")
scrollbar.pack(side="right", fill="y")
canvas.pack(side="left", fill="both", expand=True)