Jimmy's Python Pages
This page is a collection of various Python
goodies I've created. Everything here is covered by the MIT
License. Please let me know if you have any questions or feedback by sending
email to jimmy@retzlaff.com.
EasyDialogs for Windows 46691.0 - a
lightweight port of the Macintosh EasyDialogs module
pyUnRAR 1.0 - a module that wraps the free
UnRAR.dll.
X10 FireCracker Module for Python 1.0 - a module
for turning electrical devices on/off
wxPython AGG Device Context Proof of Concept -
using Anti-Grain Geometry in wxPython
EasyDialogs for Windows 46691.0
Exe Download - run to
install
Zip Download - extract, then run
"setup.py install" to install
Requires: Microsoft Windows, Python 2.3 or higher, and
ctypes
0.6.3 or higher (ctypes is included with Python 2.5 and higher, so it is not
a separate requirement there).
Example usage with screenshots and a
change history are below.
EasyDialogs for Windows is a
ctypes
based emulation of the EasyDialogs module included in the Python distribution
for Mac. It attempts to be as compatible as possible. Code using the Mac EasyDialogs module can often be run unchanged on Windows using this
module. The module has been tested on Python 2.3 running on Windows NT, 98, XP,
and 2003.
EasyDialogs is written in pure Python using Thomas Heller's
ctypes
module to call Windows APIs directly. No Python GUI toolkit is used.
This means that relatively small distributions can be made with py2exe (or
its equivalents). A simple test of all the dialogs in EasyDialogs bundled up
using py2exe results in a distribution that is about 1.25MB. Using py2exe in
concert with NSIS as shown
here allows
the same test to run as a single file executable that is just under 500KB.
The 46691 in the version number refers to the svn revision of the
Mac EasyDialogs.py file in Python SVN upon which this is based.
Version 1.14 is the version that is distributed with Python 2.3 -
version 1.16 for Mac has very minor changes from version 1.14 (these numbers
were based on CVS rather than SVN). Revision 46691 for Mac is
distributed with Python 2.5. The number after the 46691 indicates the revision of the Windows version.
Documentation for the Mac version can be found
here. That documentation is also included in the standard distributions of
Python for Windows and it can be used for this Windows version of
EasyDialogs as well. Known differences include:
AskFileForOpen
typeList is
used for the same purpose, but file type handling is different
between Windows and Mac, so the form of this argument is
different.
In an attempt to remain as similar as possible, a list of extensions
can
be supplied (e.g., ['*', 'txt', 'bat']). A more complete form is
also
allowed: [('All Files (*.*)', '*.*'), ('C Files (*.c, *.h)',
'*.c;*.h')].
The first item in each tuple is the text description presented to
the
user. The second item in each tuple is a semi-colon separated list
of
standard Windows wildcard patterns that will match files described
in the
text description.
The following parameters are ignored on Windows: clientName, dialogOptionFlags, eventProc, filterProc, multiple,
popupExtension, preferenceKey, previewProc, version, wanted
AskFileForSave
fileType is
used for the same purpose, but file type handling is different
between Windows and Mac, so the form of this argument is
different.
In an attempt to remain as similar as possible, an extension can
be supplied (e.g., 'txt'). A more complete form is also allowed:
('Text Files (*.txt)', '*.txt'). The first item in the tuple is the
text
description presented to the user. The second item in the tuple is a
standard Windows wildcard pattern that will match files described in
the
text description.
The following parameters are ignored on Windows: clientName, dialogOptionFlags, eventProc, fileCreator, filterProc,
multiple, popupExtension, preferenceKey, previewProc, version,
wanted
AskFolder
The following
parameters are ignored on Windows: clientName, dialogOptionFlags, eventProc, filterProc,
multiple, popupExtension, preferenceKey, version, wanted
Example usage:
import EasyDialogs
# Display a message box
EasyDialogs.Message('Hello world!')
# Present a standard file-open dialog
filename = EasyDialogs.AskFileForOpen()
# Display a progress bar
bar = EasyDialogs.ProgressBar(maxval=100)
for i in range(100):
bar.inc()
del bar
Change history:
Version 46691.0 (2/15/2007)
- Fixed a bug that caused warnings with newer version of ctypes (including the
version included in Python 2.5)
- The edit box in AskString now scrolls horizontally if the entered text does
not otherwise fit
- AskFileForOpen(multiple=True) will allow multiple files to be selected and a
list of strings will be returned. If multiple is False (the default if not
specified) then only a single file can be selected and a string is returned.
This no longer seems to work on the Mac, but it's useful enough to add it to the
Windows version anyway. This change is based on a patch contributed by Waldemar Osuch.
- Made minor changes to bring inline with SVN revision 46691 for Mac
Version 1.16.0 (11/5/2004)
- Removed resource DLL, resources are now in a Python source file which
simplifies distribution of apps with py2exe
- Spelling corrections
- File open/save dialogs did not display on Windows 98
- AskString edit boxes were too short on Windows 98
- Improved display of drop down lists on Windows 98 and NT
- Made minor changes to bring inline with CVS version 1.16 for Mac
Version 1.14.0 (5/11/2004)
- Initial public release
|