diff options
author | Just van Rossum <just@lettererror.com> | 1999-09-26 12:25:06 (GMT) |
---|---|---|
committer | Just van Rossum <just@lettererror.com> | 1999-09-26 12:25:06 (GMT) |
commit | a840fca15590f2369bb5381be86d13ce12563f73 (patch) | |
tree | 799bb9ec5ffb6efb132ffd8c8256eb8b8710818e | |
parent | b7ad821f022a62656677b03f1d081e1e284047ea (diff) | |
download | cpython-a840fca15590f2369bb5381be86d13ce12563f73.zip cpython-a840fca15590f2369bb5381be86d13ce12563f73.tar.gz cpython-a840fca15590f2369bb5381be86d13ce12563f73.tar.bz2 |
Initial checkin of IDE scripts. (jvr)
-rw-r--r-- | Mac/IDE scripts/ separator --- | 1 | ||||
-rw-r--r-- | Mac/IDE scripts/Hack/Debugger off | 4 | ||||
-rw-r--r-- | Mac/IDE scripts/Hack/Debugger on | 5 | ||||
-rw-r--r-- | Mac/IDE scripts/Hack/Remove .pyc files... | 22 | ||||
-rw-r--r-- | Mac/IDE scripts/Hack/Toolbox Assistant... | 45 | ||||
-rw-r--r-- | Mac/IDE scripts/Hold option to open a script... | 4 | ||||
-rw-r--r-- | Mac/IDE scripts/Insert file name... | 6 | ||||
-rw-r--r-- | Mac/IDE scripts/Insert folder name... | 6 | ||||
-rw-r--r-- | Mac/IDE scripts/Search Python Documentation... | 4 | ||||
-rw-r--r-- | Mac/IDE scripts/Widget demos/ActivateWindowDemo.py | 21 | ||||
-rw-r--r-- | Mac/IDE scripts/Widget demos/KeyTester.py | 34 | ||||
-rw-r--r-- | Mac/IDE scripts/Widget demos/ListWindow.py | 17 | ||||
-rw-r--r-- | Mac/IDE scripts/Widget demos/ModalDialog.py | 10 | ||||
-rw-r--r-- | Mac/IDE scripts/Widget demos/PaneDemo.py | 14 | ||||
-rw-r--r-- | Mac/IDE scripts/Widget demos/PaneDemo2.py | 16 | ||||
-rw-r--r-- | Mac/IDE scripts/Widget demos/ScrollbarWindow.py | 17 | ||||
-rw-r--r-- | Mac/IDE scripts/Widget demos/TwoLists.py | 22 | ||||
-rw-r--r-- | Mac/IDE scripts/Widget demos/WidgetTest.py | 85 | ||||
-rw-r--r-- | Mac/IDE scripts/separator --- | 1 |
19 files changed, 334 insertions, 0 deletions
diff --git a/Mac/IDE scripts/ separator --- b/Mac/IDE scripts/ separator --- new file mode 100644 index 0000000..74cd7fc --- /dev/null +++ b/Mac/IDE scripts/ separator --- @@ -0,0 +1 @@ +A separator ends with '---'
\ No newline at end of file diff --git a/Mac/IDE scripts/Hack/Debugger off b/Mac/IDE scripts/Hack/Debugger off new file mode 100644 index 0000000..ba68b49 --- /dev/null +++ b/Mac/IDE scripts/Hack/Debugger off @@ -0,0 +1,4 @@ +"""Turn the debugger off.""" + +import PyDebugger +PyDebugger.cont() diff --git a/Mac/IDE scripts/Hack/Debugger on b/Mac/IDE scripts/Hack/Debugger on new file mode 100644 index 0000000..63eee83 --- /dev/null +++ b/Mac/IDE scripts/Hack/Debugger on @@ -0,0 +1,5 @@ +"""This script turns the Python debugger on globally, meaning that +it will then stop at any breakpoint you might have defined.""" + +import PyDebugger +PyDebugger.startfrombottom() diff --git a/Mac/IDE scripts/Hack/Remove .pyc files... b/Mac/IDE scripts/Hack/Remove .pyc files... new file mode 100644 index 0000000..7d860a9 --- /dev/null +++ b/Mac/IDE scripts/Hack/Remove .pyc files... @@ -0,0 +1,22 @@ +import sys +import os +import macfs + +def walk(top): + names = os.listdir(top) + for name in names: + path = os.path.join(top, name) + if os.path.isdir(path): + walk(path) + else: + if path[-4:] in ['.pyc', '.pyo'] and os.path.exists(path[:-1]): + print "deleting:", path + os.remove(path) + elif path[-4:] == '.pyc': + print "!!! ------ .pyc file without .py file:", path + elif path[-4:] == '.pyo': + print "!!! ------ .pyo file without .py file:", path + +fss, ok = macfs.GetDirectory('Select the starting folder:') +if ok: + walk(fss.as_pathname()) diff --git a/Mac/IDE scripts/Hack/Toolbox Assistant... b/Mac/IDE scripts/Hack/Toolbox Assistant... new file mode 100644 index 0000000..afd7846 --- /dev/null +++ b/Mac/IDE scripts/Hack/Toolbox Assistant... @@ -0,0 +1,45 @@ +import aetools +import Standard_Suite +import Required_Suite +import MacOS +import W + + +class Toolbox(aetools.TalkTo, Standard_Suite.Standard_Suite): + + def LookupTopic(self, _object, _attributes={}, **_arguments): + _code = 'DanR' + _subcode = 'REF ' + + _arguments['----'] = _object + + _reply, _arguments, _attributes = self.send(_code, _subcode, + _arguments, _attributes) + if _arguments.has_key('errn'): + raise MacOS.Error, aetools.decodeerror(_arguments) + + +class ToolboxAssi: + + def __init__(self): + self.talker = None + self.w = W.Window((200, 100), "Toolbox Assistant") + self.w.button = W.Button((-94, -32, 80, 16), "Lookup", self.lookup) + self.w.prompt = W.TextBox((10, 8, -10, 15), "Enter topic:") + self.w.edit = W.EditText((10, 24, -10, 20)) + self.w.setdefaultbutton(self.w.button) + self.w.open() + + def lookup(self): + if self.talker is None: + try: + self.talker = Toolbox('ALTV', start = 1) + except: + raise W.AlertError, "Can¹t find ³Toolbox Assistant²" + lookup = self.w.edit.get() + try: + self.talker.LookupTopic(lookup) + except MacOS.Error, detail: + W.Message("Requested topic not found.\r(%d)" % detail[0]) + +t = ToolboxAssi() diff --git a/Mac/IDE scripts/Hold option to open a script... b/Mac/IDE scripts/Hold option to open a script... new file mode 100644 index 0000000..062c64c --- /dev/null +++ b/Mac/IDE scripts/Hold option to open a script... @@ -0,0 +1,4 @@ +"Hold the option key to open a script instead of running it." + +import W +W.Message(__doc__) diff --git a/Mac/IDE scripts/Insert file name... b/Mac/IDE scripts/Insert file name... new file mode 100644 index 0000000..7632f8e --- /dev/null +++ b/Mac/IDE scripts/Insert file name... @@ -0,0 +1,6 @@ +import macfs + +fss, ok = macfs.StandardGetFile() +if ok: + import W + W.FrontWindowInsert('"%s"' % fss.as_pathname()) diff --git a/Mac/IDE scripts/Insert folder name... b/Mac/IDE scripts/Insert folder name... new file mode 100644 index 0000000..1a9e06b --- /dev/null +++ b/Mac/IDE scripts/Insert folder name... @@ -0,0 +1,6 @@ +import macfs + +fss, ok = macfs.GetDirectory() +if ok: + import W + W.FrontWindowInsert('"%s"' % fss.as_pathname()) diff --git a/Mac/IDE scripts/Search Python Documentation... b/Mac/IDE scripts/Search Python Documentation... new file mode 100644 index 0000000..2156b95 --- /dev/null +++ b/Mac/IDE scripts/Search Python Documentation... @@ -0,0 +1,4 @@ +import PyDocSearch +# set the creator of the browser. 'MSIE' = Exploser, 'MOSS' = Netscape +PyDocSearch.SIGNATURE = 'MOSS' +pds = PyDocSearch.PyDocSearch() diff --git a/Mac/IDE scripts/Widget demos/ActivateWindowDemo.py b/Mac/IDE scripts/Widget demos/ActivateWindowDemo.py new file mode 100644 index 0000000..3cd832b --- /dev/null +++ b/Mac/IDE scripts/Widget demos/ActivateWindowDemo.py @@ -0,0 +1,21 @@ +import W + +# this demoscript illustrates how to tie a callback to activating or clicking away of the window. +# evb 22 4 99 + +class ActivateDemo: + + def __init__(self): + self.w = W.Window((200, 200), 'Activate demo') + self.w.bind("<activate>", self.my_activate_callback) + self.w.open() + + def my_activate_callback(self, onoff): + '''the callback gets 1 parameter which indicates whether the window + has been activated (1) or clicked to the back (0)''' + if onoff == 1: + print "I'm in the front now!" + else: + print "I've been clicked away, Oh No!" + +ad = ActivateDemo() diff --git a/Mac/IDE scripts/Widget demos/KeyTester.py b/Mac/IDE scripts/Widget demos/KeyTester.py new file mode 100644 index 0000000..ec66966 --- /dev/null +++ b/Mac/IDE scripts/Widget demos/KeyTester.py @@ -0,0 +1,34 @@ +"""Simple W demo -- shows how to make a window, and bind a function to a "key" event.""" + +import W + +# key callback function +def tester(char, event): + text = `char` + "\r" + `ord(char)` + "\r" + hex(ord(char)) + "\r" + oct(ord(char)) + window.keys.set(text) + +# close callback +def close(): + window.close() + +# new window +window = W.Dialog((180, 100), "Type a character") + +# make a frame (a simple rectangle) +window.frame = W.Frame((5, 5, -5, -33)) + +# some labels, static text +window.captions = W.TextBox((10, 9, 43, -36), "char:\rdecimal:\rhex:\roctal:") + +# another static text box +window.keys = W.TextBox((60, 9, 40, -36)) + +# a button +window.button = W.Button((-69, -24, 60, 16), "Done", close) + +# bind the callbacks +window.bind("<key>", tester) +window.bind("cmdw", window.button.push) + +# open the window +window.open() diff --git a/Mac/IDE scripts/Widget demos/ListWindow.py b/Mac/IDE scripts/Widget demos/ListWindow.py new file mode 100644 index 0000000..ef066b9 --- /dev/null +++ b/Mac/IDE scripts/Widget demos/ListWindow.py @@ -0,0 +1,17 @@ +import W + +def listhit(isdbl): + if isdbl: + print "double-click in list!" + else: + print "click in list." + +window = W.Window((200, 400), "Window with List", minsize = (150, 200)) + +window.list = W.List((-1, 20, 1, -14), [], listhit) + +# or (equivalent): +# window.list = W.List((-1, 20, 1, -14), callback = listhit) + +window.list.set(range(13213, 13350)) +window.open() diff --git a/Mac/IDE scripts/Widget demos/ModalDialog.py b/Mac/IDE scripts/Widget demos/ModalDialog.py new file mode 100644 index 0000000..683a76a --- /dev/null +++ b/Mac/IDE scripts/Widget demos/ModalDialog.py @@ -0,0 +1,10 @@ +import W +import Windows + + +w = W.ModalDialog((100, 100)) + +w.ed = W.EditText((10, 10, 80, 50)) +w.ok = W.Button((10, 70, 80, 16), "Ok", w.close) +w.setdefaultbutton(w.ok) +w.open() diff --git a/Mac/IDE scripts/Widget demos/PaneDemo.py b/Mac/IDE scripts/Widget demos/PaneDemo.py new file mode 100644 index 0000000..5d991b0 --- /dev/null +++ b/Mac/IDE scripts/Widget demos/PaneDemo.py @@ -0,0 +1,14 @@ +import W + +w = W.Window((600, 400), "Ha!", minsize = (240, 200)) + +w.panes = W.HorizontalPanes((8, 8, -30, -8), (0.3, 0.3, 0.4)) +w.panes.blah1 = W.EditText(None, "eehhh...") +w.panes.blah2 = W.EditText((8, 8, -8, -8), "xxx nou...") +w.panes.panes = W.VerticalPanes(None, (0.3, 0.4, 0.3)) +w.panes.panes.blah1 = W.EditText(None, "eehhh...") +w.panes.panes.blah2 = W.Frame(None) +w.panes.panes.blah2.t = W.EditText((0, 0, 0, 0), "nou...") +w.panes.panes.blah3 = W.List(None, ["eehhh...", 'abc', 'def']) + +w.open() diff --git a/Mac/IDE scripts/Widget demos/PaneDemo2.py b/Mac/IDE scripts/Widget demos/PaneDemo2.py new file mode 100644 index 0000000..7ed06de --- /dev/null +++ b/Mac/IDE scripts/Widget demos/PaneDemo2.py @@ -0,0 +1,16 @@ +import W + +w = W.Window((600, 400), "Ha!", minsize = (240, 200)) + +w.panes = W.HorizontalPanes((8, 8, -8, -20), (0.6, 0.4)) + +w.panes.panes = W.VerticalPanes(None, (0.3, 0.4, 0.3)) +w.panes.panes.blah1 = W.EditText(None, "eehhh...") +w.panes.panes.blah2 = W.EditText(None, "nou...") +w.panes.panes.blah3 = W.List(None, ["eehhh...", 'abc', 'def']) + +w.panes.group = W.Group(None) +w.panes.group.mytext = W.EditText((0, 24, 0, 0), "eehhh...") +w.panes.group.button1 = W.Button((0, 0, 80, 16), "A Button") + +w.open() diff --git a/Mac/IDE scripts/Widget demos/ScrollbarWindow.py b/Mac/IDE scripts/Widget demos/ScrollbarWindow.py new file mode 100644 index 0000000..5fc1b96 --- /dev/null +++ b/Mac/IDE scripts/Widget demos/ScrollbarWindow.py @@ -0,0 +1,17 @@ +import W + +# make a non-sizable window +#window = W.Window((200, 200), "Fixed Size") + +# make a sizable window +window = W.Window((200, 300), "Variable Size!", minsize = (200, 200)) + +# make some edit text widgets +# a scrollbar +window.hbar = W.Scrollbar((-1, -15, -14, 16), max = 100) +window.vbar = W.Scrollbar((-15, -1, 16, -14), max = 100) +#window.vbar = W.Scrollbar((-15, -1, 1, -14), max = 100) + + +# open the window +window.open() diff --git a/Mac/IDE scripts/Widget demos/TwoLists.py b/Mac/IDE scripts/Widget demos/TwoLists.py new file mode 100644 index 0000000..ee52c89 --- /dev/null +++ b/Mac/IDE scripts/Widget demos/TwoLists.py @@ -0,0 +1,22 @@ +import W + +def twothird(width, height): + return (8, 8, width - 8, 2*height/3 - 4) + +def onethird(width, height): + return (8, 2*height/3 + 4, width - 8, height - 22) + +def halfbounds1(width, height): + return (0, 0, width/2 - 4, height) + +def halfbounds2(width, height): + return (width/2 + 4, 0, width, height) + +window = W.Window((400, 400), "Sizable window with two lists", minsize = (200, 200)) + +window.listgroup = W.Group(twothird) +window.listgroup.list1 = W.List(halfbounds1, range(13213, 13310)) +window.listgroup.list2 = W.List(halfbounds2, range(800, 830)) +window.et = W.EditText(onethird, "Wat nu weer?") + +window.open() diff --git a/Mac/IDE scripts/Widget demos/WidgetTest.py b/Mac/IDE scripts/Widget demos/WidgetTest.py new file mode 100644 index 0000000..edef140 --- /dev/null +++ b/Mac/IDE scripts/Widget demos/WidgetTest.py @@ -0,0 +1,85 @@ +import W + +# define some callbacks +def callback(): + window.close() + +def checkcallback(value): + print "hit the checkbox", value + +def radiocallback(value): + print "hit radiobutton #3", value + +def scrollcallback(value): + widget = window.hbar + if value == "+": + widget.set(widget.get() - 1) + elif value == "-": + widget.set(widget.get() + 1) + elif value == "++": + widget.set(widget.get() - 10) + elif value == "--": + widget.set(widget.get() + 10) + else: # in thumb + widget.set(value) + print "scroll...", widget.get() + +def textcallback(): + window.et3.set(window.et1.get()) + +def cancel(): + import EasyDialogs + EasyDialogs.Message("Cancel!") + +# make a non-sizable window +#window = W.Window((200, 300), "Fixed Size") + +# make a sizable window +window = W.Window((200, 300), "Variable Size!", minsize = (200, 300)) + +# make some edit text widgets +window.et1 = W.EditText((10, 10, 110, 110), "Hallo!", textcallback) +window.et2 = W.EditText((130, 40, 60, 30), "one!") +window.et3 = W.EditText((130, 80, -10, 40), "two?") + +# a button +window.button = W.Button((-70, 10, 60, 16), "Close", callback) + +# a checkbox +window.ch = W.CheckBox((10, 130, 160, 16), "Check (command §)", checkcallback) + +# set of radio buttons (should become easier/nicer) +thebuttons = [] +window.r1 = W.RadioButton((10, 150, 180, 16), "Radio 1 (cmd 1)", thebuttons) +window.r2 = W.RadioButton((10, 170, 180, 16), "Radio 2 (cmd 2)", thebuttons) +window.r3 = W.RadioButton((10, 190, 180, 16), "Radio 3 (cmd 3)", thebuttons, radiocallback) +window.r1.set(1) + +# a normal button +window.cancelbutton = W.Button((10, 220, 60, 16), "Cancel", cancel) + +# a scrollbar +window.hbar = W.Scrollbar((-1, -15, -14, 16), scrollcallback, max = 100) + +# some static text +window.static = W.TextBox((10, 260, 110, 16), "Schtatic") + +# bind some keystrokes to functions +window.bind('cmd§', window.ch.push) +window.bind('cmd1', window.r1.push) +window.bind('cmd2', window.r2.push) +window.bind('cmd3', window.r3.push) +window.bind('cmdw', window.button.push) +window.bind('cmd.', window.cancelbutton.push) + +window.setdefaultbutton(window.button) +# open the window +window.open() + +if 0: + import time + for i in range(20): + window.et2.set(`i`) + #window.et2.SetPort() + #window.et2.draw() + time.sleep(0.1) diff --git a/Mac/IDE scripts/separator --- b/Mac/IDE scripts/separator --- new file mode 100644 index 0000000..74cd7fc --- /dev/null +++ b/Mac/IDE scripts/separator --- @@ -0,0 +1 @@ +A separator ends with '---'
\ No newline at end of file |