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 *
17 class ListWindow(Window
):
18 def open(self
, name
, where
):
20 r
= (40, 40, 400, 300)
21 w
= Win
.NewWindow(r
, name
, 1, 0, -1, 1, 0x55555555)
25 self
.list = List
.LNew(r2
, (0, 0, 1, 1), (0,0), 0, w
, 0, 1, 1, 1)
26 self
.list.selFlags
= Lists
.lOnlyOne
31 def do_activate(self
, onoff
, evt
):
32 self
.list.LActivate(onoff
)
34 def do_update(self
, *args
):
35 self
.list.LUpdate(self
.wid
.GetWindowPort().visRgn
)
37 def do_contentclick(self
, local
, modifiers
, evt
):
38 dclick
= self
.list.LClick(local
, modifiers
)
40 h
, v
= self
.list.LLastClick()
41 file = self
.list.LGetCell(1000, (h
, v
))
42 self
.where
= os
.path
.join(self
.where
, file)
46 """Fill the list with the contents of the current directory"""
50 contents
= os
.listdir(self
.where
)
51 l
.LAddRow(len(contents
), 0)
52 for i
in range(len(contents
)):
53 l
.LSetCell(contents
[i
], (0, i
))
55 l
.LUpdate(self
.wid
.GetWindowPort().visRgn
)
58 class TestList(Application
):
60 Application
.__init
__(self
)
64 def makeusermenus(self
):
65 self
.filemenu
= m
= Menu(self
.menubar
, "File")
66 self
.newitem
= MenuItem(m
, "New window...", "O", self
.open)
67 self
.quititem
= MenuItem(m
, "Quit", "Q", self
.quit
)
69 def open(self
, *args
):
71 fss
, ok
= macfs
.GetDirectory()
75 w
.open('Window %d'%self
.num
, fss
.as_pathname())
76 self
.num
= self
.num
+ 1
77 self
.listoflists
.append(w
)
79 def quit(self
, *args
):
82 def do_about(self
, id, item
, window
, event
):
83 EasyDialogs
.Message("""Test the List Manager interface.
84 Simple inward-only folder browser""")
90 if __name__
== '__main__':