Home | Trees | Index | Help |
|
---|
Module wxversion |
|
If you have more than one version of wxPython installed this module
allows your application to choose which version of wxPython will be
imported when it does 'import wx'. The main function of this module
is select
and you use it like this:
import wxversion wxversion.select('2.4') import wx
Or additional build options can also be selected, although they will not be required if they are not installed, like this:
import wxversion wxversion.select('2.5.3-unicode') import wx
Or you can require an exact match on the build options like this:
import wxversion wxversion.select('2.5.3-unicode', optionsRequired=True) import wx
Finally you can also specify a collection of versions that are allowed by your application, like this:
import wxversion wxversion.select(['2.5.4', '2.5.5', '2.6']) import wx
Of course the default wxPython version can also be controlled by setting PYTHONPATH or by editing the wx.pth path configuration file, but using wxversion will allow an application to manage the version selection itself rather than depend on the user to setup the environment correctly.
It works by searching the sys.path for directories matching wx-* and then comparing them to what was passed to the select function. If a match is found then that path is inserted into sys.path.
NOTE: If you are making a 'bundle' of your application with a tool like py2exe then you should not use the wxversion module since it looks at the filesystem for the directories on sys.path, it will fail in a bundled environment. Instead you should simply ensure that the version of wxPython that you want is found by default on the sys.path when making the bundled version by setting PYTHONPATH. Then that version will be included in your bundle and your app will work as expected. Py2exe and the others usually have a way to tell at runtime if they are running from a bundle or running raw, so you can check that and only use wxversion if needed. For example, for py2exe:
if not hasattr(sys, 'frozen'): import wxversion wxversion.select('2.5') import wx
More documentation on wxversion and multi-version installs can be found at: http://wiki.wxpython.org/index.cgi/MultiVersionInstalls
Exceptions | |
---|---|
VersionError |
Function Summary | |
---|---|
Check if there is a version of wxPython installed that matches one of the versions given. | |
Checks to see if the default version of wxPython is greater-than or equal to minVersion . | |
Returns a list of strings representing the installed wxPython versions that are found on the system. | |
Search for a wxPython installation that matches version. |
Variable Summary | |
---|---|
str |
UPDATE_URL = 'http://wxPython.org/'
|
Function Details |
---|
checkInstalled(versions, optionsRequired=False)Check if there is a version of wxPython installed that matches one
of the versions given. Returns True if so, False if not. This
can be used to determine if calling |
ensureMinimal(minVersion, optionsRequired=False)Checks to see if the default version of wxPython is greater-than
or equal to |
getInstalled()Returns a list of strings representing the installed wxPython versions that are found on the system. |
select(versions, optionsRequired=False)Search for a wxPython installation that matches version. If one is found then sys.path is modified so that version will be imported with a 'import wx', otherwise a VersionError exception is raised. This funciton should only be caled once at the begining of the application before wxPython is imported.
|
Variable Details |
---|
UPDATE_URL
|
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1.20050511.rpd on Thu Mar 22 12:08:40 2007 | http://epydoc.sf.net |