Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | title = 'Blt busy cursor 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 | self.parent = parent | |
13 | ||
14 | if Pmw.Blt.havebltbusy(parent): | |
15 | text = 'Click here to show the\nbusy cursor for one second.' | |
16 | else: | |
17 | text = 'Sorry\n' \ | |
18 | 'Either the BLT package has not\n' \ | |
19 | 'been installed on this system or\n' \ | |
20 | 'it does not support the busy command.\n' \ | |
21 | 'Clicking on this button will pause\n' \ | |
22 | 'for one second but will not display\n' \ | |
23 | 'the busy cursor.' | |
24 | ||
25 | button = Tkinter.Button(parent, | |
26 | text = text, | |
27 | command = Pmw.busycallback(self.sleep, parent.update)) | |
28 | button.pack(padx = 10, pady = 10) | |
29 | ||
30 | entry = Tkinter.Entry(parent, width = 30) | |
31 | entry.insert('end', 'Try to enter some text while busy.') | |
32 | entry.pack(padx = 10, pady = 10) | |
33 | ||
34 | def sleep(self): | |
35 | self.parent.after(1000) | |
36 | ||
37 | ###################################################################### | |
38 | ||
39 | # Create demo in root window for testing. | |
40 | if __name__ == '__main__': | |
41 | root = Tkinter.Tk() | |
42 | Pmw.initialise(root) | |
43 | root.title(title) | |
44 | ||
45 | exitButton = Tkinter.Button(root, text = 'Exit', command = root.destroy) | |
46 | exitButton.pack(side = 'bottom') | |
47 | widget = Demo(root) | |
48 | root.mainloop() |