itrade_wxversion.py :  » Business-Application » iTrade » itrade » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Business Application » iTrade 
iTrade » itrade » itrade_wxversion.py
#!/usr/bin/env python
# ============================================================================
# Project Name : iTrade
# Module Name  : itrade_wxversion.py
#
# Description: Manage wxVersion
#
# The Original Code is iTrade code (http://itrade.sourceforge.net).
#
# The Initial Developer of the Original Code is  Gilles Dumortier.
#
# Portions created by the Initial Developer are Copyright (C) 2004-2008 the
# Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see http://www.gnu.org/licenses/gpl.html
#
# History       Rev   Description
# 2006-01-01    dgil  Wrote it from scratch
# 2006-11-18    dgil  Experiment unicode version of wxPython
# 2007-01-21    dgil  Switch definitively to unicode version of wxPython
# ============================================================================

# ============================================================================
# wxPython version required : 2.8.x UNICODE
# ============================================================================

WXVERSION_MAJOR     = 2
WXVERSION_MINOR1    = 8
WXVERSION_MINOR2    = 8

# ============================================================================
# Imports
# ============================================================================

# python system
import re

# wxPython system
import wxversion

# iTrade system
from itrade_config import main_is_frozen,verbose
from itrade_local import message,setLang

# ============================================================================
# resolve_wxversion
# ============================================================================

def resolve_wxversion():
    patt = "%d\.%d[0-9\-\.A-Za-z]*-unicode"
    patts = "-unicode"

    versions = wxversion.getInstalled()
    if verbose:
        print 'wxPython Installed :',versions

    # need to select the more recent one with 'unicode'
    vSelected = None
    vSelectedMsg = ''
    for eachVersion in versions:
        for min in range(WXVERSION_MINOR1,WXVERSION_MINOR2+1):
            m = re.search( patt % (WXVERSION_MAJOR,min), eachVersion)
            if m:
                if min == WXVERSION_MINOR2:
                    vSelectedMsg = ''
                else:
                    vSelectedMsg = ' (deprecated version - think to update)'
                vSelected = eachVersion
                break
        if m:
            break

    if vSelected:
        print 'wxPython Selected  :',vSelected,vSelectedMsg
        wxversion.select(vSelected)
        return

    # no compatible version :-( : try to select any release
    bUnicode = False
    for eachVersion in versions:
        m = re.search(patts, eachVersion)
        if m:
            print 'wxPython Selected  :',eachVersion
            wxversion.select(eachVersion)
            bUnicode = True
            break

    if not bUnicode:
        # only ansi release :-( => use US lang
        setLang('us')

    import sys, wx, webbrowser
    app = wx.PySimpleApp()
    wx.MessageBox(message('wxversion_msg') % (WXVERSION_MAJOR,WXVERSION_MINOR2), message('wxversion_title'))
    app.MainLoop()
    webbrowser.open("http://wxpython.org/")
    sys.exit()

# ============================================================================
# During import
# ============================================================================

if not main_is_frozen():
    resolve_wxversion()

# ============================================================================
# That's all folks !
# ============================================================================
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.