-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotebook.py
35 lines (31 loc) · 1.05 KB
/
notebook.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
30
31
32
33
34
35
try:
# for Python2
from Tkinter import * ## notice capitalized T in Tkinter
except ImportError:
# for Python3
from tkinter import * ## notice lowercase 't' in tkinter here
class notebook(object):
def __init__(self, master, side=LEFT):
self.active_fr = None
self.count = 0
self.choice = IntVar() ## was (0)
if side in (TOP, BOTTOM):
self.side = LEFT
else: self.side = TOP
self.rb_fr = Frame(master, borderwidth=2, relief=GROOVE)
self.rb_fr.pack(side=side, fill=BOTH)
self.screen_fr = Frame(master, borderwidth=2, relief=FLAT)
self.screen_fr.pack(fill=BOTH)
def __call__(self):
return self.screen_fr
def add_screen(self, fr, title):
b = Radiobutton(self.rb_fr, text=title, indicatoron=0, variable=self.choice, value=self.count, command=lambda: self.display(fr))
b.pack(fill=BOTH, side=self.side)
if not self.active_fr:
fr.pack(fill=BOTH, expand=1)
self.active_fr = fr
self.count += 1
def display(self, fr):
self.active_fr.forget( )
fr.pack(fill=BOTH, expand=1)
self.active_fr = fr