File: NoteBookS.py

package info (click to toggle)
python-pmw 0.6.2-0.1
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 1,652 kB
  • ctags: 2,716
  • sloc: python: 10,720; makefile: 44; sh: 24
file content (44 lines) | stat: -rw-r--r-- 1,261 bytes parent folder | download | duplicates (3)
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
36
37
38
39
40
41
42
43
44
""" Demonstration of the Pmw NoteBookS megawidget.
"""

# Import Pmw from the sibling directory.
import sys
sys.path[:0] = ['../../..']

import Tkinter
import Pmw

class Demo:
    def __init__(self, parent):

	# Create and pack the NoteBook
	nb = Pmw.NoteBookS(parent)
	nb.pack(pady=10, padx=10, fill='both', expand=1)
	nb.addPage('fruit')
	nb.addPage('veges')
	nb.addPage('candy')

	# Fill in some pages
	frame1 = nb.getPage('fruit')
	frame2 = nb.getPage('veges')
	frame3 = nb.getPage('candy')
	Tkinter.Label(frame1, text='Apple', bg='green').pack(side='top')
	Tkinter.Label(frame1, text='Orange', bg='orange').pack(side='right')
	Tkinter.Label(frame2, text='Carrot', bg='orange').pack(side='left')
	Tkinter.Label(frame2, text='Peas', bg='green').pack(side='bottom')
	Tkinter.Label(frame3, text='Chocolate', bg='brown').pack(padx=30, pady=40, anchor='c')
	
######################################################################

# Create demo in root window for testing.
if __name__ == '__main__':
    root = Tkinter.Tk()
    Pmw.initialise(root, fontScheme = 'pmw1')
    root.title('Pmw NoteBook demonstration') 

    widget = Demo(root)
    exitButton = Tkinter.Button(root, text = 'Exit', command = root.destroy)
    exitButton.pack()
    root.mainloop()