Author: | Daniel Pozmanter |
---|---|
Contact: | drpython@bluebottle.com |
Web site: | http://drpython.sourceforge.net/ |
Copyright: | 2003-2005 Daniel Pozmanter |
License: | GPL |
Customize and Extend:
Just what is DrPython?
To start with, DrPython is a Development Environment. It is essentially a text editor with built in programming tools, like an integrated prompt, text manipulation, and syntax highlighting to name a few. The integrated prompt means when you run a python program, DrPython catches the output, takes input, and in general behaves like a console window (cmd.exe or rxvt for example).
DrPython was designed to be a cross-platform Python IDE. The primary purpose was for use in Education, to make teaching Python programming easier. It was originally designed based roughly on DrScheme. DrPython is meant to play the same role for Python that DrScheme plays for Scheme.
The development platform is Linux (Mandrake 10.1 is the current flavor) It has been tested on various flavors of Linux (E.g. Mandrake, Debian, Gentoo, Fedora), Windows 9x, Windows NT, Windows XP, and Mac OS X.
Any platform which supports python 2.3+ and wxPython 2.5.2+ should work.
Is DrPython Free or What?
DrPython is both free and open source software. This means you can download DrPython for free, share it as much as you want, look through the source, whatever. You can even take chunks of code and plop them into your own program (so long as you give proper credit!). You could even start your own branch of DrPython, or rewrite the code to work with another language.
The point of Free/Open Source Software is that the user has the power to use their software as they wish.
The bummer side of this is that DrPython has no warranty. So if after using DrPython your computer becomes telekinetic and blows up your refrigerator... You can send me a bug report.
DrPython is released under the GNU Public License.
For the Program:
For the Documentation:
Icons from:
If you are reading this, DrPython should already be installed. That being said, you need the following programs to run DrPython: Python 2.0 or newer (tested with 2.2) and the corresponding wxPython. It is really best to get the lastest version of Python and wxPython.
If you are having trouble running DrPython on Linux/Unix, run the file drpython.lin, or edit the first line of drpython.pyw or drpython.py to read:
(eg: #!/usr/bin/python). (In other words, make the path absolute.)
If you are still having trouble, go to the DrPython website (http://www.sourceforge.net/projects/drpython/) and post to the help forum.
You can manually set the path used for storing preferences:
drpython.pyw --preferencesbasepath="the path"
DrPython will then use preferences in the directory: - "the path/.drpython" - "the path/drpython" on Windows
Found a bug? Want to see something change? Have a feature request? Stop by the DrPython Sourceforge Project Page. Post in the forum, or formally submit a bug/feature request. I highly recommend starting a discussion on possible features/changes. Part of the power of open source is the power of the users and developers to engage in discourse about a project, its design and its uses.
Bookmarks are pretty straighforward: there are Bookmarks, and there are Bookmark Folders.
A Bookmark is either a file or directory. When it is selected from the menu, if it is a file, it is opened. If it is a directory, an Open Dialog in that directory pops up.
A Bookmark Folder may contain Bookmarks and/or Bookmark Folders.
You can only add a Bookmark Folder or Bookmark to a Bookmark Folder.
To move a Bookmark or a Bookmark Folder (and all it's contents):
Back to the Top
Runs the python built in 'compile', then tabnanny, on the current file. Reports syntax and indentation errors.
Note that this only checks the syntax for the current file.
The following only applies if your version of wxPython was built with unicode support:
If you want to use a non ascii encoding (like latin-1 or unicode (utf8)), you need to set some preferences first. (In the event of a bad encoding, drpython will warn you via standard output (if the problem is in the file dialog or prompt), or via a dialog (if the problem occurs while saving or opening a file).
DrPython, by default, checks for unicode when opening/saving files, and in the Prompt.
If you want to use a specific encoding, you have two options.
(As detailed in the Python Tutorial).
DrPython will try the encoding 'xyz' for the file first.
DrPython, when getting text to open/save will go through the following steps:
To disable default encoding, leave it blank.
Back to the Top
This is a rather standard/straightforward dialog. However there are some things that stick out.
Right clicking on the text field will yield a pop up menu. You can insert tab/newline/carriage returns, perform clipboard operations, or clear the text.
You can also access Find/Replace History via the combobox.
Back to the Top
This is a user initiated version of auto complete. DrPython will search the current file for possible completions to the word you are currently typing. It will display these results in a small window. Navigate by using the up and down arrows, or to go faster, page up and page down to go faster, or home and end to skip to the start and end of the list.
Hitting Enter or Tab will complete the current word with the selection.
Context Sensitive: Find And Complete stops at the following characters (in addition to whitespace):
( ) < > [ ] { }
This means:
searching at dog(tre will yield tree, treat. However:
searching at dog( will yield dog(threat, dogs.
Note: Find And Complete is case sensitive.
Back to the Top
A few notes. In the code:
'if True:' is the start of the block; 'print "Hello again"' is the end.
Comments '#' are ignored. For explicitly (joined with a backslash) and implicitly joined lines, every line after the first is ignored.
Double clicking a traceback entry in the prompt (the File line in the example below):
Traceback (most recent call last): File "/home/user/Desktop/test.py", line 6, in ? wd NameError: name 'wd' is not defined
will tell DrPython to open '/home/user/Desktop/test.py' and go to line 6.
Back to the Top
The "Use Tabs" option under "Document" in preferences tells DrPython whether to use tabs (default) or spaces for autoindentation. "Tab Width" under "General" is how many spaces DrPython should consider a "Tab" to be.
To see what characters the current document uses for indentation, check the statusbar.
The "Whitespace" menu has entries that allow you to set indentation to tabs or spaces. Setting the indentation for the document to tabs, for example, will replace a set number of spaces with tabs. This operation takes place at the beginning of each line.
Some programmers prefer (and/or were taught) to use tabs ('t') to indent blocks of code. Some use spaces instead.
The whitespace menu lets you easily switch the type of indentation used in the current file to the type you prefer to work with.
Note: The ClassBrowser only works properly if the current file is using the same type of indentation (tab character or spaces) as is set as the default for DrPython in prefs. DrPython will automatically check for this when you open the Class Browser. To fix a mixed file, use the "Whitespace" menu under "Edit".
NOTE: If the line endings are mixed, DrPython will not be able to properly fix the indentation. Always set the line endings before setting the indentation type.
Back to the Top
You can set shortcuts by selecting "Customize Shortcuts" from the Options menu.
Ignore Keys ignores the modifier keys listed. Only modifier keys are valid. This is primarily for operating systems such as Linux, where the "Meta" key is set to "Num Lock" by default, and hence may always be on.
Note: You can set shortcuts for DrScript menu items. If you have not, or the shortcuts file is somehow out of sync with the actual number of DrScripts, DrPython will simply load the correct DrScripts, with no default shortcuts. DrScript Shortcuts are stored separately from DrPython Shortcuts.
If your shortcuts are not working, use "get key" on a shortcut to see if a modifier key is constantly present. On Linux, "Meta" may be present. If this is the case, use "Ignore Keys" to set "Meta" as a key to ignore.
For a given shortcut, simply click the "Get Key" Button, and press the keys you wish. It will print the modifiers detected, and the keycode. When you are done, hit "Close", and the keystring will be next to the shortcut.
Select "Update" to start using the key now. Select "Save" to have DrPython remember the changes.
Note: The Tab and Enter keys are used for code related to indentation in the document, and Enter + the arrow keys are used behaviour specific to the prompt. Setting these keys in the shortcuts may cause DrPython to behave incorrectly.
Note: On some platforms some keys may not register, and thus cannot be used as shortcuts.
Note: There seems to be a bug where shift + backspace inserts the backspace character. To work around this, "Delete Back Not Line" is assigned to shift + backspace. If you want to insert the backspace character, just set "Delete Back Not Line" to None. If you want to use shift + backspace for something else, just set it to None, and you should be set.
The defaults are:
Key | Default shortcut |
---|---|
Ctrl + N | New File |
Ctrl + O | Open File |
Ctrl + S | Save File |
Ctrl + W | Close File |
Ctrl + M | Open Imported Module |
F9 | Select Previous Document |
F10 | Select Next Document |
F7 | Open a Python interpreter |
Ctrl + E | Run current program |
Ctrl + D | End current program / Python interpreter |
Ctrl + R | Replace |
Ctrl + F | Find |
F3 | Find Next |
Shift + F3 | Find previous |
Ctrl + G | Go to line |
Ctrl + B | Go to block start |
Ctrl + Shift + B | Go to block end |
Ctrl + F8 | Source Browser Go To |
Ctrl + Enter | Find and complete |
F6 | Toggle view prompt |
F5 | Toggle maximise |
F8 | Toggle source browser |
Ctrl + Shift + W | Toggle view whitespace |
Ctrl + P | Print file |
Ctrl + Shift + P | Print prompt |
Ctrl + [ | Comment |
Ctrl + ] | Uncomment |
Ctrl + I | Indent |
Ctrl + Shift + I | Dedent |
Ctrl + A | Select all |
Ctrl + Z | Undo |
Ctrl + Y | Redo |
Ctrl + X | Cut |
Ctrl + C | Copy |
Ctrl + V | Paste |
Ctrl + + | Zoom in |
Ctrl + - | Zoom out |
Ctrl + Shift + U | Uppercase |
Ctrl + U | Lowercase |
Back to the Top
Unix Mode | \n | New line |
Windows Mode | \r\n | Carriage return, New line |
Macintosh Mode | \r | Carriage return |
Windows mode can make linux hiccup. So Unix Mode is the default (Windows seems to be fine with it.)
Note: Setting the Line Endings in Preferences does not affect the current open file!
Back to the Top
DrPython only shows modules which exist. These are either in the current module search path for Python, or in the same directory as the current document.
Some modules do not exist as files. The integral modules sys and time are two examples. These will not show up in the list of imported modules, even if they are imported in the current document.
If you type, the typed text is used as a filter for the matching modules. (Use backspace to backtrack). Only matches that contain the typed text will be shown. (Case insensitive.)
Back to the Top
To activate this feature, use Alt on Windows, Shift + Alt on Linux. (If neither works, try Ctrl).
In Find: rectangular selection ignores line endings, and does not support the 'Whole Word' flag. It searches line by line.
In Replace: the above applies. Also, 'Prompt On Replace' is not supported.
Back to the Top
It is best to consult the python documentation (Under Modules, "re").
In short, Regular Expressions provide a fast and powerful method for matching patterns of text. These can be quite useful in programs you write, or simply to find and/or replace text in a given file.
Back to the Top
Open a file, click run, and you are set to go. If your program takes arguments, select "Set Arguments" from the menu or toolbar.
Note the right field in the status bar tells you if the program is running. Also note that the "End" button is enabled, and "Run", "Set Arguments", and "Python Debugger" are disabled.
When the program has ended, the right status bar field goes blank, "End" is disabled, and "Run", "Set Arguments", and "Python Debugger" are enabled.
Back to the Top
To add a shell command, go to the DrScript menu, under Add Script, and select "Shell Command".
Back to the Top
The source browser displays classes, defs, imports, and labels. Double Clicking (Or, Optionally, Right Clicking) an item will set the Document to the line number of that item.
Separators (Labels) can be added manually #---YourLabelHere or via the Insert Seperators Dialog.
Back to the Top
A very quick and simple way to move around in a large document. If you type, the typed text is used as a filter for the matching classes, defs, and imports. (Use backspace to backtrack). Only matches that contain the typed text will be shown. (Case insensitive.)
The typed text is echoed in the top text control. The next two text controls shows the line number of the selected item, as well as the class or function the item is defined in. (The filename is used if no class or function is found).
Back to the Top
Back to the Top
A few notes on customizing the toolbar.
Back to the Top
Tracebacks are the output the python interpreter produces for an unhandled exception. This output:
Traceback (most recent call last): File "/mnt/win_e/docs/prog/drpython/drpython-3.1.2/drpython.py", line 1840, in OnGoTo v = int(v) - 1 ValueError: invalid literal for int(): line number
is produced if you type "line number" into the Goto dialog.
Now, DrPython handles this exception. However DrPython displays tracebacks in its error dialogs (if there are any) for the purposes of transparency. This way, if there is a bug it is easier to report it, and if you are working on a DrScript or a Plugin, this makes it easier to figure out what is going on.
Back to the Top
View In Panel lets you view any open document (including the current one) in any side panel.
There are two notes.
Back to the Top
DrPython cannot handle everything.
If you create more than 100 Panels in any one direction (Left, Right, Top, Bottom), the events will be all messed up.
If you do not have permission to write to your user's home directory, or the replacement directories DrPython will try if your home directory does not exist (eg. C:\ or os.environ["APPDATA"]), then DrPython will not save preferences, and will not keep a recent files list.
If you run a program with an infinite loop, things will get rather slow. Hit the "End" button on the toolbar, or hit Ctrl+D to end the program being run.
Please note that if you type the color in for the font style dialog, any bad characters (not 0-9 or A-F) will create a warning the moment you enter them. If the string is not properly formated ('#' followed by 6 characters), the sliders will be disabled. Upon hitting OK, any invalid color string will be ignored, and DrPython will revert to the last value for that color string.
Back to the Top