The Artima Developer Community
Sponsored Link

Python Buzz Forum
Using wxPython 2.4.x and 2.5.x simultaneously

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Kevin Altis

Posts: 66
Nickname: altis
Registered: Aug, 2003

Kevin Altis is the lead developer for PythonCard
Using wxPython 2.4.x and 2.5.x simultaneously Posted: Aug 20, 2004 10:17 AM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Kevin Altis.
Original Post: Using wxPython 2.4.x and 2.5.x simultaneously
Feed Title: Kevin Altis' Weblog
Feed URL: http://altis.pycs.net/rss.xml
Feed Description: Python, Open Source, PythonCard
Latest Python Buzz Posts
Latest Python Buzz Posts by Kevin Altis
Latest Posts From Kevin Altis' Weblog

Advertisement

How to live on the edge with wxPython and not get cut (i.e. using wxPython 2.4.x and 2.5.x simultaneously).

I used this trick during the initial wxPython 2.5.1.5 release on Windows and I'm sure it works, as long as you know that the application you want to run is consistent about its use of wxPython packages. The old wxPython package was wxPython.wx so typically you would see people using it as:

from wxPython.wx import *

or

from wxPython import wx

There was an experimental package in later 2.4.x releases called wx, so if you look in site-packages you'll see wx and wxPython directories. There was a magical set of import statements that imported all the wxPython.wx stuff and did namespace manipulation for the wx package in anticipation of the new wx package that would be adopted with wxPython 2.5.x and later.

As of wxPython 2.5.x the real package is wx and now the wxPython package does the magical imports and namespace manipulation to provide backward compatability for code that still uses the old imports form above. Newer packages designed to work with wxPython 2.5.x and later use imports of the form:

import wx

or if you still believe namespace collisions will never happen to you

from wx import *

So, what's this got to do with living in both worlds? If you have wxPython 2.4.2.4 installed, then go into your site-packages directory and rename the wx dir to wx24 and the wxPython dir to wxPython24. Now install wxPython 2.5.2.7. Rename the wxPython dir to wxPython25 and then rename the wxPython24 dir to wxPython. Voila, now you can live in both worlds. PythonCard will never import from wxPython.wx so there won't be a conflict between 2.4.2.4 and 2.5.2.7 libraries and a package like Boa will always be importing from wxPython.wx so it won't ever try and get something from the 2.5.2.7 wx package.

If you want to test this, simply rename the wx package back to wx25 and run your code that requires wxPython 2.4.x. If anything ever tries to import from wx then an exception will be thrown. Similarly, you can test that code that wants 2.5.x doesn't ever import from wxPython.wx by renaming the wxPython dir back to wxPython24.

I never tested this on Linux and the process might be more complicated if the underlying wxGTK libs don't live under the wx and wxPython dirs, but it works like a champ on Windows. If you are running Mac OS X, you simply shouldn't run wxPython 2.4.x, wxPython 2.5.2.7 on Mac OS X is so much better, so just upgrade!

Read: Using wxPython 2.4.x and 2.5.x simultaneously

Topic: Running Jails Previous Topic   Next Topic Topic: Corvids:

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use