Kaydet (Commit) a3c253e8 authored tarafından Guido van Rossum's avatar Guido van Rossum

Removing new files accidentally checked in on the trunk rather than on the

idlefork-merge-branch.
üst 767d9fed
IDLEfork Credits
==================
Guido van Rossum, as well as being the creator of the Python language, is
the original creator of IDLE. He also developed the RPC code and Remote
Debugger extension used in IDLEfork.
The IDLEfork project was initiated and brought up to version 0.7.1 primarily
by David Scherer, with help from Peter Schneider-Kamp and Nicholas Riley.
Bruce Sherwood has contributed considerable time testing and suggesting
improvements.
Besides Guido, the main developers who have been active on IDLEfork version
0.8.1 and later are Stephen M. Gava, who implemented the Configuration GUI, the
new configuration system, and the new About menu, and Kurt B. Kaiser, who
completed the integration of the RPC and remote debugger, and made a number of
usability enhancements.
Other contributors include Raymond Hettinger, Tony Lownds (Mac integration),
Neal Norwitz (code check and clean-up), and Chui Tey (RPC integration, debugger
integration and persistent breakpoints).
Hernan Foffani, Christos Georgiou, Jason Orendorff, Josh Robb, and Bruce
Sherwood have submitted useful patches. Thanks, guys!
There are others who should be included here, especially those who contributed
to IDLE versions prior to 0.8, principally Mark Hammond, Jeremy Hylton,
Tim Peters, and Moshe Zadka. For additional details refer to NEWS.txt and
Changelog.
Please contact the IDLEfork maintainer to have yourself included here if you
are one of those we missed!
Contact details at http://idlefork.sourceforge.net
IDLE History
============
This file contains the release messages for previous IDLE releases.
As you read on you go back to the dark ages of IDLE's history.
IDLE 0.5 - February 2000 - Release Notes
----------------------------------------
This is an early release of IDLE, my own attempt at a Tkinter-based
IDE for Python.
(For a more detailed change log, see the file ChangeLog.)
FEATURES
IDLE has the following features:
- coded in 100% pure Python, using the Tkinter GUI toolkit (i.e. Tcl/Tk)
- cross-platform: works on Windows and Unix (on the Mac, there are
currently problems with Tcl/Tk)
- multi-window text editor with multiple undo, Python colorizing
and many other features, e.g. smart indent and call tips
- Python shell window (a.k.a. interactive interpreter)
- debugger (not complete, but you can set breakpoints, view and step)
USAGE
The main program is in the file "idle.py"; on Unix, you should be able
to run it by typing "./idle.py" to your shell. On Windows, you can
run it by double-clicking it; you can use idle.pyw to avoid popping up
a DOS console. If you want to pass command line arguments on Windows,
use the batch file idle.bat.
Command line arguments: files passed on the command line are executed,
not opened for editing, unless you give the -e command line option.
Try "./idle.py -h" to see other command line options.
IDLE requires Python 1.5.2, so it is currently only usable with a
Python 1.5.2 distribution. (An older version of IDLE is distributed
with Python 1.5.2; you can drop this version on top of it.)
COPYRIGHT
IDLE is covered by the standard Python copyright notice
(http://www.python.org/doc/Copyright.html).
New in IDLE 0.5 (2/15/2000)
---------------------------
Tons of stuff, much of it contributed by Tim Peters and Mark Hammond:
- Status bar, displaying current line/column (Moshe Zadka).
- Better stack viewer, using tree widget. (XXX Only used by Stack
Viewer menu, not by the debugger.)
- Format paragraph now recognizes Python block comments and reformats
them correctly (MH)
- New version of pyclbr.py parses top-level functions and understands
much more of Python's syntax; this is reflected in the class and path
browsers (TP)
- Much better auto-indent; knows how to indent the insides of
multi-line statements (TP)
- Call tip window pops up when you type the name of a known function
followed by an open parenthesis. Hit ESC or click elsewhere in the
window to close the tip window (MH)
- Comment out region now inserts ## to make it stand out more (TP)
- New path and class browsers based on a tree widget that looks
familiar to Windows users
- Reworked script running commands to be more intuitive: I/O now
always goes to the *Python Shell* window, and raw_input() works
correctly. You use F5 to import/reload a module: this adds the module
name to the __main__ namespace. You use Control-F5 to run a script:
this runs the script *in* the __main__ namespace. The latter also
sets sys.argv[] to the script name
New in IDLE 0.4 (4/7/99)
------------------------
Most important change: a new menu entry "File -> Path browser", shows
a 4-column hierarchical browser which lets you browse sys.path,
directories, modules, and classes. Yes, it's a superset of the Class
browser menu entry. There's also a new internal module,
MultiScrolledLists.py, which provides the framework for this dialog.
New in IDLE 0.3 (2/17/99)
-------------------------
Most important changes:
- Enabled support for running a module, with or without the debugger.
Output goes to a new window. Pressing F5 in a module is effectively a
reload of that module; Control-F5 loads it under the debugger.
- Re-enable tearing off the Windows menu, and make a torn-off Windows
menu update itself whenever a window is opened or closed.
- Menu items can now be have a checkbox (when the menu label starts
with "!"); use this for the Debugger and "Auto-open stack viewer"
(was: JIT stack viewer) menu items.
- Added a Quit button to the Debugger API.
- The current directory is explicitly inserted into sys.path.
- Fix the debugger (when using Python 1.5.2b2) to use canonical
filenames for breakpoints, so these actually work. (There's still a
lot of work to be done to the management of breakpoints in the
debugger though.)
- Closing a window that is still colorizing now actually works.
- Allow dragging of the separator between the two list boxes in the
class browser.
- Bind ESC to "close window" of the debugger, stack viewer and class
browser. It removes the selection highlighting in regular text
windows. (These are standard Windows conventions.)
New in IDLE 0.2 (1/8/99)
------------------------
Lots of changes; here are the highlights:
General:
- You can now write and configure your own IDLE extension modules; see
extend.txt.
File menu:
The command to open the Python shell window is now in the File menu.
Edit menu:
New Find dialog with more options; replace dialog; find in files dialog.
Commands to tabify or untabify a region.
Command to format a paragraph.
Debug menu:
JIT (Just-In-Time) stack viewer toggle -- if set, the stack viewer
automaticall pops up when you get a traceback.
Windows menu:
Zoom height -- make the window full height.
Help menu:
The help text now show up in a regular window so you can search and
even edit it if you like.
IDLE 0.1 was distributed with the Python 1.5.2b1 release on 12/22/98.
======================================================================
IDLEfork Installation Notes
===========================
IDLEfork requires Python Version 2.2 or later.
There are several distribution files (where xx is the subversion):
IDLEfork-0.9xx.win32.exe
This is a Windows installer which will install IDLEfork in
..../site-packages/idleforklib/ and place the idefork startup script
at ..../scripts/idlefork. Rename this to idlefork.pyw and
point your launcher icons at it. Installation is as idlefork
to avoid conflict with the original Python IDLE.
IDLEfork-0.9xx-1.noarch.rpm
This is an rpm which is designed to install as idleforklib in an
existing /usr/lib/python2.2 tree. It installs as idlefork to avoid
conflict with Python IDLE.
Python rpms are available at http://www.python.org/2.2.2/rpms.html and
http://www.python.org/2.2.1/rpms.html.
IDLEfork-0.9xx.tar.gz
This is a distutils sdist (source) tarfile which can be used to make
installations on platforms not supported by the above files.
** It remains configured to install as idlelib, not idleforklib. **
Unpack in ..../Tools/, cd to the IDLEfork directory created, and
"python setup.py install" to install in ....site-packages/idlelib.
This will overwrite the Python IDLE installation.
If you don't want to overwrite Python IDLE, it is also possible to
simply call "python idle.py" to run from the IDLEfork source directory
without making an installation. In this case, IDLE will not be on
your PATH unless you are in the source directory. Also, it is then
advisable to remove any Python IDLE installation by removing
..../site-packages/idlelib so the two identically named packages don't
conflict.
On Redhat Linux systems prior to 8.0, /usr/bin/python may be pointing
at python1.5. If so, change the first line in the /usr/bin/idle
script to read:
!# /usr/bin/python2.2
See README.txt for more details on this version of IDLEfork.
To apply this license to IDLE or IDLEfork, read 'IDLE' or 'IDLEfork'
for every occurence of 'Python 2.1.1' in the text below.
PSF LICENSE AGREEMENT
---------------------
1. This LICENSE AGREEMENT is between the Python Software Foundation
("PSF"), and the Individual or Organization ("Licensee") accessing and
otherwise using Python 2.1.1 software in source or binary form and its
associated documentation.
2. Subject to the terms and conditions of this License Agreement, PSF
hereby grants Licensee a nonexclusive, royalty-free, world-wide
license to reproduce, analyze, test, perform and/or display publicly,
prepare derivative works, distribute, and otherwise use Python 2.1.1
alone or in any derivative version, provided, however, that PSF's
License Agreement and PSF's notice of copyright, i.e., "Copyright (c)
2001 Python Software Foundation; All Rights Reserved" are retained in
Python 2.1.1 alone or in any derivative version prepared by Licensee.
3. In the event Licensee prepares a derivative work that is based on
or incorporates Python 2.1.1 or any part thereof, and wants to make
the derivative work available to others as provided herein, then
Licensee hereby agrees to include in any such work a brief summary of
the changes made to Python 2.1.1.
4. PSF is making Python 2.1.1 available to Licensee on an "AS IS"
basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 2.1.1 WILL NOT
INFRINGE ANY THIRD PARTY RIGHTS.
5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
2.1.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 2.1.1,
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
6. This License Agreement will automatically terminate upon a material
breach of its terms and conditions.
7. Nothing in this License Agreement shall be deemed to create any
relationship of agency, partnership, or joint venture between PSF and
Licensee. This License Agreement does not grant permission to use PSF
trademarks or trade name in a trademark sense to endorse or promote
products or services of Licensee, or any third party.
8. By copying, installing or otherwise using Python 2.1.1, Licensee
agrees to be bound by the terms and conditions of this License
Agreement.
# Makefile to build the interrupt module, which is a C extension
PYTHON=python2.3
all: interrupt.so
interrupt.so: interruptmodule.c
$(PYTHON) setup.py build_ext -i
This diff is collapsed.
import rpc
def remote_object_tree_item(item):
wrapper = WrappedObjectTreeItem(item)
oid = id(wrapper)
rpc.objecttable[oid] = wrapper
return oid
class WrappedObjectTreeItem:
# Lives in PYTHON subprocess
def __init__(self, item):
self.__item = item
def __getattr__(self, name):
value = getattr(self.__item, name)
return value
def _GetSubList(self):
list = self.__item._GetSubList()
return map(remote_object_tree_item, list)
class StubObjectTreeItem:
# Lives in IDLE process
def __init__(self, sockio, oid):
self.sockio = sockio
self.oid = oid
def __getattr__(self, name):
value = rpc.MethodProxy(self.sockio, self.oid, name)
return value
def _GetSubList(self):
list = self.sockio.remotecall(self.oid, "_GetSubList", (), {})
return [StubObjectTreeItem(self.sockio, oid) for oid in list]
"""
about box for idle
"""
from Tkinter import *
import string, os
import textView
import idlever
class AboutDialog(Toplevel):
"""
modal about dialog for idle
"""
def __init__(self,parent,title):
Toplevel.__init__(self, parent)
self.configure(borderwidth=5)
self.geometry("+%d+%d" % (parent.winfo_rootx()+30,
parent.winfo_rooty()+30))
self.bg="#707070"
self.fg="#ffffff"
self.CreateWidgets()
self.resizable(height=FALSE,width=FALSE)
self.title(title)
self.transient(parent)
self.grab_set()
self.protocol("WM_DELETE_WINDOW", self.Ok)
self.parent = parent
self.buttonOk.focus_set()
#key bindings for this dialog
self.bind('<Alt-c>',self.CreditsButtonBinding) #credits button
self.bind('<Alt-l>',self.LicenseButtonBinding) #license button
self.bind('<Return>',self.Ok) #dismiss dialog
self.bind('<Escape>',self.Ok) #dismiss dialog
self.wait_window()
def CreateWidgets(self):
frameMain = Frame(self,borderwidth=2,relief=SUNKEN)
frameButtons = Frame(self)
frameButtons.pack(side=BOTTOM,fill=X)
frameMain.pack(side=TOP,expand=TRUE,fill=BOTH)
self.buttonOk = Button(frameButtons,text='Ok',
command=self.Ok)#,default=ACTIVE
self.buttonOk.pack(padx=5,pady=5)
#self.picture = Image('photo',data=self.pictureData)
frameBg = Frame(frameMain,bg=self.bg)
frameBg.pack(expand=TRUE,fill=BOTH)
labelTitle = Label(frameBg,text='IDLEfork',fg=self.fg,bg=self.bg,
font=('courier', 24, 'bold'))
labelTitle.grid(row=0,column=0,sticky=W,padx=10,pady=10)
#labelPicture = Label(frameBg,text='[picture]')
#image=self.picture,bg=self.bg)
#labelPicture.grid(row=0,column=1,sticky=W,rowspan=2,padx=0,pady=3)
labelVersion = Label(frameBg,text='version '+idlever.IDLE_VERSION,
fg=self.fg,bg=self.bg)
labelVersion.grid(row=1,column=0,sticky=W,padx=10,pady=5)
labelDesc = Label(frameBg,
text="A development version of Python's lightweight\n"+
'Integrated DeveLopment Environment, IDLE.',
justify=LEFT,fg=self.fg,bg=self.bg)
labelDesc.grid(row=2,column=0,sticky=W,columnspan=3,padx=10,pady=5)
labelCopyright = Label(frameBg,
text="Copyright (c) 2001 Python Software Foundation;\nAll Rights Reserved",
justify=LEFT,fg=self.fg,bg=self.bg)
labelCopyright.grid(row=3,column=0,sticky=W,columnspan=3,padx=10,pady=5)
labelLicense = Label(frameBg,
text='Released under the Python 2.1.1 PSF Licence',
justify=LEFT,fg=self.fg,bg=self.bg)
labelLicense.grid(row=4,column=0,sticky=W,columnspan=3,padx=10,pady=5)
Frame(frameBg,height=5,bg=self.bg).grid(row=5,column=0)
labelEmail = Label(frameBg,text='email: idle-dev@python.org',
justify=LEFT,fg=self.fg,bg=self.bg)
labelEmail.grid(row=6,column=0,columnspan=2,sticky=W,padx=10,pady=0)
labelWWW = Label(frameBg,text='www: http://idlefork.sourceforge.net',
justify=LEFT,fg=self.fg,bg=self.bg)
labelWWW.grid(row=7,column=0,columnspan=2,sticky=W,padx=10,pady=0)
Frame(frameBg,borderwidth=1,relief=SUNKEN,
height=2,bg=self.bg).grid(row=8,column=0,sticky=EW,
columnspan=3, padx=5, pady=5)
labelPythonVer = Label(frameBg,text='Python version: '+
sys.version.split()[0],fg=self.fg,bg=self.bg)
labelPythonVer.grid(row=9,column=0,sticky=W,padx=10,pady=0)
#handle weird tk version num in windoze python >= 1.6 (?!?)
tkVer = `TkVersion`.split('.')
tkVer[len(tkVer)-1] = str('%.3g' % (float('.'+tkVer[len(tkVer)-1])))[2:]
if tkVer[len(tkVer)-1] == '':
tkVer[len(tkVer)-1] = '0'
tkVer = string.join(tkVer,'.')
labelTkVer = Label(frameBg,text='Tk version: '+
tkVer,fg=self.fg,bg=self.bg)
labelTkVer.grid(row=9,column=1,sticky=W,padx=2,pady=0)
self.buttonLicense = Button(frameBg,text='View License',underline=5,
width=14,highlightbackground=self.bg,command=self.ShowLicense)#takefocus=FALSE
self.buttonLicense.grid(row=10,column=0,sticky=W,padx=10,pady=10)
self.buttonCredits = Button(frameBg,text='View Credits',underline=5,
width=14,highlightbackground=self.bg,command=self.ShowCredits)#takefocus=FALSE
self.buttonCredits.grid(row=10,column=1,columnspan=2,sticky=E,padx=10,pady=10)
def CreditsButtonBinding(self,event):
self.buttonCredits.invoke()
def LicenseButtonBinding(self,event):
self.buttonLicense.invoke()
def ShowLicense(self):
self.ViewFile('About - License','LICENSE.txt')
def ShowCredits(self):
self.ViewFile('About - Credits','CREDITS.txt')
def ViewFile(self,viewTitle,viewFile):
fn=os.path.join(os.path.abspath(os.path.dirname(__file__)),viewFile)
textView.TextViewer(self,viewTitle,fn)
def Ok(self, event=None):
self.destroy()
if __name__ == '__main__':
#test the dialog
root=Tk()
def run():
import aboutDialog
aboutDialog.AboutDialog(root,'About')
Button(root,text='Dialog',command=run).pack()
root.mainloop()
"boolcheck - import this module to ensure True, False, bool() builtins exist."
try:
True
except NameError:
import __builtin__
__builtin__.True = 1
__builtin__.False = 0
from operator import truth
__builtin__.bool = truth
# IDLE reads several config files to determine user preferences. This
# file is the default config file for idle extensions settings.
#
# Each extension must have at least one section, named after the extension
# module. This section must contain an 'enable' item (=1 to enable the
# extension, =0 to disable it) and also contains any other general
# configuration items for the extension. Each extension may also define up to
# two optional sections named ExtensionName_bindings and
# ExtensionName_cfgBindings. If present, ExtensionName_bindings defines virtual
# event bindings for the extension that are not sensibly re-configurable. If
# present, ExtensionName_cfgBindings defines virtual event bindings for the
# extension that may be sensibly re-configured.
# See config-keys.def for notes on specifying keys.
[FormatParagraph]
enable=1
[FormatParagraph_cfgBindings]
format-paragraph=<Alt-Key-q>
[AutoExpand]
enable=1
[AutoExpand_cfgBindings]
expand-word=<Alt-Key-slash>
[ZoomHeight]
enable=1
[ZoomHeight_cfgBindings]
zoom-height=<Alt-Key-2>
[ScriptBinding]
enable=1
[ScriptBinding_cfgBindings]
run-module=<Key-F5>
check-module=<Alt-Key-x>
[CallTips]
enable=1
[CallTips_bindings]
paren-open=<Key-parenleft>
paren-close=<Key-parenright>
check-calltip-cancel=<KeyRelease>
calltip-cancel=<ButtonPress> <Key-Escape>
[ParenMatch]
enable=0
style= expression
flash-delay= 500
bell= 1
hilite-foreground= black
hilite-background= #43cd80
[ParenMatch_bindings]
flash-open-paren=<KeyRelease-parenright> <KeyRelease-bracketright> <KeyRelease-braceright>
check-restore=<KeyPress>
# IDLE reads several config files to determine user preferences. This
# file is the default config file for idle highlight theme settings.
[IDLE Classic]
normal-foreground= #000000
normal-background= #ffffff
keyword-foreground= #ff7700
keyword-background= #ffffff
comment-foreground= #dd0000
comment-background= #ffffff
string-foreground= #00aa00
string-background= #ffffff
definition-foreground= #0000ff
definition-background= #ffffff
hilite-foreground= #000000
hilite-background= gray
break-foreground= black
break-background= #ffff55
hit-foreground= #ffffff
hit-background= #000000
error-foreground= #000000
error-background= #ff7777
#cursor (only foreground can be set)
cursor-foreground= black
#shell window
stdout-foreground= blue
stdout-background= #ffffff
stderr-foreground= red
stderr-background= #ffffff
console-foreground= #770000
console-background= #ffffff
[IDLE New]
normal-foreground= #000000
normal-background= #ffffff
keyword-foreground= #ff7700
keyword-background= #ffffff
comment-foreground= #dd0000
comment-background= #ffffff
string-foreground= #00aa00
string-background= #ffffff
definition-foreground= #0000ff
definition-background= #ffffff
hilite-foreground= #000000
hilite-background= gray
break-foreground= black
break-background= #ffff55
hit-foreground= #ffffff
hit-background= #000000
error-foreground= #000000
error-background= #ff7777
#cursor (only foreground can be set)
cursor-foreground= black
#shell window
stdout-foreground= blue
stdout-background= #ffffff
stderr-foreground= red
stderr-background= #ffffff
console-foreground= #770000
console-background= #ffffff
# IDLE reads several config files to determine user preferences. This
# file is the default config file for idle key binding settings.
# Where multiple keys are specified for an action: if they are separated
# by a space (eg. action=<key1> <key2>) then the keys are altenatives, if
# there is no space (eg. action=<key1><key2>) then the keys comprise a
# single 'emacs style' multi-keystoke binding. The tk event specifier 'Key'
# is used in all cases, for consistency in auto key conflict checking in the
# configuration gui.
[IDLE Classic Windows]
copy=<Control-Key-c>
cut=<Control-Key-x>
paste=<Control-Key-v>
beginning-of-line= <Key-Home>
center-insert=<Control-Key-l>
close-all-windows=<Control-Key-q>
close-window=<Alt-Key-F4> <Meta-Key-F4>
do-nothing=<Control-Key-F12>
end-of-file=<Control-Key-d>
python-docs=<Key-F1>
python-context-help=<Shift-Key-F1>
history-next=<Alt-Key-n> <Meta-Key-n>
history-previous=<Alt-Key-p> <Meta-Key-p>
interrupt-execution=<Control-Key-c>
view-restart=<Key-F6>
restart-shell=<Control-Key-F6>
open-class-browser=<Alt-Key-c> <Meta-Key-c>
open-module=<Alt-Key-m> <Meta-Key-m>
open-new-window=<Control-Key-n>
open-window-from-file=<Control-Key-o>
plain-newline-and-indent=<Control-Key-j>
print-window=<Control-Key-p>
redo=<Control-Shift-Key-z>
remove-selection=<Key-Escape>
save-copy-of-window-as-file=<Alt-Shift-Key-s>
save-window-as-file=<Control-Shift-Key-s>
save-window=<Control-Key-s>
select-all=<Control-Key-a>
toggle-auto-coloring=<Control-Key-slash>
undo=<Control-Key-z>
find=<Control-Key-f>
find-again=<Control-Key-g> <Key-F3>
find-in-files=<Alt-Key-F3> <Meta-Key-F3>
find-selection=<Control-Key-F3>
replace=<Control-Key-h>
goto-line=<Alt-Key-g> <Meta-Key-g>
smart-backspace=<Key-BackSpace>
newline-and-indent=<Key-Return> <Key-KP_Enter>
smart-indent=<Key-Tab>
indent-region=<Control-Key-bracketright>
dedent-region=<Control-Key-bracketleft>
comment-region=<Alt-Key-3> <Meta-Key-3>
uncomment-region=<Alt-Key-4> <Meta-Key-4>
tabify-region=<Alt-Key-5> <Meta-Key-5>
untabify-region=<Alt-Key-6> <Meta-Key-6>
toggle-tabs=<Alt-Key-t> <Meta-Key-t>
change-indentwidth=<Alt-Key-u> <Meta-Key-u>
[IDLE Classic Unix]
copy=<Alt-Key-w> <Meta-Key-w>
cut=<Control-Key-w>
paste=<Control-Key-y>
beginning-of-line=<Control-Key-a> <Key-Home>
center-insert=<Control-Key-l>
close-all-windows=<Control-Key-x><Control-Key-c>
close-window=<Control-Key-x><Control-Key-0>
do-nothing=<Control-Key-x>
end-of-file=<Control-Key-d>
history-next=<Alt-Key-n> <Meta-Key-n>
history-previous=<Alt-Key-p> <Meta-Key-p>
interrupt-execution=<Control-Key-c>
view-restart=<Key-F6>
restart-shell=<Control-Key-F6>
open-class-browser=<Control-Key-x><Control-Key-b>
open-module=<Control-Key-x><Control-Key-m>
open-new-window=<Control-Key-x><Control-Key-n>
open-window-from-file=<Control-Key-x><Control-Key-f>
plain-newline-and-indent=<Control-Key-j>
print-window=<Control-x><Control-Key-p>
python-docs=<Control-Key-h>
python-context-help=<Control-Shift-Key-h>
redo=<Alt-Key-z> <Meta-Key-z>
remove-selection=<Key-Escape>
save-copy-of-window-as-file=<Control-Key-x><Control-Key-y>
save-window-as-file=<Control-Key-x><Control-Key-w>
save-window=<Control-Key-x><Control-Key-s>
select-all=<Alt-Key-a> <Meta-Key-a>
toggle-auto-coloring=<Control-Key-slash>
undo=<Control-Key-z>
find=<Control-Key-u><Control-Key-u><Control-Key-s>
find-again=<Control-Key-u><Control-Key-s>
find-in-files=<Alt-Key-s> <Meta-Key-s>
find-selection=<Control-Key-s>
replace=<Control-Key-r>
goto-line=<Alt-Key-g> <Meta-Key-g>
smart-backspace=<Key-BackSpace>
newline-and-indent=<Key-Return> <Key-KP_Enter>
smart-indent=<Key-Tab>
indent-region=<Control-Key-bracketright>
dedent-region=<Control-Key-bracketleft>
comment-region=<Alt-Key-3>
uncomment-region=<Alt-Key-4>
tabify-region=<Alt-Key-5>
untabify-region=<Alt-Key-6>
toggle-tabs=<Alt-Key-t>
change-indentwidth=<Alt-Key-u>
[IDLE Classic Mac]
copy=<Command-Key-c>
cut=<Command-Key-x>
paste=<Command-Key-v>
beginning-of-line= <Key-Home>
center-insert=<Control-Key-l>
close-all-windows=<Command-Key-q>
close-window=<Command-Key-w>
do-nothing=<Control-Key-F12>
end-of-file=<Control-Key-d>
python-docs=<Key-F1>
python-context-help=<Shift-Key-F1>
history-next=<Control-Key-n>
history-previous=<Control-Key-p>
interrupt-execution=<Control-Key-c>
view-restart=<Key-F6>
restart-shell=<Control-Key-F6>
open-class-browser=<Command-Key-b>
open-module=<Command-Key-m>
open-new-window=<Command-Key-n>
open-window-from-file=<Command-Key-o>
plain-newline-and-indent=<Control-Key-j>
print-window=<Command-Key-p>
redo=<Shift-Command-Key-z>
remove-selection=<Key-Escape>
save-window-as-file=<Shift-Command-Key-s>
save-window=<Command-Key-s>
save-copy-of-window-as-file=<Option-Command-Key-s>
select-all=<Command-Key-a>
toggle-auto-coloring=<Control-Key-slash>
undo=<Command-Key-z>
find=<Command-Key-f>
find-again=<Command-Key-g> <Key-F3>
find-in-files=<Command-Key-F3>
find-selection=<Shift-Command-Key-F3>
replace=<Command-Key-r>
goto-line=<Command-Key-j>
smart-backspace=<Key-BackSpace>
newline-and-indent=<Key-Return> <Key-KP_Enter>
smart-indent=<Key-Tab>
indent-region=<Command-Key-bracketright>
dedent-region=<Command-Key-bracketleft>
comment-region=<Control-Key-3>
uncomment-region=<Control-Key-4>
tabify-region=<Control-Key-5>
untabify-region=<Control-Key-6>
toggle-tabs=<Control-Key-t>
change-indentwidth=<Control-Key-u>
# IDLE reads several config files to determine user preferences. This
# file is the default config file for general idle settings.
#
# When IDLE starts, it will look in
# the following two sets of files, in order:
#
# default configuration
# ---------------------
# config-main.def the default general config file
# config-extensions.def the default extension config file
# config-highlight.def the default highlighting config file
# config-keys.def the default keybinding config file
#
# user configuration
# -------------------
# ~/.idlerc/idle-main.cfg the user general config file
# ~/.idlerc/idle-extensions.cfg the user extension config file
# ~/.idlerc/idle-highlight.cfg the user highlighting config file
# ~/.idlerc/idle-keys.cfg the user keybinding config file
#
# Any options the user saves through the config dialog will be saved to
# the relevant user config file. Reverting any general setting to the
# default causes that entry to be wiped from the user file and re-read
# from the default file. User highlighting themes or keybinding sets are
# retained unless specifically deleted within the config dialog. Choosing
# one of the default themes or keysets just applies the relevant settings
# from the default file.
#
# Additional help sources are listed in the [HelpFiles] section and must be
# viewable by a web browser (or the Windows Help viewer in the case of .chm
# files). These sources will be listed on the Help menu. The pattern is
# <sequence_number = menu item;/path/to/help/source>
# You can't use a semi-colon in a menu item or path. The path will be platform
# specific because of path separators, drive specs etc.
#
# It is best to use the Configuration GUI to set up additional help sources!
# Example:
#1 = My Extra Help Source;/usr/share/doc/foo/index.html
#2 = Another Help Source;/path/to/another.pdf
[General]
editor-on-startup= 0
print-command-posix=lpr %s
print-command-win=start /min notepad /p %s
[EditorWindow]
width= 80
height= 30
font= courier
font-size= 12
font-bold= 0
[Indent]
use-spaces= 1
num-spaces= 4
[Theme]
default= 1
name= IDLE Classic
[Keys]
default= 1
name= IDLE Classic Windows
[HelpFiles]
This diff is collapsed.
This diff is collapsed.
"Dialog to specify or edit the parameters for a user configured help source."
import os
from Tkinter import *
import tkMessageBox
import tkFileDialog
class GetHelpSourceDialog(Toplevel):
def __init__(self, parent, title, menuItem='', filePath=''):
"""Get menu entry and url/ local file location for Additional Help
User selects a name for the Help resource and provides a web url
or a local file as its source. The user can enter a url or browse
for the file.
"""
Toplevel.__init__(self, parent)
self.configure(borderwidth=5)
self.resizable(height=FALSE, width=FALSE)
self.title(title)
self.transient(parent)
self.grab_set()
self.protocol("WM_DELETE_WINDOW", self.Cancel)
self.parent = parent
self.result = None
self.CreateWidgets()
self.menu.set(menuItem)
self.path.set(filePath)
self.withdraw() #hide while setting geometry
#needs to be done here so that the winfo_reqwidth is valid
self.update_idletasks()
#centre dialog over parent:
self.geometry("+%d+%d" %
((parent.winfo_rootx() + ((parent.winfo_width()/2)
-(self.winfo_reqwidth()/2)),
parent.winfo_rooty() + ((parent.winfo_height()/2)
-(self.winfo_reqheight()/2)))))
self.deiconify() #geometry set, unhide
self.bind('<Return>', self.Ok)
self.wait_window()
def CreateWidgets(self):
self.menu = StringVar(self)
self.path = StringVar(self)
self.fontSize = StringVar(self)
self.frameMain = Frame(self, borderwidth=2, relief=GROOVE)
self.frameMain.pack(side=TOP, expand=TRUE, fill=BOTH)
labelMenu = Label(self.frameMain, anchor=W, justify=LEFT,
text='Menu Item:')
self.entryMenu = Entry(self.frameMain, textvariable=self.menu,
width=30)
self.entryMenu.focus_set()
labelPath = Label(self.frameMain, anchor=W, justify=LEFT,
text='Help File Path: Enter URL or browse for file')
self.entryPath = Entry(self.frameMain, textvariable=self.path,
width=40)
self.entryMenu.focus_set()
labelMenu.pack(anchor=W, padx=5, pady=3)
self.entryMenu.pack(anchor=W, padx=5, pady=3)
labelPath.pack(anchor=W, padx=5, pady=3)
self.entryPath.pack(anchor=W, padx=5, pady=3)
browseButton = Button(self.frameMain, text='Browse', width=8,
command=self.browseFile)
browseButton.pack(pady=3)
frameButtons = Frame(self)
frameButtons.pack(side=BOTTOM, fill=X)
self.buttonOk = Button(frameButtons, text='OK',
width=8, default=ACTIVE, command=self.Ok)
self.buttonOk.grid(row=0, column=0, padx=5,pady=5)
self.buttonCancel = Button(frameButtons, text='Cancel',
width=8, command=self.Cancel)
self.buttonCancel.grid(row=0, column=1, padx=5, pady=5)
def browseFile(self):
filetypes = [
("HTML Files", "*.htm *.html", "TEXT"),
("PDF Files", "*.pdf", "TEXT"),
("Windows Help Files", "*.chm"),
("Text Files", "*.txt", "TEXT"),
("All Files", "*")]
path = self.path.get()
if path:
dir, base = os.path.split(path)
else:
base = None
if sys.platform.count('win') or sys.platform.count('nt'):
dir = os.path.join(os.path.dirname(sys.executable), 'Doc')
if not os.path.isdir(dir):
dir = os.getcwd()
else:
dir = os.getcwd()
opendialog = tkFileDialog.Open(parent=self, filetypes=filetypes)
file = opendialog.show(initialdir=dir, initialfile=base)
if file:
self.path.set(file)
def MenuOk(self):
"Simple validity check for a sensible menu item name"
menuOk = True
menu = self.menu.get()
menu.strip()
if not menu:
tkMessageBox.showerror(title='Menu Item Error',
message='No menu item specified',
parent=self)
self.entryMenu.focus_set()
menuOk = False
elif len(menu) > 30:
tkMessageBox.showerror(title='Menu Item Error',
message='Menu item too long:'
'\nLimit 30 characters.',
parent=self)
self.entryMenu.focus_set()
menuOk = False
return menuOk
def PathOk(self):
"Simple validity check for menu file path"
pathOk = True
path = self.path.get()
path.strip()
if not path: #no path specified
tkMessageBox.showerror(title='File Path Error',
message='No help file path specified.',
parent=self)
self.entryPath.focus_set()
pathOk = False
elif path.startswith('www.') or path.startswith('http'):
pathOk = True
elif not os.path.exists(path):
tkMessageBox.showerror(title='File Path Error',
message='Help file path does not exist.',
parent=self)
self.entryPath.focus_set()
pathOk = False
return pathOk
def Ok(self, event=None):
if self.MenuOk() and self.PathOk():
self.result = (self.menu.get().strip(),
self.path.get().strip())
self.destroy()
def Cancel(self, event=None):
self.result = None
self.destroy()
if __name__ == '__main__':
#test the dialog
root = Tk()
def run():
keySeq = ''
dlg = GetHelpSourceDialog(root, 'Get Help Source')
print dlg.result
Button(root,text='Dialog', command=run).pack()
root.mainloop()
"""
Dialog that allows user to specify a new config file section name.
Used to get new highlight theme and keybinding set names.
"""
from Tkinter import *
import tkMessageBox
class GetCfgSectionNameDialog(Toplevel):
def __init__(self,parent,title,message,usedNames):
"""
message - string, informational message to display
usedNames - list, list of names already in use for validity check
"""
Toplevel.__init__(self, parent)
self.configure(borderwidth=5)
self.resizable(height=FALSE,width=FALSE)
self.title(title)
self.transient(parent)
self.grab_set()
self.protocol("WM_DELETE_WINDOW", self.Cancel)
self.parent = parent
self.message=message
self.usedNames=usedNames
self.result=''
self.CreateWidgets()
self.withdraw() #hide while setting geometry
self.update_idletasks()
#needs to be done here so that the winfo_reqwidth is valid
self.messageInfo.config(width=self.frameMain.winfo_reqwidth())
self.geometry("+%d+%d" %
((parent.winfo_rootx()+((parent.winfo_width()/2)
-(self.winfo_reqwidth()/2)),
parent.winfo_rooty()+((parent.winfo_height()/2)
-(self.winfo_reqheight()/2)) )) ) #centre dialog over parent
self.deiconify() #geometry set, unhide
self.wait_window()
def CreateWidgets(self):
self.name=StringVar(self)
self.fontSize=StringVar(self)
self.frameMain = Frame(self,borderwidth=2,relief=SUNKEN)
self.frameMain.pack(side=TOP,expand=TRUE,fill=BOTH)
self.messageInfo=Message(self.frameMain,anchor=W,justify=LEFT,padx=5,pady=5,
text=self.message)#,aspect=200)
entryName=Entry(self.frameMain,textvariable=self.name,width=30)
entryName.focus_set()
self.messageInfo.pack(padx=5,pady=5)#,expand=TRUE,fill=BOTH)
entryName.pack(padx=5,pady=5)
frameButtons=Frame(self)
frameButtons.pack(side=BOTTOM,fill=X)
self.buttonOk = Button(frameButtons,text='Ok',
width=8,command=self.Ok)
self.buttonOk.grid(row=0,column=0,padx=5,pady=5)
self.buttonCancel = Button(frameButtons,text='Cancel',
width=8,command=self.Cancel)
self.buttonCancel.grid(row=0,column=1,padx=5,pady=5)
def NameOk(self):
#simple validity check for a sensible
#ConfigParser file section name
nameOk=1
name=self.name.get()
name.strip()
if not name: #no name specified
tkMessageBox.showerror(title='Name Error',
message='No name specified.', parent=self)
nameOk=0
elif len(name)>30: #name too long
tkMessageBox.showerror(title='Name Error',
message='Name too long. It should be no more than '+
'30 characters.', parent=self)
nameOk=0
elif name in self.usedNames:
tkMessageBox.showerror(title='Name Error',
message='This name is already in use.', parent=self)
nameOk=0
return nameOk
def Ok(self, event=None):
if self.NameOk():
self.result=self.name.get().strip()
self.destroy()
def Cancel(self, event=None):
self.result=''
self.destroy()
if __name__ == '__main__':
#test the dialog
root=Tk()
def run():
keySeq=''
dlg=GetCfgSectionNameDialog(root,'Get Name',
'The information here should need to be word wrapped. Test.')
print dlg.result
Button(root,text='Dialog',command=run).pack()
root.mainloop()
"""
OptionMenu widget modified to allow dynamic menu reconfiguration
and setting of highlightthickness
"""
from Tkinter import OptionMenu
from Tkinter import _setit
import copy
class DynOptionMenu(OptionMenu):
"""
unlike OptionMenu, our kwargs can include highlightthickness
"""
def __init__(self, master, variable, value, *values, **kwargs):
#get a copy of kwargs before OptionMenu.__init__ munges them
kwargsCopy=copy.copy(kwargs)
if 'highlightthickness' in kwargs.keys():
del(kwargs['highlightthickness'])
OptionMenu.__init__(self, master, variable, value, *values, **kwargs)
self.config(highlightthickness=kwargsCopy.get('highlightthickness'))
#self.menu=self['menu']
self.variable=variable
self.command=kwargs.get('command')
def SetMenu(self,valueList,value=None):
"""
clear and reload the menu with a new set of options.
valueList - list of new options
value - initial value to set the optionmenu's menubutton to
"""
self['menu'].delete(0,'end')
for item in valueList:
self['menu'].add_command(label=item,
command=_setit(self.variable,item,self.command))
if value:
self.variable.set(value)
/***********************************************************************
* interruptmodule.c
*
* Python extension implementing the interrupt module.
*
**********************************************************************/
#include "Python.h"
#ifndef PyDoc_STR
#define PyDoc_VAR(name) static char name[]
#define PyDoc_STR(str) str
#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str)
#endif
/* module documentation */
PyDoc_STRVAR(module_doc,
"Provide a way to interrupt the main thread from a subthread.\n\n\
In threaded Python code the KeyboardInterrupt is always directed to\n\
the thread which raised it. This extension provides a method,\n\
interrupt_main, which a subthread can use to raise a KeyboardInterrupt\n\
in the main thread.");
/* module functions */
static PyObject *
setinterrupt(PyObject * self, PyObject * args)
{
PyErr_SetInterrupt();
Py_INCREF(Py_None);
return Py_None;
}
/* registration table */
static struct PyMethodDef methods[] = {
{"interrupt_main", setinterrupt, METH_VARARGS,
PyDoc_STR("Interrupt the main thread")},
{NULL, NULL}
};
/* module initialization */
void
initinterrupt(void)
{
(void) Py_InitModule3("interrupt", methods, module_doc);
}
This diff is collapsed.
#!/usr/bin/env pythonw
# IDLE.app
#
# Installation:
# see the install_IDLE target in python/dist/src/Mac/OSX/Makefile
#
# Usage:
#
# 1. Double clicking IDLE icon will open IDLE.
# 2. Dropping file on IDLE icon will open that file in IDLE.
# 3. Launch from command line with files with this command-line:
#
# /Applications/Python/IDLE.app/Contents/MacOS/python file1 file2 file3
#
#
# Add IDLE.app/Contents/Resources/idlelib to path.
# __file__ refers to this file when it is used as a module, sys.argv[0]
# refers to this file when it is used as a script (pythonw macosx_main.py)
import sys
from os.path import split, join, isdir
try:
__file__
except NameError:
__file__ = sys.argv[0]
idlelib = join(split(__file__)[0], 'idlelib')
if isdir(idlelib):
sys.path.append(idlelib)
# see if we are being asked to execute the subprocess code
if '-p' in sys.argv:
# run expects only the port number in sys.argv
sys.argv.remove('-p')
# this module will become the namespace used by the interactive
# interpreter; remove all variables we have defined.
del sys, __file__, split, join, isdir, idlelib
__import__('run').main()
else:
# Load idlelib/idle.py which starts the application.
import idle
This diff is collapsed.
import sys
import time
import socket
import traceback
import threading
import Queue
import boolcheck
import CallTips
import RemoteDebugger
import RemoteObjectBrowser
import StackViewer
import rpc
import interrupt
import __main__
# Thread shared globals: Establish a queue between a subthread (which handles
# the socket) and the main thread (which runs user code), plus global
# completion and exit flags:
server = None # RPCServer instance
queue = Queue.Queue(0)
execution_finished = False
exit_requested = False
def main():
"""Start the Python execution server in a subprocess
In the Python subprocess, RPCServer is instantiated with handlerclass
MyHandler, which inherits register/unregister methods from RPCHandler via
the mix-in class SocketIO.
When the RPCServer 'server' is instantiated, the TCPServer initialization
creates an instance of run.MyHandler and calls its handle() method.
handle() instantiates a run.Executive object, passing it a reference to the
MyHandler object. That reference is saved as attribute rpchandler of the
Executive instance. The Executive methods have access to the reference and
can pass it on to entities that they command
(e.g. RemoteDebugger.Debugger.start_debugger()). The latter, in turn, can
call MyHandler(SocketIO) register/unregister methods via the reference to
register and unregister themselves.
"""
global queue, execution_finished, exit_requested
port = 8833
if sys.argv[1:]:
port = int(sys.argv[1])
sys.argv[:] = [""]
sockthread = threading.Thread(target=manage_socket,
name='SockThread',
args=(('localhost', port),))
sockthread.setDaemon(True)
sockthread.start()
while 1:
try:
if exit_requested:
sys.exit()
# XXX KBK 22Mar03 eventually check queue here!
pass
time.sleep(0.05)
except KeyboardInterrupt:
##execution_finished = True
continue
def manage_socket(address):
global server, exit_requested
for i in range(6):
time.sleep(i)
try:
server = rpc.RPCServer(address, MyHandler)
break
except socket.error, err:
if i < 3:
print>>sys.__stderr__, ".. ",
else:
print>>sys.__stderr__,"\nPython subprocess socket error: "\
+ err[1] + ", retrying...."
else:
print>>sys.__stderr__, "\nConnection to Idle failed, exiting."
exit_requested = True
server.handle_request() # A single request only
class MyHandler(rpc.RPCHandler):
def handle(self):
"""Override base method"""
executive = Executive(self)
self.register("exec", executive)
sys.stdin = self.get_remote_proxy("stdin")
sys.stdout = self.get_remote_proxy("stdout")
sys.stderr = self.get_remote_proxy("stderr")
rpc.RPCHandler.getresponse(self, myseq=None, wait=0.5)
class Executive:
def __init__(self, rpchandler):
self.rpchandler = rpchandler
self.locals = __main__.__dict__
self.calltip = CallTips.CallTips()
def runcode(self, code):
global queue, execution_finished
execution_finished = False
queue.put(code)
# dequeue and run in subthread
self.runcode_from_queue()
while not execution_finished:
time.sleep(0.05)
def runcode_from_queue(self):
global queue, execution_finished
# poll until queue has code object, using threads, just block?
while True:
try:
code = queue.get(0)
break
except Queue.Empty:
time.sleep(0.05)
try:
exec code in self.locals
except:
self.flush_stdout()
efile = sys.stderr
typ, val, tb = info = sys.exc_info()
sys.last_type, sys.last_value, sys.last_traceback = info
tbe = traceback.extract_tb(tb)
print >>efile, 'Traceback (most recent call last):'
exclude = ("run.py", "rpc.py", "RemoteDebugger.py", "bdb.py")
self.cleanup_traceback(tbe, exclude)
traceback.print_list(tbe, file=efile)
lines = traceback.format_exception_only(typ, val)
for line in lines:
print>>efile, line,
execution_finished = True
else:
self.flush_stdout()
execution_finished = True
def flush_stdout(self):
try:
if sys.stdout.softspace:
sys.stdout.softspace = 0
sys.stdout.write("\n")
except (AttributeError, EOFError):
pass
def cleanup_traceback(self, tb, exclude):
"Remove excluded traces from beginning/end of tb; get cached lines"
orig_tb = tb[:]
while tb:
for rpcfile in exclude:
if tb[0][0].count(rpcfile):
break # found an exclude, break for: and delete tb[0]
else:
break # no excludes, have left RPC code, break while:
del tb[0]
while tb:
for rpcfile in exclude:
if tb[-1][0].count(rpcfile):
break
else:
break
del tb[-1]
if len(tb) == 0:
# exception was in IDLE internals, don't prune!
tb[:] = orig_tb[:]
print>>sys.stderr, "** IDLE Internal Exception: "
for i in range(len(tb)):
fn, ln, nm, line = tb[i]
if nm == '?':
nm = "-toplevel-"
if not line and fn.startswith("<pyshell#"):
line = self.rpchandler.remotecall('linecache', 'getline',
(fn, ln), {})
tb[i] = fn, ln, nm, line
def interrupt_the_server(self):
self.rpchandler.interrupted = True
##print>>sys.__stderr__, "** Interrupt main!"
interrupt.interrupt_main()
def shutdown_the_server(self):
global exit_requested
exit_requested = True
def start_the_debugger(self, gui_adap_oid):
return RemoteDebugger.start_debugger(self.rpchandler, gui_adap_oid)
def stop_the_debugger(self, idb_adap_oid):
"Unregister the Idb Adapter. Link objects and Idb then subject to GC"
self.rpchandler.unregister(idb_adap_oid)
def get_the_calltip(self, name):
return self.calltip.fetch_tip(name)
def stackviewer(self, flist_oid=None):
if not hasattr(sys, "last_traceback"):
return None
flist = None
if flist_oid is not None:
flist = self.rpchandler.get_remote_proxy(flist_oid)
tb = sys.last_traceback
while tb and tb.tb_frame.f_globals["__name__"] in ["rpc", "run"]:
tb = tb.tb_next
item = StackViewer.StackTreeItem(flist, tb)
return RemoteObjectBrowser.remote_object_tree_item(item)
[bdist_rpm]
release = 1
packager = Kurt B. Kaiser <kbk@shore.net>
"""
a couple of classes for implementing partial tabbed-page like behaviour
"""
from Tkinter import *
class InvalidTabPage(Exception): pass
class AlreadyExists(Exception): pass
class PageTab(Frame):
"""
a 'page tab' like framed button
"""
def __init__(self,parent):
Frame.__init__(self, parent,borderwidth=2,relief=RIDGE)
self.button=Radiobutton(self,padx=5,pady=5,takefocus=FALSE,
indicatoron=FALSE,highlightthickness=0,
borderwidth=0,selectcolor=self.cget('bg'))
self.button.pack()
class TabPageSet(Frame):
"""
a set of 'pages' with TabButtons for controlling their display
"""
def __init__(self,parent,pageNames=[],**kw):
"""
pageNames - a list of strings, each string will be the dictionary key
to a page's data, and the name displayed on the page's tab. Should be
specified in desired page order. The first page will be the default
and first active page.
"""
Frame.__init__(self, parent, kw)
self.grid_location(0,0)
self.columnconfigure(0,weight=1)
self.rowconfigure(1,weight=1)
self.tabBar=Frame(self)
self.tabBar.grid(row=0,column=0,sticky=EW)
self.activePage=StringVar(self)
self.defaultPage=''
self.pages={}
for name in pageNames:
self.AddPage(name)
def ChangePage(self,pageName=None):
if pageName:
if pageName in self.pages.keys():
self.activePage.set(pageName)
else:
raise InvalidTabPage, 'Invalid TabPage Name'
## pop up the active 'tab' only
for page in self.pages.keys():
self.pages[page]['tab'].config(relief=RIDGE)
self.pages[self.GetActivePage()]['tab'].config(relief=RAISED)
## switch page
self.pages[self.GetActivePage()]['page'].lift()
def GetActivePage(self):
return self.activePage.get()
def AddPage(self,pageName):
if pageName in self.pages.keys():
raise AlreadyExists, 'TabPage Name Already Exists'
self.pages[pageName]={'tab':PageTab(self.tabBar),
'page':Frame(self,borderwidth=2,relief=RAISED)}
self.pages[pageName]['tab'].button.config(text=pageName,
command=self.ChangePage,variable=self.activePage,
value=pageName)
self.pages[pageName]['tab'].pack(side=LEFT)
self.pages[pageName]['page'].grid(row=1,column=0,sticky=NSEW)
if len(self.pages)==1: # adding first page
self.defaultPage=pageName
self.activePage.set(self.defaultPage)
self.ChangePage()
def RemovePage(self,pageName):
if not pageName in self.pages.keys():
raise InvalidTabPage, 'Invalid TabPage Name'
self.pages[pageName]['tab'].pack_forget()
self.pages[pageName]['page'].grid_forget()
self.pages[pageName]['tab'].destroy()
self.pages[pageName]['page'].destroy()
del(self.pages[pageName])
# handle removing last remaining, or default, or active page
if not self.pages: # removed last remaining page
self.defaultPage=''
return
if pageName==self.defaultPage: # set a new default page
self.defaultPage=\
self.tabBar.winfo_children()[0].button.cget('text')
if pageName==self.GetActivePage(): # set a new active page
self.activePage.set(self.defaultPage)
self.ChangePage()
if __name__ == '__main__':
#test dialog
root=Tk()
tabPage=TabPageSet(root,pageNames=['Foobar','Baz'])
tabPage.pack(expand=TRUE,fill=BOTH)
Label(tabPage.pages['Foobar']['page'],text='Foo',pady=20).pack()
Label(tabPage.pages['Foobar']['page'],text='Bar',pady=20).pack()
Label(tabPage.pages['Baz']['page'],text='Baz').pack()
entryPgName=Entry(root)
buttonAdd=Button(root,text='Add Page',
command=lambda:tabPage.AddPage(entryPgName.get()))
buttonRemove=Button(root,text='Remove Page',
command=lambda:tabPage.RemovePage(entryPgName.get()))
labelPgName=Label(root,text='name of page to add/remove:')
buttonAdd.pack(padx=5,pady=5)
buttonRemove.pack(padx=5,pady=5)
labelPgName.pack(padx=5)
entryPgName.pack(padx=5)
tabPage.ChangePage()
root.mainloop()
##---------------------------------------------------------------------------##
##
## idle - simple text view dialog
## elguavas
##
##---------------------------------------------------------------------------##
"""
simple text browser for idle
"""
from Tkinter import *
import tkMessageBox
class TextViewer(Toplevel):
"""
simple text viewer dialog for idle
"""
def __init__(self,parent,title,fileName):
"""
fileName - string,should be an absoulute filename
"""
Toplevel.__init__(self, parent)
self.configure(borderwidth=5)
self.geometry("+%d+%d" % (parent.winfo_rootx()+10,
parent.winfo_rooty()+10))
#elguavas - config placeholders til config stuff completed
self.bg=None
self.fg=None
self.CreateWidgets()
self.title(title)
self.transient(parent)
self.grab_set()
self.protocol("WM_DELETE_WINDOW", self.Ok)
self.parent = parent
self.textView.focus_set()
#key bindings for this dialog
self.bind('<Return>',self.Ok) #dismiss dialog
self.bind('<Escape>',self.Ok) #dismiss dialog
self.LoadTextFile(fileName)
self.textView.config(state=DISABLED)
self.wait_window()
def LoadTextFile(self, fileName):
textFile = None
try:
textFile = open(fileName, 'r')
except IOError:
tkMessageBox.showerror(title='File Load Error',
message='Unable to load file '+`fileName`+' .')
else:
self.textView.insert(0.0,textFile.read())
def CreateWidgets(self):
frameText = Frame(self)
frameButtons = Frame(self)
self.buttonOk = Button(frameButtons,text='Ok',
command=self.Ok,takefocus=FALSE,default=ACTIVE)
self.scrollbarView = Scrollbar(frameText,orient=VERTICAL,
takefocus=FALSE,highlightthickness=0)
self.textView = Text(frameText,wrap=WORD,highlightthickness=0)
self.scrollbarView.config(command=self.textView.yview)
self.textView.config(yscrollcommand=self.scrollbarView.set)
self.buttonOk.pack(padx=5,pady=5)
self.scrollbarView.pack(side=RIGHT,fill=Y)
self.textView.pack(side=LEFT,expand=TRUE,fill=BOTH)
frameButtons.pack(side=BOTTOM,fill=X)
frameText.pack(side=TOP,expand=TRUE,fill=BOTH)
def Ok(self, event=None):
self.destroy()
if __name__ == '__main__':
#test the dialog
root=Tk()
Button(root,text='View',
command=lambda:TextViewer(root,'Text','./textView.py')).pack()
root.mainloop()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment