1 title = 'Blt Tabset demonstration'
3 # Import Pmw from this directory tree.
5 sys.path[:0] = ['../../..']
11 def __init__(self, parent):
12 if not Pmw.Blt.haveblt(parent):
13 message = 'Sorry\nThe BLT package has not been\n' + \
14 'installed on this system.\n' + \
15 'Please install it and try again.'
16 w = Tkinter.Label(parent, text = message)
17 w.pack(padx = 8, pady = 8)
20 self.tabset = Pmw.Blt.Tabset(parent,
22 highlightthickness = 0,
26 background = self.tabset.cget('background')
27 self.tabset.configure(selectbackground = background,
28 tabbackground = background, activebackground = background)
30 configurePanel = Tkinter.Frame(self.tabset)
31 sideMenu = Pmw.OptionMenu (configurePanel,
34 items = ('top', 'bottom', 'left', 'right'),
35 menubutton_width = 10,
36 command = self.changeSide,
38 sideMenu.pack(anchor = 'w', padx = 10, pady = 10)
40 rotateMenu = Pmw.ComboBox(configurePanel,
42 label_text = 'Text rotation:',
43 entryfield_validate = 'integer',
45 selectioncommand = self.rotateText,
46 scrolledlist_items = (0, 45, 90, 135, 180, 225, 270, 315),
48 rotateMenu.pack(side = 'left', padx = 10, pady = 10)
50 rotateMenu.selectitem(0)
53 self.appearancePanel = Tkinter.Label(self.tabset)
54 helpersPanel = Tkinter.Button(self.tabset,
55 text = 'This is a lot\nof help!')
57 self.tabset.insert('end',
58 'Appearance', 'Configure', 'Helpers', 'Images')
60 self.tabset.tab_configure('Appearance',
61 command = self.appearance_cb, fill = 'both')
62 self.tabset.tab_configure('Configure', window = configurePanel)
63 self.tabset.tab_configure('Images',
64 command = self.images_cb, fill = 'both')
65 self.tabset.tab_configure('Helpers',
66 window = helpersPanel, padx = 100, pady = 150)
69 self.tabset.pack(fill = 'both', expand = 1, padx = 5, pady = 5)
72 def appearance_cb(self):
73 self.appearancePanel.configure(
74 text = 'Don\'t judge a book\nby it\'s cover.')
75 self.tabset.tab_configure('Appearance', window = self.appearancePanel)
78 self.appearancePanel.configure(text = 'Beauty is only\nskin deep.')
79 self.tabset.tab_configure('Images', window = self.appearancePanel)
81 def changeSide(self, side):
82 self.tabset.configure(side = side)
84 def rotateText(self, angle):
85 if Pmw.integervalidator(angle) == Pmw.OK:
86 self.tabset.configure(rotate = angle)
90 ######################################################################
92 # Create demo in root window for testing.
93 if __name__ == '__main__':
98 exitButton = Tkinter.Button(root, text = 'Exit', command = root.destroy)
99 exitButton.pack(side = 'bottom')