Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b4e4783

Browse files
committed
Uses new FrameWork, has multiple windows
1 parent 8ce4d51 commit b4e4783

1 file changed

Lines changed: 46 additions & 31 deletions

File tree

Mac/Lib/test/tlist.py

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,72 +4,87 @@
44
#
55
# This test expects Win, Evt and FrameWork (and anything used by those)
66
# to work.
7+
#
8+
# Actually, it is more a test of FrameWork by now....
79

810
from FrameWork import *
911
import Win
1012
import Qd
1113
import List
1214
import os
1315

14-
class TestList(Application):
15-
def __init__(self):
16-
os.chdir('Moes:')
17-
self.makemenubar()
18-
self.makewindow()
19-
20-
def makewindow(self):
16+
class ListWindow(Window):
17+
def open(self, name, where):
18+
self.where = where
2119
r = (40, 40, 400, 300)
22-
w = Win.NewWindow(r, "List test", 1, 0, -1, 1, 0x55555555)
20+
w = Win.NewWindow(r, name, 1, 0, -1, 1, 0x55555555)
2321
r2 = (0, 0, 345, 245)
2422
self.list = List.LNew(r2, (0, 0, 1, 1), (0,0), 0, w, 0, 1, 1, 1)
2523
self.filllist()
2624
w.DrawGrowIcon()
27-
self.win = w
25+
self.wid = w
26+
self.do_postopen()
2827

29-
def makeusermenus(self):
30-
self.filemenu = m = Menu(self.menubar, "File")
31-
self.quititem = MenuItem(m, "Quit", "Q", self.quit)
32-
33-
def quit(self, *args):
34-
raise self
28+
def do_activate(self, onoff, evt):
29+
self.list.LActivate(onoff)
3530

36-
def do_about(self, id, item, window, event):
37-
EasyDialogs.Message("""Test the List Manager interface.
38-
Double-click on a folder to change directory""")
39-
40-
def do_activateEvt(self, *args):
41-
self.list.LActivate(1) # XXXX Wrong...
31+
def do_rawupdate(self, window, event):
32+
window.BeginUpdate()
33+
self.do_update(window, event)
34+
window.EndUpdate()
4235

4336
def do_update(self, *args):
44-
print 'LUPDATE'
4537
self.list.LUpdate()
46-
47-
def do_inContent(self, partcode, window, event):
48-
(what, message, when, where, modifiers) = event
49-
Qd.SetPort(window)
50-
local = Qd.GlobalToLocal(where)
51-
print 'CLICK', where, '->', local
38+
39+
def do_contentclick(self, local, modifiers, evt):
5240
dclick = self.list.LClick(local, modifiers)
5341
if dclick:
5442
h, v = self.list.LLastClick()
5543
file = self.list.LGetCell(1000, (h, v))
56-
os.chdir(file)
44+
self.where = os.path.join(self.where, file)
5745
self.filllist()
5846

5947
def filllist(self):
6048
"""Fill the list with the contents of the current directory"""
6149
l = self.list
6250
l.LSetDrawingMode(0)
6351
l.LDelRow(0, 0)
64-
contents = os.listdir(':')
65-
print contents
52+
contents = os.listdir(self.where)
6653
l.LAddRow(len(contents), 0)
6754
for i in range(len(contents)):
6855
l.LSetCell(contents[i], (0, i))
6956
l.LSetDrawingMode(1)
7057
l.LUpdate()
7158

7259

60+
class TestList(Application):
61+
def __init__(self):
62+
Application.__init__(self)
63+
self.num = 0
64+
self.listoflists = []
65+
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)
70+
71+
def open(self, *args):
72+
import macfs
73+
fss, ok = macfs.GetDirectory()
74+
if not ok:
75+
return
76+
w = ListWindow(self)
77+
w.open('Window %d'%self.num, fss.as_pathname())
78+
self.num = self.num + 1
79+
self.listoflists.append(w)
80+
81+
def quit(self, *args):
82+
raise self
83+
84+
def do_about(self, id, item, window, event):
85+
EasyDialogs.Message("""Test the List Manager interface.
86+
Simple inward-only folder browser""")
87+
7388
def main():
7489
App = TestList()
7590
App.mainloop()

0 commit comments

Comments
 (0)