Introduction
Screenshots and readme.txt for codeEditor
The codeEditor sample in PythonCard is focused on being a simple to use Python source code editor. It is not intended to be a generic editor or replace vi(m), Emacs, etc. If you are already happy with your existing editing environment for Python source code, there is no particular reason you have to switch. codeEditor and the resourceEditor and shell will be more tightly integrated as the project progresses so that the user has a simple Integrated Development Environment (IDE) for building desktop applications without needing to use an external program for editing.
It borrows ideas and code from IDLE as well as Mark Hammond's Pythonwin, PyCrust (the PythonCard shell) and Robin Dunn's pyshell.py. The core editor component uses the wxPython wxStyledTextCtrl (wxSTC) which in turn uses Neil Hodgson's Scintilla. Isn't open source fun? In 15 minutes you can have a pretty decent editor by standing on the shoulders of others.
Design Questions and Goals
- which IDLE features should be duplicated?
- read/write IDLE config files?
- read/write Pythonwin config files?
- support IDLE extensions or equivelant?
- settable key bindings?
colorize source for printing, http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52298, also SilverCity http://silvercity.sourceforge.net/
- recent files list? [KEA] checked into cvs
how do we handle multiple windows windows doing Multiple Document Interface (MDI)? Just share a window list via a class variable or is there still one main window and all others are child windows? Each window can close itself? How will multiple windows impact the Shell, Scriptlets... What's the IDLE logic on this? Patrick suggested using a wxNotebook like Boa so that each document is a on a separate tab in the notebook; Allaire's HomeSite HTML editor works this way too.
- support optional code folding? Neil says Robin already has most of the logic in the demo for doing this.
To Do
use ConfigParser for config files
- need to be able to support various tab settings and conversions. This is going to have to wait, so for now it is 4 spaces per tab Guido style.
- code folding
Features
Documentation
In addition to the wxPython wxStyledTextCtrl (wxSTC) page, you should check out the Scintilla Documentation. There is a good set of API documentation at http://www.yellowbrain.com/stc/index.html.
We should be able to adapt the following documents for codeEditor. They are also a good source of features that should be supported.
Here's some IDLE documentation, written by Daryl Harms.
Danny Yoo wrote an extremely gentle introduction to IDLE: One Day of IDLE Toying.
Pythonwin docs, including a section on supported command-line arguments
codeEditor source
Associating Python files with codeEditor on Windows
These instructions are for Windows 2000, and Windows XP. They may be slightly different on other versions of Windows.
- Open the Explorer and choose "Folder Options..." under the "Tools" menu
- Click on the "File Types" tab
- Scroll down in the "Registered file types" list and select extension "PY Python File"
- Click on the "Advanced" button 4a. You should be looking at an "Edit File Type" dialog with a list of Actions such as Edit and Open. Open is probably in bold since it is the default action usually associated with .py files.
- Click on the "New..." button 5a. You should be looking at a "New Action" dialog
In the "Action:" field type in a label such as "Edit with PythonCard". This is the label that will show up in the context menu when you right-click on a .py file in the Explorer
- in the "Application used to perform action:" field you need to specify the path to the Python executable as well as the location of the codeEditor.py file. On a Python 2.2.1 installation using the default installer this will look like:
C:\Python22\pythonw.exe C:\Python22\PythonCardPrototype\samples\codeEditor\codeEditor.py "%1" Substitute your own paths for the ones above and put quotes (") around the paths with spaces in them, if any. If you want a console when codeEditor.py runs, then use python.exe instead of pythonw.exe
- Click "OK"
You should now have an "Edit with PythonCard" item in your "Edit File Type" dialog
The item in bold is the default action; Open will be the default if nothing is showing up in bold. Whether you want to "Edit with PythonCard" or "Open" (run) a script when you double-click a file in the Explorer is of course a personal preference. If you want "Edit with PythonCard" as the default action, then select "Edit with PythonCard" in the list, and click the "Set Default" button.
- Click "OK"
- Click "Close" in the "Folder Options" dialog
Open a directory in the explorer that contains a .py file, then right-click on the file and choose "Edit with PythonCard" and the file should be opened with codeEditor.py
- If it doesn't work, double-check the steps above
- Repeat the process for .pyw files, using the same name and path.
Windows 7
In their infinite wisdom, under Windows 7, Microsoft removed the ability for end-users to perform the procedure as described above. See: [http://answers.microsoft.com/en-us/windows/forum/windows_7-files/where-is-the-dialogue-for-advanced-set-file/33b1c212-f5b4-4f3f-9899-8cb7f5b89825]. You can either use the registry editor regedit to perform the necessary key additions, or (much easier) download a trial copy of a very useful program "Creative Element Power Tools" from [http://www.creativelement.com/] and use the "File Type Doctor" in that package to set the file type (similar operating procedure as described above for Windows 2000).
Contributors
Initials indicate comments by particular individuals. Please add yourself as you make changes to this wiki page.
- [KEA] Kevin Altis
- [NKH] Neil Hodgson
- [JH] John Henry
Changes
- 2011-05-13 Added association instructions for Windows XP and Windows 7
2007-07-20 Removed link to PyFrame which is now a linkfarm portal, replaced with the yellowbrain docs.
2003-10-07 [SAM] added link to PyFrame's wxSTC documentation.
- 2003-01-02 [KEA] added link to screenshots and readme.txt on main web site
- 2002-12-25 [KEA] added Associating Python files with codeEditor on Windows from readme.txt
- 2002-05-06 [KEA] most of the must have features are in place, so I made appropriate notes above
- 2002-05-04 [KEA] created page
2002-05-13 [NKH] fixed spelling of Hodgson and added reference to SilverCity