diff options
author | emkael <emkael@tlen.pl> | 2019-06-01 01:14:30 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2019-06-01 01:14:30 +0200 |
commit | 353b6d158c5e34064728514a015ea760ee771268 (patch) | |
tree | ebec1509d6683a355aea70551962ff6b6fc3253a /jfr_playoff/gui/frames/__init__.py | |
parent | 596efa60514452c1e29e0f5a9c89078a49a5b4dc (diff) |
Scrollable frames for team settings
Diffstat (limited to 'jfr_playoff/gui/frames/__init__.py')
-rw-r--r-- | jfr_playoff/gui/frames/__init__.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/jfr_playoff/gui/frames/__init__.py b/jfr_playoff/gui/frames/__init__.py index f75a024..bc6bdb9 100644 --- a/jfr_playoff/gui/frames/__init__.py +++ b/jfr_playoff/gui/frames/__init__.py @@ -94,3 +94,36 @@ class RepeatableEntry(RepeatableFrame): def setValue(self, value): return self.value.set(value) + +class ScrollableFrame(tk.Frame): + def __init__(self, *args, **kwargs): + vertical = False + if 'vertical' in kwargs: + vertical = kwargs['vertical'] + del kwargs['vertical'] + horizontal = False + if 'horizontal' in kwargs: + horizontal = kwargs['horizontal'] + del kwargs['horizontal'] + tk.Frame.__init__(self, *args, **kwargs) + canvas = tk.Canvas(self, borderwidth=0, highlightthickness=0) + if horizontal: + hscroll = tk.Scrollbar( + self, orient=tk.HORIZONTAL, command=canvas.xview) + hscroll.pack(side=tk.BOTTOM, fill=tk.X) + canvas.configure(xscrollcommand=hscroll.set) + if vertical: + vscroll = tk.Scrollbar( + self, orient=tk.VERTICAL, command=canvas.yview) + vscroll.pack(side=tk.RIGHT, fill=tk.Y) + canvas.configure(yscrollcommand=vscroll.set) + frame = tk.Frame(canvas, borderwidth=0, highlightthickness=0) + canvas.pack(side=tk.LEFT, fill=tk.BOTH, expand=True) + canvas.create_window((0,0), window=frame, anchor=tk.N+tk.W) + frame.bind( + '<Configure>', + lambda ev: canvas.configure(scrollregion=canvas.bbox('all'))) + self.renderContent(frame) + + def renderContent(self, container): + pass |