Improved some error messages for command line processing.
[python/dscho.git] / Mac / Lib / test / tscrollwin.py
blob40e9d67b646821b68ce0e1f6748a2536272932ea
1 # Test FrameWork scrollbars
2 # Draw a window in which the user can type.
4 # This test expects Win, Evt and FrameWork (and anything used by those)
5 # to work.
7 # Actually, it is more a test of FrameWork by now....
9 from FrameWork import *
10 import Win
11 import Qd
12 import TE
13 import os
15 class MyWindow(ScrolledWindow):
16 def open(self, name):
17 r = (40, 40, 400, 300)
18 w = Win.NewWindow(r, name, 1, 0, -1, 1, 0x55555555)
19 self.ourrect = 0, 0, 360-SCROLLBARWIDTH-1, 260-SCROLLBARWIDTH-1
20 Qd.SetPort(w)
21 w.DrawGrowIcon()
22 self.wid = w
23 self.do_postopen()
24 self.vx = self.vy = 0
25 self.scrollbars()
27 def getscrollbarvalues(self):
28 return self.vx, self.vy
30 def scrollbar_callback(self, which, what, value):
31 if what == '-':
32 delta = -1
33 elif what == '--':
34 delta = -100
35 elif what == '+':
36 delta = 1
37 elif what == '++':
38 delta = 100
40 if which == 'x':
41 if value:
42 self.vx = value
43 else:
44 self.vx = self.vx + delta
45 else:
46 if value:
47 self.vy = value
48 else:
49 self.vy = self.vy + delta
50 Win.InvalRect(self.ourrect)
52 def do_update(self, wid, event):
53 Qd.EraseRect(self.ourrect)
54 Qd.MoveTo(40, 40)
55 Qd.DrawString("x=%d, y=%d"%(self.vx, self.vy))
57 class TestSW(Application):
58 def __init__(self):
59 Application.__init__(self)
60 self.num = 0
61 self.listoflists = []
63 def makeusermenus(self):
64 self.filemenu = m = Menu(self.menubar, "File")
65 self.newitem = MenuItem(m, "New window...", "O", self.open)
66 self.quititem = MenuItem(m, "Quit", "Q", self.quit)
68 def open(self, *args):
69 w = MyWindow(self)
70 w.open('Window %d'%self.num)
71 self.num = self.num + 1
72 self.listoflists.append(w)
74 def quit(self, *args):
75 raise self
77 def do_about(self, id, item, window, event):
78 EasyDialogs.Message("""Test scrolling FrameWork windows""")
80 def main():
81 App = TestSW()
82 App.mainloop()
84 if __name__ == '__main__':
85 main()