13 print 'This is to create a window'
17 d
= GetNewDialog(ID
, -1)
19 # Create the list and fill it
21 tp
, h
, rect
= d
.GetDialogItem(2)
22 rect
= rect
[0], rect
[1], rect
[2]-15, rect
[3]-15 # Space for scrollbars
23 length
= (len(items
)+1) / 2
24 list = LNew(rect
, (0, 0, 2, length
), (0, 0), 0, d
, 0, 1, 1, 1)
25 for i
in range(len(items
)):
26 list.LSetCell(items
[i
], (i
%2, i
/2))
30 list.LSetDrawingMode(1)
31 list.LUpdate(self
.wid
.GetWindowPort().visRgn
)
33 # Do the (modeless) dialog
36 ok
, ev
= WaitNextEvent(0xffff, 10)
40 (what
, message
, when
, where
, modifiers
) = ev
42 # XXXX We just always update our list (sigh...)
44 list.LUpdate(self
.wid
.GetWindowPort().visRgn
)
46 # It is a dialog event. See if it's ours.
47 ok
, window
, item
= DialogSelect(ev
)
51 if item
== 1: # OK button
53 elif item
== 2: # List
54 (what
, message
, when
, where
, modifiers
) = ev
57 local
= GlobalToLocal(where
)
58 list.LClick(local
, modifiers
)
60 print 'Unexpected item hit'
62 print 'Unexpected dialog hit'
66 for i
in range(len(items
)):
67 ok
, dummycell
= list.LGetSelect(0, (i
%2, i
/2))
69 sel
.append(list.LGetCell(256, (i
%2, i
/2)))
70 print 'Your selection:', sel
74 Res
.FSpOpenResFile('tlist_dialog.rsrc', 1)
75 dodialog(os
.listdir(':'))
78 if __name__
== '__main__':