Remove VIRTUAL_DESKTOP code
[wmaker-crm.git] / WINGs / python / test.py
blobde98188c05a45498394ad49f24a1195489ed5052
1 #!/usr/bin/env python
3 import sys
4 from WINGs import *
6 if __name__ == "__main__":
7 def quit(obj, data):
8 #sys.exit()
9 scr.breakMainLoop()
11 def click(btn, list):
12 print win.width(), win.height()
13 print list.selectedItemRow()
14 win2.show()
15 scr.runModalLoop(win2.view())
16 print txt2.text()
18 def sayhi(btn, data):
19 print "hi"
21 def breakLoop(btn, data):
22 #sys.exit()
23 scr.breakModalLoop()
24 win2.hide()
26 def dc(object, data, action):
27 print "didChange:", object, data, action
29 def dbe(object, data, action):
30 print "didBeginEditing:", object, data, action
32 def dee(object, data, action):
33 if action == wings.WMReturnTextMovement:
34 if object == txt:
35 object.setFocusTo(txt2)
36 else:
37 object.setFocusTo(txt)
38 print "didEndEditing:", object, data, action, object.text()
40 def tcb(one):
41 old = list.selectedItemRow()
42 list.selectItem(list.index)
43 list.unselectItem(old)
44 list.index = (list.index+1) % 3
45 #print one
47 scr = WMScreen("foobar")
48 win = WMWindow(scr, "aWindow")
49 win.setCloseAction(quit)
50 win.setTitle("test window")
51 win.resize(400, 180)
52 win.setInitialPosition((scr.width-win.width())/2, (scr.height-win.height())/2)
54 btn = WMCommandButton(win)
55 btn.setText("Click Me")
56 btn.resize(100, 25)
57 btn.move(20, 20)
58 btn.show()
60 sw = WMSwitchButton(win)
61 sw.setText("Some option")
62 sw.resize(100, 25)
63 sw.move(20, 50)
64 sw.show()
66 radios = []
67 r = None
68 j = 0
69 for i in ["One", "Two", "Four"]:
70 r = WMRadioButton(win, r)
71 radios.append(r)
72 r.show()
73 r.setText(i)
74 r.move(20, 70+j*25)
75 r.resize(100, 25)
76 j=j+1
78 sw.setAction(sayhi)
80 list = WMList(win)
81 list.resize(100,100)
82 list.move(130, 20)
83 list.addItem("one")
84 list.addItem("two")
85 list.addItem("three")
86 list.allowMultipleSelection(1)
87 list.show()
88 list.index = 0
90 txtdel = WMTextFieldDelegate()
91 txtdel.data = 'mydata'
92 txtdel.didBeginEditing = dbe
93 txtdel.didEndEditing = dee
94 txtdel.didChange = dc
96 txt = WMTextField(win)
97 txt.resize(95, 20)
98 txt.move(295, 20)
99 txt.setDelegate(txtdel)
100 txt.show()
101 txt2 = WMTextField(win, "01234567890")
102 txt2.resize(95, 20)
103 txt2.move(295, 45)
104 txt2.setDelegate(txtdel)
105 txt2.show()
107 txt.setNextText(txt2)
108 txt2.setNextText(txt)
110 label = WMLabel(win, "Text1:")
111 label.setTextAlignment(WARight)
112 label.move(240, 20)
113 label.resize(55, 20)
114 label.show()
116 label2 = WMLabel(win, "mytext2:")
117 label2.setTextAlignment(WARight)
118 label2.move(240, 45)
119 label2.resize(55, 20)
120 label2.show()
122 btn.setAction(click, list)
124 frame = WMFrame(win, "My Frame")
125 frame.resize(150, 50)
126 frame.move(240, 70)
127 #frame.setRelief(WRPushed)
128 frame.show()
130 ebtn = WMCommandButton(win)
131 ebtn.setText("Exit")
132 ebtn.resize(100, 25)
133 ebtn.move(290, 147)
134 ebtn.setAction(quit)
135 ebtn.show()
137 win.realize()
138 win.show()
140 timer = WMPersistentTimer(1000, tcb, win)
141 #del(timer)
142 #timer.delete()
144 win2 = WMPanel(win, "anotherWindow", WMTitledWindowMask)
145 win2.setTitle("transient test window")
146 win2.resize(150, 50)
147 win2.setInitialPosition((scr.width-win2.width())/2, (scr.height-win2.height())/2)
149 btn7 = WMCommandButton(win2)
150 btn7.setText("Dismiss")
151 btn7.resize(100, 25)
152 btn7.move(27, 10)
153 btn7.show()
154 btn7.setAction(breakLoop)
156 win2.realize()
158 scr.mainLoop()