2 # Draw a window with all the files in the current folder.
3 # double-clicking will change folder.
5 # This test expects Win, Evt and FrameWork (and anything used by those)
8 # Actually, it is more a test of FrameWork by now....
10 from FrameWork
import *
16 class ListWindow(Window
):
17 def open(self
, name
, where
):
19 r
= (40, 40, 400, 300)
20 w
= Win
.NewWindow(r
, name
, 1, 0, -1, 1, 0x55555555)
22 self
.list = List
.LNew(r2
, (0, 0, 1, 1), (0,0), 0, w
, 0, 1, 1, 1)
28 def do_activate(self
, onoff
, evt
):
29 self
.list.LActivate(onoff
)
31 def do_rawupdate(self
, window
, event
):
33 self
.do_update(window
, event
)
36 def do_update(self
, *args
):
39 def do_contentclick(self
, local
, modifiers
, evt
):
40 dclick
= self
.list.LClick(local
, modifiers
)
42 h
, v
= self
.list.LLastClick()
43 file = self
.list.LGetCell(1000, (h
, v
))
44 self
.where
= os
.path
.join(self
.where
, file)
48 """Fill the list with the contents of the current directory"""
52 contents
= os
.listdir(self
.where
)
53 l
.LAddRow(len(contents
), 0)
54 for i
in range(len(contents
)):
55 l
.LSetCell(contents
[i
], (0, i
))
60 class TestList(Application
):
62 Application
.__init
__(self
)
66 def makeusermenus(self
):
67 self
.filemenu
= m
= Menu(self
.menubar
, "File")
68 self
.newitem
= MenuItem(m
, "New window...", "O", self
.open)
69 self
.quititem
= MenuItem(m
, "Quit", "Q", self
.quit
)
71 def open(self
, *args
):
73 fss
, ok
= macfs
.GetDirectory()
77 w
.open('Window %d'%self
.num
, fss
.as_pathname())
78 self
.num
= self
.num
+ 1
79 self
.listoflists
.append(w
)
81 def quit(self
, *args
):
84 def do_about(self
, id, item
, window
, event
):
85 EasyDialogs
.Message("""Test the List Manager interface.
86 Simple inward-only folder browser""")
92 if __name__
== '__main__':