summaryrefslogtreecommitdiffstats
path: root/Mac/Lib
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>1996-04-10 14:43:17 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>1996-04-10 14:43:17 (GMT)
commitfcdf4378acd50b94da0cf16187363f3bf5815d6a (patch)
tree7497d276d097b8e3cd4102a6c004e690e7b23b9e /Mac/Lib
parent0701d623e9d144c6aa050852b6c1bef4da2e9c5c (diff)
downloadcpython-fcdf4378acd50b94da0cf16187363f3bf5815d6a.zip
cpython-fcdf4378acd50b94da0cf16187363f3bf5815d6a.tar.gz
cpython-fcdf4378acd50b94da0cf16187363f3bf5815d6a.tar.bz2
TextEdit sample code (not yet complete)
Diffstat (limited to 'Mac/Lib')
-rw-r--r--Mac/Lib/test/tte.py17
-rw-r--r--Mac/Lib/test/ttedit.py85
2 files changed, 102 insertions, 0 deletions
diff --git a/Mac/Lib/test/tte.py b/Mac/Lib/test/tte.py
new file mode 100644
index 0000000..9e6bee4
--- /dev/null
+++ b/Mac/Lib/test/tte.py
@@ -0,0 +1,17 @@
+# Test TE module, simple version
+
+from Win import *
+from TE import *
+import Qd
+
+r = (40, 40, 140, 140)
+w = NewWindow(r, "TETextBox test", 1, 0, -1, 1, 0x55555555)
+##w.DrawGrowIcon()
+
+r = (10, 10, 90, 90)
+
+Qd.SetPort(w)
+t = TETextBox("Nobody expects the SPANISH inquisition", r, 1)
+
+import time
+time.sleep(10)
diff --git a/Mac/Lib/test/ttedit.py b/Mac/Lib/test/ttedit.py
new file mode 100644
index 0000000..59e250d
--- /dev/null
+++ b/Mac/Lib/test/ttedit.py
@@ -0,0 +1,85 @@
+# Test TE module.
+# Draw a window in which the user can type.
+#
+# This test expects Win, Evt and FrameWork (and anything used by those)
+# to work.
+#
+# Actually, it is more a test of FrameWork by now....
+
+from FrameWork import *
+import Win
+import Qd
+import TE
+import os
+
+class TEWindow(Window):
+ def open(self, name):
+ r = (40, 40, 400, 300)
+ w = Win.NewWindow(r, name, 1, 0, -1, 1, 0x55555555)
+ r2 = (0, 0, 345, 245)
+ Qd.SetPort(w)
+ self.ted = TE.TENew(r2, r2)
+ w.DrawGrowIcon()
+ self.wid = w
+ self.do_postopen()
+
+ def do_idle(self):
+ self.ted.TEIdle()
+
+ def do_activate(self, onoff, evt):
+ if onoff:
+ self.ted.TEActivate()
+ else:
+ self.ted.TEDeactivate()
+
+ def do_rawupdate(self, window, event):
+ window.BeginUpdate()
+ self.do_update(window, event)
+ window.EndUpdate()
+
+ def do_update(self, *args):
+ Qd.EraseRect(self.wid.GetWindowPort().portRect)
+ self.ted.TEUpdate(self.wid.GetWindowPort().portRect)
+
+ def do_contentclick(self, local, modifiers, evt):
+ shifted = (modifiers & 0x200)
+ self.ted.TEClick(local, shifted)
+
+ def do_char(self, ch, event):
+ self.ted.TEKey(ch)
+
+class TestList(Application):
+ def __init__(self):
+ Application.__init__(self)
+ self.num = 0
+ self.listoflists = []
+
+ def makeusermenus(self):
+ self.filemenu = m = Menu(self.menubar, "File")
+ self.newitem = MenuItem(m, "New window...", "O", self.open)
+ self.quititem = MenuItem(m, "Quit", "Q", self.quit)
+
+ def open(self, *args):
+ w = TEWindow(self)
+ w.open('Window %d'%self.num)
+ self.num = self.num + 1
+ self.listoflists.append(w)
+
+ def quit(self, *args):
+ raise self
+
+ def do_about(self, id, item, window, event):
+ EasyDialogs.Message("""Test the TextEdit interface.
+ Simple window in which you can type""")
+
+ def do_idle(self, *args):
+ for l in self.listoflists:
+ l.do_idle()
+
+def main():
+ App = TestList()
+ App.mainloop()
+
+if __name__ == '__main__':
+ main()
+