mirror of
https://github.com/python/cpython.git
synced 2025-09-13 04:08:37 +00:00
Initial checkin of IDE scripts. (jvr)
This commit is contained in:
parent
b7ad821f02
commit
a840fca155
19 changed files with 334 additions and 0 deletions
1
Mac/IDE scripts/ separator ---
Normal file
1
Mac/IDE scripts/ separator ---
Normal file
|
@ -0,0 +1 @@
|
||||||
|
A separator ends with '---'
|
4
Mac/IDE scripts/Hack/Debugger off
Normal file
4
Mac/IDE scripts/Hack/Debugger off
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
"""Turn the debugger off."""
|
||||||
|
|
||||||
|
import PyDebugger
|
||||||
|
PyDebugger.cont()
|
5
Mac/IDE scripts/Hack/Debugger on
Normal file
5
Mac/IDE scripts/Hack/Debugger on
Normal file
|
@ -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()
|
22
Mac/IDE scripts/Hack/Remove .pyc files...
Normal file
22
Mac/IDE scripts/Hack/Remove .pyc files...
Normal file
|
@ -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())
|
45
Mac/IDE scripts/Hack/Toolbox Assistant...
Normal file
45
Mac/IDE scripts/Hack/Toolbox Assistant...
Normal file
|
@ -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()
|
4
Mac/IDE scripts/Hold option to open a script...
Normal file
4
Mac/IDE scripts/Hold option to open a script...
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
"Hold the option key to open a script instead of running it."
|
||||||
|
|
||||||
|
import W
|
||||||
|
W.Message(__doc__)
|
6
Mac/IDE scripts/Insert file name...
Normal file
6
Mac/IDE scripts/Insert file name...
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
import macfs
|
||||||
|
|
||||||
|
fss, ok = macfs.StandardGetFile()
|
||||||
|
if ok:
|
||||||
|
import W
|
||||||
|
W.FrontWindowInsert('"%s"' % fss.as_pathname())
|
6
Mac/IDE scripts/Insert folder name...
Normal file
6
Mac/IDE scripts/Insert folder name...
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
import macfs
|
||||||
|
|
||||||
|
fss, ok = macfs.GetDirectory()
|
||||||
|
if ok:
|
||||||
|
import W
|
||||||
|
W.FrontWindowInsert('"%s"' % fss.as_pathname())
|
4
Mac/IDE scripts/Search Python Documentation...
Normal file
4
Mac/IDE scripts/Search Python Documentation...
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
import PyDocSearch
|
||||||
|
# set the creator of the browser. 'MSIE' = Exploser, 'MOSS' = Netscape
|
||||||
|
PyDocSearch.SIGNATURE = 'MOSS'
|
||||||
|
pds = PyDocSearch.PyDocSearch()
|
21
Mac/IDE scripts/Widget demos/ActivateWindowDemo.py
Normal file
21
Mac/IDE scripts/Widget demos/ActivateWindowDemo.py
Normal file
|
@ -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()
|
34
Mac/IDE scripts/Widget demos/KeyTester.py
Normal file
34
Mac/IDE scripts/Widget demos/KeyTester.py
Normal file
|
@ -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()
|
17
Mac/IDE scripts/Widget demos/ListWindow.py
Normal file
17
Mac/IDE scripts/Widget demos/ListWindow.py
Normal file
|
@ -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()
|
10
Mac/IDE scripts/Widget demos/ModalDialog.py
Normal file
10
Mac/IDE scripts/Widget demos/ModalDialog.py
Normal file
|
@ -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()
|
14
Mac/IDE scripts/Widget demos/PaneDemo.py
Normal file
14
Mac/IDE scripts/Widget demos/PaneDemo.py
Normal file
|
@ -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()
|
16
Mac/IDE scripts/Widget demos/PaneDemo2.py
Normal file
16
Mac/IDE scripts/Widget demos/PaneDemo2.py
Normal file
|
@ -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()
|
17
Mac/IDE scripts/Widget demos/ScrollbarWindow.py
Normal file
17
Mac/IDE scripts/Widget demos/ScrollbarWindow.py
Normal file
|
@ -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()
|
22
Mac/IDE scripts/Widget demos/TwoLists.py
Normal file
22
Mac/IDE scripts/Widget demos/TwoLists.py
Normal file
|
@ -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()
|
85
Mac/IDE scripts/Widget demos/WidgetTest.py
Normal file
85
Mac/IDE scripts/Widget demos/WidgetTest.py
Normal file
|
@ -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)
|
1
Mac/IDE scripts/separator ---
Normal file
1
Mac/IDE scripts/separator ---
Normal file
|
@ -0,0 +1 @@
|
||||||
|
A separator ends with '---'
|
Loading…
Add table
Add a link
Reference in a new issue