blob: f88b0599630151089b1166b47b8007e974474cfb [file] [log] [blame]
Just van Rossuma840fca1999-09-26 12:25:06 +00001import W
2
3# define some callbacks
4def callback():
5 window.close()
6
7def checkcallback(value):
8 print "hit the checkbox", value
9
10def radiocallback(value):
11 print "hit radiobutton #3", value
12
13def scrollcallback(value):
14 widget = window.hbar
15 if value == "+":
16 widget.set(widget.get() - 1)
17 elif value == "-":
18 widget.set(widget.get() + 1)
19 elif value == "++":
20 widget.set(widget.get() - 10)
21 elif value == "--":
22 widget.set(widget.get() + 10)
23 else: # in thumb
24 widget.set(value)
25 print "scroll...", widget.get()
26
27def textcallback():
28 window.et3.set(window.et1.get())
29
30def cancel():
31 import EasyDialogs
32 EasyDialogs.Message("Cancel!")
33
34# make a non-sizable window
35#window = W.Window((200, 300), "Fixed Size")
36
37# make a sizable window
38window = W.Window((200, 300), "Variable Size!", minsize = (200, 300))
39
40# make some edit text widgets
41window.et1 = W.EditText((10, 10, 110, 110), "Hallo!", textcallback)
42window.et2 = W.EditText((130, 40, 60, 30), "one!")
43window.et3 = W.EditText((130, 80, -10, 40), "two?")
44
45# a button
46window.button = W.Button((-70, 10, 60, 16), "Close", callback)
47
48# a checkbox
Just van Rossumfb3e54f2001-06-19 21:38:42 +000049window.ch = W.CheckBox((10, 130, 160, 16), "Check (command \xa4)", checkcallback)
Just van Rossuma840fca1999-09-26 12:25:06 +000050
51# set of radio buttons (should become easier/nicer)
52thebuttons = []
53window.r1 = W.RadioButton((10, 150, 180, 16), "Radio 1 (cmd 1)", thebuttons)
54window.r2 = W.RadioButton((10, 170, 180, 16), "Radio 2 (cmd 2)", thebuttons)
55window.r3 = W.RadioButton((10, 190, 180, 16), "Radio 3 (cmd 3)", thebuttons, radiocallback)
56window.r1.set(1)
57
58# a normal button
59window.cancelbutton = W.Button((10, 220, 60, 16), "Cancel", cancel)
60
61# a scrollbar
62window.hbar = W.Scrollbar((-1, -15, -14, 16), scrollcallback, max = 100)
63
64# some static text
65window.static = W.TextBox((10, 260, 110, 16), "Schtatic")
66
67# bind some keystrokes to functions
Just van Rossumfb3e54f2001-06-19 21:38:42 +000068window.bind('cmd\xa4', window.ch.push)
Just van Rossuma840fca1999-09-26 12:25:06 +000069window.bind('cmd1', window.r1.push)
70window.bind('cmd2', window.r2.push)
71window.bind('cmd3', window.r3.push)
72window.bind('cmdw', window.button.push)
73window.bind('cmd.', window.cancelbutton.push)
74
75window.setdefaultbutton(window.button)
76# open the window
77window.open()
78
79if 0:
80 import time
81 for i in range(20):
82 window.et2.set(`i`)
83 #window.et2.SetPort()
84 #window.et2.draw()
85 time.sleep(0.1)