| 1 | title = 'Pmw.LabeledWidget demonstration' |
| 2 | |
| 3 | # Import Pmw from this directory tree. |
| 4 | import sys |
| 5 | sys.path[:0] = ['../../..'] |
| 6 | |
| 7 | import Tkinter |
| 8 | import Pmw |
| 9 | |
| 10 | class Demo: |
| 11 | def __init__(self, parent): |
| 12 | |
| 13 | # Create a frame to put the LabeledWidgets into |
| 14 | frame = Tkinter.Frame(parent, background = 'grey90') |
| 15 | frame.pack(fill = 'both', expand = 1) |
| 16 | |
| 17 | # Create and pack the LabeledWidgets. |
| 18 | column = 0 |
| 19 | row = 0 |
| 20 | for pos in ('n', 'nw', 'wn', 'w'): |
| 21 | lw = Pmw.LabeledWidget(frame, |
| 22 | labelpos = pos, |
| 23 | label_text = pos + ' label') |
| 24 | lw.component('hull').configure(relief='sunken', borderwidth=2) |
| 25 | lw.grid(column=column, row=row, padx=10, pady=10) |
| 26 | cw = Tkinter.Button(lw.interior(), text='child\nsite') |
| 27 | cw.pack(padx=10, pady=10, expand='yes', fill='both') |
| 28 | |
| 29 | # Get ready for next grid position. |
| 30 | column = column + 1 |
| 31 | if column == 2: |
| 32 | column = 0 |
| 33 | row = row + 1 |
| 34 | |
| 35 | ###################################################################### |
| 36 | |
| 37 | # Create demo in root window for testing. |
| 38 | if __name__ == '__main__': |
| 39 | root = Tkinter.Tk() |
| 40 | Pmw.initialise(root) |
| 41 | root.title(title) |
| 42 | |
| 43 | widget = Demo(root) |
| 44 | exitButton = Tkinter.Button(root, text = 'Exit', command = root.destroy) |
| 45 | exitButton.pack() |
| 46 | root.mainloop() |