本文整理汇总了Python中wxversion.ensureMinimal函数的典型用法代码示例。如果您正苦于以下问题:Python ensureMinimal函数的具体用法?Python ensureMinimal怎么用?Python ensureMinimal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ensureMinimal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
def run():
""" Run application. """
# parse options
options = _parse_opt()
# logowanie
from wxgtd.lib.logging_setup import logging_setup
logging_setup('wxgtd.log', options.debug, options.debug_sql)
# app config
from wxgtd.lib import appconfig
config = appconfig.AppConfig('wxgtd.cfg', 'wxgtd')
config.load_defaults(config.get_data_file('defaults.cfg'))
config.load()
config.debug = options.debug
# importowanie wx
try:
import wxversion
try:
wxversion.ensureMinimal("2.8")
except wxversion.AlreadyImportedError:
_LOG.warn('Wx Already Imported')
except wxversion.VersionError:
_LOG.error("WX version > 2.8 not found; avalable: %s",
wxversion.checkInstalled())
except ImportError, err:
_LOG.error('No wxversion.... (%s)' % str(err))
示例2: CheckForWx
def CheckForWx():
"""Try to import wx module and check its version"""
if 'wx' in sys.modules.keys():
return
minVersion = [2, 8, 10, 1]
try:
try:
import wxversion
except ImportError as e:
raise ImportError(e)
# wxversion.select(str(minVersion[0]) + '.' + str(minVersion[1]))
wxversion.ensureMinimal(str(minVersion[0]) + '.' + str(minVersion[1]))
import wx
version = wx.__version__
if map(int, version.split('.')) < minVersion:
raise ValueError('Your wxPython version is %s.%s.%s.%s' % tuple(version.split('.')))
except ImportError as e:
print >> sys.stderr, 'ERROR: wxGUI requires wxPython. %s' % str(e)
sys.exit(1)
except (ValueError, wxversion.VersionError) as e:
print >> sys.stderr, 'ERROR: wxGUI requires wxPython >= %d.%d.%d.%d. ' % tuple(minVersion) + \
'%s.' % (str(e))
sys.exit(1)
except locale.Error as e:
print >> sys.stderr, "Unable to set locale:", e
os.environ['LC_ALL'] = ''
示例3: init_stage2
def init_stage2(use_gui):
"""\
Initialise the remaining (non-path) parts of wxGlade (second stage)
@param use_gui: Starting wxGlade GUI
@type use_gui: Boolean
"""
common.use_gui = use_gui
if use_gui:
# ensure minimal wx version
if not hasattr(sys, 'frozen') and \
'wxversion' not in sys.modules and \
'wx' not in sys.modules:
import wxversion
wxversion.ensureMinimal("2.6")
# store current platform (None is default)
import wx
common.platform = wx.Platform
# codewrites, widgets and sizers are loaded in class main.wxGladeFrame
else:
# use_gui has to be set before importing config
import config
config.init_preferences()
common.load_code_writers()
common.load_widgets()
common.load_sizers()
示例4: check
def check(self):
try:
import wxversion
except ImportError:
raise CheckFailed("requires wxPython")
try:
_wx_ensure_failed = wxversion.AlreadyImportedError
except AttributeError:
_wx_ensure_failed = wxversion.VersionError
try:
wxversion.ensureMinimal("2.8")
except _wx_ensure_failed:
pass
try:
import wx
backend_version = wx.VERSION_STRING
except ImportError:
raise CheckFailed("requires wxPython")
# Extra version check in case wxversion lacks AlreadyImportedError;
# then VersionError might have been raised and ignored when
# there really *is* a problem with the version.
major, minor = [int(n) for n in backend_version.split(".")[:2]]
if major < 2 or (major < 3 and minor < 8):
raise CheckFailed("Requires wxPython 2.8, found %s" % backend_version)
BackendAgg.force = True
return "version %s" % backend_version
示例5: ensure
def ensure(recommended, minimal):
"""Ensures the minimal version of wxPython is installed.
- minimal: as string (eg. '2.6')"""
#wxversion
try:
import wxversion
if wxversion.checkInstalled(recommended):
wxversion.select(recommended)
else:
wxversion.ensureMinimal(minimal)
import wx
return wx
except ImportError:
sys.stdout.write(_t('Warning: python-wxversion is not installed.\n'))
#wxversion failed, import wx anyway
params = {'recommended': recommended, 'minimal': minimal}
try:
import wx
except ImportError:
message = _t('Error: wxPython %(recommended)s' \
' (or at least %(minimal)s) can not' \
' be found, but is required.'
) % params +\
'\n\n' + _t('Please (re)install it.')
sys.stderr.write(message)
if sys.platform.startswith('linux') and \
os.path.exists('/usr/bin/zenity'):
call('''zenity --error --text="%s"\n\n''' % message + \
_t("This application needs 'python-wxversion' " \
"and 'python-wxgtk%(recommended)s' " \
"(or at least 'python-wxgtk%(minimal)s')."
) % params, shell=True)
sys.exit()
#wxversion failed but wx is available, check version again
params['version'] = wx.VERSION_STRING
if wx.VERSION_STRING < minimal:
class MyApp(wx.App):
def OnInit(self):
result = wx.MessageBox(
_t("This application is known to be compatible" \
" with\nwxPython version(s) %(recommended)s" \
" (or at least %(minimal)s),\nbut you have " \
"%(version)s installed."
) % params + "\n\n" +\
_t("Please upgrade your wxPython."),
_t("wxPython Version Error"),
style=wx.ICON_ERROR)
return False
app = MyApp()
app.MainLoop()
sys.exit()
#wxversion failed, but wx is the right version anyway
return wx
示例6: CheckForWx
def CheckForWx():
"""!Try to import wx module and check its version"""
if 'wx' in sys.modules.keys():
return
minVersion = [2, 8, 1, 1]
try:
try:
import wxversion
except ImportError, e:
raise ImportError(e)
# wxversion.select(str(minVersion[0]) + '.' + str(minVersion[1]))
wxversion.ensureMinimal(str(minVersion[0]) + '.' + str(minVersion[1]))
import wx
version = wx.version().split(' ')[0]
if map(int, version.split('.')) < minVersion:
raise ValueError('Your wxPython version is %s.%s.%s.%s' % tuple(version.split('.')))
示例7: _check_environment
def _check_environment():
# Check Python version
py2_7_or_better = hasattr(sys, 'version_info') and sys.version_info >= (2,7)
py3 = hasattr(sys, 'version_info') and sys.version_info >= (3,0)
if not py2_7_or_better:
exit('This application requires Python 2.7 or later.')
if py3:
exit('This application cannot run under Python 3.x. Try Python 2.7 instead.')
# Check for dependencies
if not _running_as_bundle():
try:
import wxversion
except ImportError:
exit(
'This application requires wxPython to be installed. ' +
'Download it from http://wxpython.org/')
else:
# Check version and display dialog to user if an upgrade is needed.
# If a dialog is displayed, the application will exit automatically.
wxversion.ensureMinimal('2.8')
try:
import wx
except ImportError:
is_64bits = sys.maxsize > 2**32
if is_64bits:
python_bitness = '64-bit'
else:
python_bitness = '32-bit'
exit(
'wxPython found but couldn\'t be loaded. ' +
'Your Python is %s. Are you sure the installed wxPython is %s?' %
(python_bitness, python_bitness))
try:
import BeautifulSoup
except ImportError:
exit(
'This application requires BeautifulSoup to be installed. ' +
'Download it from http://www.crummy.com/software/BeautifulSoup/')
示例8: CheckForWx
def CheckForWx():
"""!Try to import wx module and check its version"""
if 'wx' in sys.modules.keys():
return
minVersion = [2, 8, 1, 1]
unsupportedVersion = [2, 9, 0, 0]
try:
try:
import wxversion
except ImportError, e:
raise ImportError(e)
# wxversion.select(str(minVersion[0]) + '.' + str(minVersion[1]))
wxversion.ensureMinimal(str(minVersion[0]) + '.' + str(minVersion[1]))
import wx
version = wx.version().split(' ')[0]
if map(int, version.split('.')) < minVersion:
raise ValueError('Your wxPython version is %s.%s.%s.%s' % tuple(version.split('.')))
if map(int, version.split('.')) >= unsupportedVersion:
print >> sys.stderr, 'ERROR: wxGUI does not support wxPython %s yet.' % version
sys.exit(1)
示例9: hasattr
# See LICENSE.txt for details.
"Launch the plover application."
# Python 2/3 compatibility.
from __future__ import print_function
import os
import sys
import traceback
import argparse
WXVER = '3.0'
if not hasattr(sys, 'frozen'):
import wxversion
wxversion.ensureMinimal(WXVER)
if sys.platform.startswith('darwin'):
import appnope
import wx
import plover.gui.main
import plover.oslayer.processlock
from plover.oslayer.config import CONFIG_DIR, ASSETS_DIR
from plover.config import CONFIG_FILE, Config
from plover import log
from plover import __name__ as __software_name__
from plover import __version__
def show_error(title, message):
"""Report error to the user.
示例10: hasattr
Task Coach 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. If not, see <http://www.gnu.org/licenses/>.
'''
import sys
if not hasattr(sys, "frozen"):
# These checks are only necessary in a non-frozen environment, i.e. we
# skip these checks when run from a py2exe-fied application
import wxversion
try:
wxversion.ensureMinimal("2.8-unicode", optionsRequired=True)
except:
pass
try:
import taskcoachlib
except ImportError:
sys.stderr.write('''ERROR: cannot import the library 'taskcoachlib'.
Please see http://www.taskcoach.org/faq.html for more information and
possible resolutions.''')
sys.exit(1)
def start():
from taskcoachlib import config, application
options, args = config.ApplicationOptionParser().parse_args()
app = application.Application(options, args)
示例11: Copyright
#!/usr/bin/env python2
# Part of the PsychoPy library
# Copyright (C) 2014 Jonathan Peirce
# Distributed under the terms of the GNU General Public License (GPL).
import sys, psychopy
import copy
if not hasattr(sys, 'frozen'):
import wxversion
wxversion.ensureMinimal('2.8') # because this version has agw
import wx
try:
from agw import advancedsplash as AS
except ImportError: # if it's not there locally, try the wxPython lib.
import wx.lib.agw.advancedsplash as AS
#NB keep imports to a minimum here because splash screen has not yet shown
#e.g. coder and builder are imported during app.__init__ because they take a while
from psychopy import preferences, logging#needed by splash screen for the path to resources/psychopySplash.png
from psychopy.app import connections
import sys, os, threading
# knowing if the user has admin priv is generally a good idea for security.
# not actually needed; psychopy should never need anything except normal user
# see older versions for code to detect admin (e.g., v 1.80.00)
class MenuFrame(wx.Frame):
"""A simple, empty frame with a menubar that should be the last frame to close on a mac
"""
def __init__(self, parent=None, ID=-1, app=None, title="PsychoPy2"):
示例12: visualizer
def visualizer(data):
""" Stand Alone app to analize solution
data are a dictionary with
:sol: solution
"""
# Used to guarantee to use at least Wx2.8
import wxversion
wxversion.ensureMinimal('2.8')
import matplotlib
matplotlib.use('WXAgg')
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg as Toolbar
from matplotlib.figure import Figure
import wx
import wx.xrc as xrc
class PlotPanel(wx.Panel):
""" Inspired by example "embedding_in_wx3.py"
Bare matplotlib panel
"""
def __init__(self, parent):
wx.Panel.__init__(self, parent, -1)
self.fig = Figure((3,2))
self.canvas = FigureCanvasWxAgg(self, -1, self.fig)
self.toolbar = Toolbar(self.canvas) #matplotlib toolbar
self.toolbar.Realize()
#self.toolbar.set_active([0,1])
## Now put all into a sizer
sizer = wx.BoxSizer(wx.VERTICAL)
## This way of adding to sizer allows resizing
sizer.Add(self.canvas, 1, wx.ALL | wx.EXPAND)
## Best to allow the toolbar to resize!
sizer.Add(self.toolbar, 0, wx.ALL)
self.sizer = sizer
self.SetSizer(sizer)
self.Fit()
def GetToolBar(self):
# You will need to override GetToolBar if you are using an
# unmanaged toolbar in your frame
return self.toolbar
def onEraseBackground(self, evt):
# this is supposed to prevent redraw flicker on some X servers...
pass
class InstrumentFrame(wx.Frame):
def __init__(self, title = "Visualizer GUI",
parent = None,):
## A Frame is a top-level window
wx.Frame.__init__(self, parent, wx.ID_ANY, title, size = (700,600))
self.Show(True) # Show the frame.
self.stdF = wx.Font(14, wx.FONTFAMILY_DEFAULT,
wx.FONTSTYLE_NORMAL,
wx.FONTWEIGHT_NORMAL)
self.buttonF = wx.Font(16, wx.FONTFAMILY_DEFAULT,
wx.FONTSTYLE_NORMAL,
wx.FONTWEIGHT_BOLD)
self.SetFont( self.stdF )
self.buttons = []
## Set Sizer and Automatic Layout
##- 4 boxes 1) 3d/contour
## 2) slice/animation
## 3) Open/save
## 4) parameters..
self.box = wx.FlexGridSizer(2,2)
self.box.SetFlexibleDirection(wx.BOTH)
### Info ######
### ==== ######
self.info = wx.StaticText(self, label = "blah blah")
#self.description.SetSize((300,-1))
self.box.Add(self.info, 0, wx.ALL , border = 4)
### 3d/contour ######
### ========== ######
self.contour_plot = PlotPanel(self)
bSizer = wx.BoxSizer( wx.VERTICAL )
## Slider to select the frame
self.m_slider = wx.Slider( self, wx.ID_ANY, 0,
0, 100, # Size
wx.DefaultPosition, wx.DefaultSize, wx.SL_HORIZONTAL )
#.........这里部分代码省略.........
示例13: hasattr
# (c) 2013-2014 Andreas Pflug
#
# Licensed under the Apache License,
# see LICENSE.TXT for conditions of usage
import sys
if not hasattr(sys, 'frozen'):
import wxversion
import os, platform
wxversion._EM_DEBUG=True
if platform.system() == "Darwin":
wxversion.select('2.9.4')
else:
wxversion.ensureMinimal("3.0")
if platform.system() == "Windows":
minVersion="3.0.1.1"
for iv in wxversion._find_installed():
ver=os.path.basename(iv.pathname).split('-')[1]
if ver >= minVersion:
break
if ver >= '3.0':
for f in os.listdir(iv.pathname):
if f.endswith('.egg-info'):
ver=f.split('-')[1]
if ver >= minVersion:
break
else:
raise wxversion.VersionError('wxPython minimum usable version is %s' % minVersion)
示例14:
#!/usr/bin/python
# -*- coding: iso-8859-15 -*-
import sys
try:
import wxversion; wxversion.ensureMinimal("2.8")
import wx.aui
except ImportError:
print "Can't laod wx.aui module, please check that you have installed wxpython > 2.8 and taht it is your default install"
sys.exit(1)
#used for about dialog
from wx.lib.wordwrap import wordwrap
#used for ipython GUI objects
from IPython.gui.wx.ipython_view import IPShellWidget
from IPython.gui.wx.ipython_history import IPythonHistoryPanel
#used to invoke ipython1 wx implementation
### FIXME ### temporary disabled due to interference with 'show_in_pager' hook
is_sync_frontend_ok = False
try:
from IPython.frontend.wx.ipythonx import IPythonXController
except ImportError:
is_sync_frontend_ok = False
#used to create options.conf file in user directory
from IPython.ipapi import get
__version__ = 0.10
__version_str__ = "0.10"
示例15: StringIO
#!/usr/bin/env python
import sys
if sys.platform.startswith('win') and sys.executable.lower().endswith('pythonw.exe'):
from cStringIO import StringIO
sys.stdout = StringIO()
MIN_WX_VERSION = '2.5.4.1'
GET_WXPYTHON = 'Get it from http://www.wxpython.org!'
try:
import wxversion
if sys.modules.has_key('wx') or sys.modules.has_key('wxPython'):
pass #probably not the first call to this module: wxPython already loaded
else:
wxversion.ensureMinimal(MIN_WX_VERSION)
except ImportError:
#the old fashioned way as not everyone seems to have wxversion installed
try:
import wx
if wx.VERSION_STRING < MIN_WX_VERSION:
print 'You need to upgrade wxPython to v%s (or higher) to run SPE.'%MIN_WX_VERSION
print GET_WXPYTHON
sys.exit()
except ImportError:
print "Error: SPE requires wxPython, which doesn't seem to be installed."
print GET_WXPYTHON
sys.exit()
print 'Warning: the package python-wxversion was not found, please install it!'
print 'SPE will continue anyway, but not all features (such as wxGlade) might work.'