| 1 | title = 'Pmw.TimeCounter demonstration' |
| 2 | |
| 3 | # Import Pmw from this directory tree. |
| 4 | import sys |
| 5 | sys.path[:0] = ['../../..'] |
| 6 | |
| 7 | import string |
| 8 | import Tkinter |
| 9 | import Pmw |
| 10 | |
| 11 | class Demo: |
| 12 | def __init__(self, parent): |
| 13 | self._time = Pmw.TimeCounter(parent, |
| 14 | labelpos = 'w', |
| 15 | label_text = 'HH:MM:SS', |
| 16 | min = '00:00:00', |
| 17 | max = '23:59:59') |
| 18 | self._time.pack(padx=10, pady=5) |
| 19 | |
| 20 | button = Tkinter.Button(parent, text = 'Show', command = self.show) |
| 21 | button.pack() |
| 22 | |
| 23 | def show(self): |
| 24 | stringVal = self._time.getstring() |
| 25 | intVal = self._time.getint() |
| 26 | print stringVal + ' (' + str(intVal) + ')' |
| 27 | |
| 28 | |
| 29 | ###################################################################### |
| 30 | |
| 31 | # Create demo in root window for testing. |
| 32 | if __name__ == '__main__': |
| 33 | root = Tkinter.Tk() |
| 34 | Pmw.initialise(root) |
| 35 | root.title(title) |
| 36 | |
| 37 | exitButton = Tkinter.Button(root, text = 'Exit', command = root.destroy) |
| 38 | exitButton.pack(side = 'bottom') |
| 39 | widget = Demo(root) |
| 40 | root.mainloop() |