py-cvs-rel2_1 (Rev 1.2) merge
[python/dscho.git] / Mac / Lib / test / tdlg_modeless.py
blob2b6a0f786132a321f57f3f45f9a9959909401a91
1 # Function to display a message and wait for the user to hit OK.
2 # This uses a DLOG resource with ID=256 which is part of the standard
3 # Python library.
4 # The ID can be overridden by passing a second parameter.
5 # This is the modeless version of this test program, the normal
6 # modal version is in tdlg.py
8 from Dlg import *
9 from Evt import *
10 from Events import *
11 import MacOS
12 import string
14 ID = 256
16 def message(str = "Hello, modeless world!", id = ID):
17 print 'This is to init the console window...'
18 d = GetNewDialog(id, -1)
19 tp, h, rect = d.GetDialogItem(2)
20 SetDialogItemText(h, str)
21 while 1:
22 ok, ev = WaitNextEvent(0xffff, 10)
23 if not ok:
24 continue
25 if IsDialogEvent(ev):
26 ok, window, item = DialogSelect(ev)
27 if ok:
28 if window == d:
29 if item == 1:
30 break
31 else:
32 print 'Unexpected item hit'
33 else:
34 print 'Unexpected dialog hit'
35 else:
36 MacOS.HandleEvent(ev)
38 def test():
39 message()
41 if __name__ == '__main__':
42 test()