DrPython: Help



Welcome to the DrPython documentation.

Written By: Daniel Pozmanter (drpython@bluebottle.com)

Copyright 2003 Daniel Pozmanter

Utilizing: Python (Guido van Rossum et al.),
wxPython (Robin Dunn), wxWindows (Julian Smart et al.), Scintilla (Neil Hodgson),
and Klassic New Crisp Icons (Asif Ali Rizwaan)

Table of Contents:

Introduction

GNU General Public License

Credits
Thanks
North Star (Learn More, Help Out)

Support
Installation
Running a Python Program
Debugging a Python Program
Loggers
Switcheroo
RegularExpressions
DrScript
Bookmarks
Startup Script
Indentation and Tabs
Menu and Focus (Toggling)
Keyboard Shortcuts
Preferences and Themes
File Format
Notes



Introduction:

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 intergrated 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 (As of DrPython 2.2.7, Mandrake 9.2 is the current flavor)
It has been tested on various flavors of Linux (E.g. Mandrake, Debian), Windows 9x, Windows NT, Windows XP,
and Mac OS X.

Any platform which supports python 2.2+ and wxPython 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 to 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 refridgerator...You can send me a bug report.

DrPython is released under the GNU Public License.

If you want to show support for DrPython,
you can donate to the individual users, or
to North Star, the school that started it all.

Back to the Top



Support:

Found a bug?  Want to see something change?  Have a feature request?
Stop by the drpython sourceforge page (http://www.sourceforge.net/projects/drpython/).
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.

Back to the Top



Installation:

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 from the same directory as drpython,
or edit the first line of drpython.pyw or drpython.py to read:
#![ PATH TO PYTHON ]/python
(eg: #!/usr/bin/python)
(In other words, make the path absolute)
You could do the same to drpython.lin:
Change:
python ./drpython.pyw
To:
python [pathtodrpython]/drpython.pyw
(eg: python /home/user/drpython-2.2.7/drpython.pyw)

If you are still having trouble, go to the DrPython website
(http://www.sourceforge.net/projects/drpython/) and post to the help forum.


Back to the Top


Running a Python Program:

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


Debugging a Python Program:

DrPython simply uses the Python Debugger (pdb.py)
Consult the Python documentation for how to use this program.
DrPython supports adding Breakpoints as well.
(Breakpoints are not saved with the file).
You can also type "help" at the debug prompt.

Another way to debug a program is by using Loggers.


Back to the Top


Loggers:

What are "Loggers"?  A simple method of debugging a program.
When I coded in C++, I prefered to use small logging functions
I wrote rather than stepping through my code.

Here is how it works.

You put the cursor somewhere where a logging function would be useful:

You select "Add Logger" or "Add String Logger" from the
Program Menu under "Loggers".

This will produce a log (by default, the filename + ".log")
which contains information logged by each logger call.

Thus you could have a record of everytime a function is called,
the value of a variable in a loop, etc.  Each Logger Call by default
sets the first argument to a string representation of the current line number.
Of course, this can be changed to anything you want.

This is especially useful in projects with multiple files.


Back to the Top


Switcheroo:

Switcheroo is like replace, except instead of replacing "Text A" with "Text B",
it replaces every instance of "Text A" with "Text B",
and every instance of "Text B" with "Text A".
So using Switcheroo and selecting
Switch: Dog
With:     Cat
on the following text:
"The Dog chased the Cat, and the Cat bit back."

Will yield:
"The Cat chased the Dog, and the Dog bit back."


Back to the Top


Regular Expressions:

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


Bookmarks:

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):
Single click on the item you want to move.
Drag it to the item you want it to go immediately after.
Dragging it to the any item in a folder will cause it to be added
directly after that item.
Dragging it to a folder will cause it to be the first item in that folder.

Back to the Top


Startup Script:

If you create a file in your drpython folder in your home directory  called:
"startup.py", DrPython will run it before it loads most of the program.

Under the "Options" menu, the "Startup Script" menu let's you do this easily.
Simply select "Edit Startup Script" to Edit (or create, if one does not yet exist)
your Startup Script. 

At any time, you can remove the startup script by selecting "Remove Startup Script".

Note:  Removing the script completely removes "startup.py" from your drpython folder
in your home directory.

Back to the Top


Indentation and Tabs:

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.

The clean up indentation menu let's you switch tabs with spaces,
or spaces with tabs.  Some programmers prefer (or were taught)
to use tabs ('\t') to indent blocks of code.  Some use spaces instead.

The clean up indentation menu let's 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 tabtype (tab character or spaces) as is set as the default
for DrPython in prefs.

Back to the Top


Menu And Focus (Toggling):

Some menu items act on the Text Control currently with focus.
Toggle Whitespace Visible is one such item.

If the focus is on the File text control, then selecting
this menu item will cause the whitespace
to either become visible or invisible in that control.

If the focus is on the prompt, then the whitespace
will be toggled in the prompt.


Back to the Top



Keyboard Shortcuts:

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:  On some platforms some keys may not register,
and thus cannot be used as shortcuts.

The Defaults Are:

Ctrl + n :
Ctrl + o :
Ctrl + s :

F9:
F10:

F7 :                    
Ctrl + e :
Ctrl + d :

Ctrl + r :
Ctrl + f :
F3 :
Shift + F3:
Ctrl + Alt + s:
Ctrl + g :

F6 :
F5 :
Ctrl + Shift + c
Ctrl + w

Ctrl + p :
Ctrl + Shift + p :

Ctrl + [
Ctrl + ]
Ctrl + i
Ctrl + Shift + i

F8

Ctrl + a
Ctrl + Shift + a
Ctrl + z
Ctrl + y
Ctrl + x
Ctrl + c
Ctrl + p
Ctrl + +
Ctrl + -
Ctrl + Shift + u
Ctrl + u
New Window
Open File
Save File

Select Previous Tab
Select Next Tab

Open a Python Interpreter
Run Current Program
End Current Program/Python Interpreter

Replace
Find
Find Next
Find Previous
Switcheroo
Go To Line

Toggle View Prompt
Toggle Maximize
Show Class Browser
Toggle View Whitespace

Print File
Print Prompt

Comment
UnComment
Indent
Dedent

View Python Docs

Select All
Select None
Undo
Redo
Cut
Copy
Paste
Zoom In
Zoom Out
Uppercase
Lowecase


Back to the Top



File Format:

Unix Mode: "\n", End Line
Windows Mode: "\r\b", Carriage Return, End Line
Mac 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 File Format in Preferences does not affect
the current open file!


Back to the Top


Notes:

DrPython cannot handle everything.
There are two things which will cause odd behavior:

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