2 addpack
.addpack(':Tools:bgen:evt')
16 print 'This is to create a window'
20 d
= GetNewDialog(ID
, -1)
22 # Create the list and fill it
24 tp
, h
, rect
= d
.GetDialogItem(2)
25 rect
= rect
[0], rect
[1], rect
[2]-15, rect
[3]-15 # Space for scrollbars
26 length
= (len(items
)+1) / 2
27 list = LNew(rect
, (0, 0, 2, length
), (0, 0), 0, d
, 0, 1, 1, 1)
28 for i
in range(len(items
)):
29 list.LSetCell(items
[i
], (i
%2, i
/2))
33 list.LSetDrawingMode(1)
36 # Do the (modeless) dialog
39 ok
, ev
= WaitNextEvent(0xffff, 10)
43 (what
, message
, when
, where
, modifiers
) = ev
45 # XXXX We just always update our list (sigh...)
49 # It is a dialog event. See if it's ours.
50 ok
, window
, item
= DialogSelect(ev
)
54 if item
== 1: # OK button
56 elif item
== 2: # List
57 (what
, message
, when
, where
, modifiers
) = ev
60 local
= GlobalToLocal(where
)
61 list.LClick(local
, modifiers
)
63 print 'Unexpected item hit'
65 print 'Unexpected dialog hit'
69 for i
in range(len(items
)):
70 ok
, dummycell
= list.LGetSelect(0, (i
%2, i
/2))
72 sel
.append(list.LGetCell(256, (i
%2, i
/2)))
73 print 'Your selection:', sel
77 Res
.OpenResFile('tlist_dialog.rsrc')
78 dodialog(os
.listdir(':'))
81 if __name__
== '__main__':