Version checking

Is this the accepted/correct way to check if one is on wxPython 2.4 or 2.5/2.6?

if int(wx.__version__[2]) >= 5:

Best regards
Werner

O.K. this is a bit more complex it seems as below won't work on 2.4.

What I am trying to do is move matplotlib backend to the 2.5 namespace. John Hunter would like to keep the modules compatible with wxPython 2.4.

As my first go doesn't work I do it now before import, i.e.:

try:
    import wx.__version__ as version
    wxVersion = int(version[2])
    from wxPython.wx import *
    del version
except:
    import wxPython.__version__ as version
    wxVersion = int(version[2])
    import wx
    del version

and then do this

if wxVersion >= 5:

Would this be o.k. or is there a nicer/more acceptable way of doing this.

Best regards
Werner

Werner F. Bruhin wrote:

···

Is this the accepted/correct way to check if one is on wxPython 2.4 or 2.5/2.6?

if int(wx.__version__[2]) >= 5:

Best regards
Werner

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

use wx.VERSION_STRING

for example:

ver = wx.VERSION_STRING

if ver > '2.4': ....
or
if ver< '2.5.5': ....

you can even look for specific versions :wink: like in:
if ver.startswith('2.5.5.0'): ....

Peter.

···

On Mon, 11 Apr 2005 11:31:15 +0300, Werner F. Bruhin <werner.bruhin@free.fr> wrote:

Is this the accepted/correct way to check if one is on wxPython 2.4 or 2.5/2.6?

if int(wx.__version__[2]) >= 5:

Thanks Andrea and Peter,

If one would remember these simple things :-[

See you
Werner

Peter Damoc wrote:

···

On Mon, 11 Apr 2005 11:31:15 +0300, Werner F. Bruhin > <werner.bruhin@free.fr> wrote:

Is this the accepted/correct way to check if one is on wxPython 2.4 or 2.5/2.6?

if int(wx.__version__[2]) >= 5:

use wx.VERSION_STRING

for example:

ver = wx.VERSION_STRING

if ver > '2.4': ....
or
if ver< '2.5.5': ....

you can even look for specific versions :wink: like in:
if ver.startswith('2.5.5.0'): ....

Peter.

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Werner F. Bruhin wrote:

O.K. this is a bit more complex it seems as below won't work on 2.4.

What I am trying to do is move matplotlib backend to the 2.5 namespace. John Hunter would like to keep the modules compatible with wxPython 2.4.

2.4 implements the wx namespace as well. 2.4 uses the flat namespace natively, but implements a mapping to the new namespace, while 2.5.* uses the wx namespace natively, an implements a mapping to the old one.

So, you should be able to use the new namespace with 2.4. and 2.5 There are other differences, so it might make sense to have version specific code anyway.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Hi Chris,

Chris Barker wrote:

Werner F. Bruhin wrote:

O.K. this is a bit more complex it seems as below won't work on 2.4.

What I am trying to do is move matplotlib backend to the 2.5 namespace. John Hunter would like to keep the modules compatible with wxPython 2.4.

2.4 implements the wx namespace as well. 2.4 uses the flat namespace natively, but implements a mapping to the new namespace, while 2.5.* uses the wx namespace natively, an implements a mapping to the old one.

So, you should be able to use the new namespace with 2.4. and 2.5 There are other differences, so it might make sense to have version specific code anyway.

I was aware of that but initially couldn't find how to check the version, but Andrea and Peter fixed me up on this.

For the matplotlib stuff the only conditional code was the "self.bind" stuff and the "printer.GetLastError()" which I can't find a solution for in 2.4.

John is trying the updated stuff out (see matplotlib newsgroup), he noted a difference for figsize which is not respected in the updated stuff but I don't think I touched that.

See you
Werner

···

-Chris

I've played with 2.4+2.5 support for an app I made before moving away from 2.4
attached is a script I've used to minimize the impact on the code. (only one, easy commentable "import wxfix" statement)

Maybe it can help you somehow :wink:

Peter

wxfix.py (1.47 KB)

···

On Tue, 12 Apr 2005 12:39:59 +0300, Werner F. Bruhin <werner.bruhin@free.fr> wrote:

Hi Chris,

Chris Barker wrote:

Werner F. Bruhin wrote:

O.K. this is a bit more complex it seems as below won't work on 2.4.

What I am trying to do is move matplotlib backend to the 2.5 namespace. John Hunter would like to keep the modules compatible with wxPython 2.4.

2.4 implements the wx namespace as well. 2.4 uses the flat namespace natively, but implements a mapping to the new namespace, while 2.5.* uses the wx namespace natively, an implements a mapping to the old one.

So, you should be able to use the new namespace with 2.4. and 2.5 There are other differences, so it might make sense to have version specific code anyway.

I was aware of that but initially couldn't find how to check the version, but Andrea and Peter fixed me up on this.

For the matplotlib stuff the only conditional code was the "self.bind" stuff and the "printer.GetLastError()" which I can't find a solution for in 2.4.