Python wx.VERSION Examples

The following are 16 code examples of wx.VERSION(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module wx , or try the search function .
Example #1
Source File: _requires.py    From admin4 with Apache License 2.0 6 votes vote down vote up
def GetPrerequisites(info=False):
  try:
    import ldap
    if ldap.__version__ < "2.4":
      if info:
        print "ldap too old"
      return None
    import wx
    if wx.VERSION < (2,9):
      if info:
        print "wxPython too old"
      return None
    
    return "ldap"
  except:
    if info:
      print "ldap missing"
    pass
  return None 
Example #2
Source File: SearchResultPanel.py    From OpenPLC_Editor with GNU General Public License v3.0 6 votes vote down vote up
def _init_ctrls(self, prnt):
        self.HeaderLabel = wx.StaticText(id=ID_SEARCHRESULTPANELHEADERLABEL,
                                         name='HeaderLabel', parent=self,
                                         pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)

        search_results_tree_style = CT.TR_HAS_BUTTONS | CT.TR_NO_LINES | CT.TR_HAS_VARIABLE_ROW_HEIGHT
        self.SearchResultsTree = CT.CustomTreeCtrl(id=ID_SEARCHRESULTPANELSEARCHRESULTSTREE,
                                                   name="SearchResultsTree", parent=self,
                                                   pos=wx.Point(0, 0), style=search_results_tree_style)
        if wx.VERSION >= (2, 8, 11):
            self.SearchResultsTree.SetAGWWindowStyleFlag(search_results_tree_style)
        self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnSearchResultsTreeItemActivated,
                  id=ID_SEARCHRESULTPANELSEARCHRESULTSTREE)

        self.ResetButton = wx.lib.buttons.GenBitmapButton(
            self, bitmap=GetBitmap("reset"),
            size=wx.Size(28, 28), style=wx.NO_BORDER)
        self.ResetButton.SetToolTipString(_("Reset search result"))
        self.Bind(wx.EVT_BUTTON, self.OnResetButton, self.ResetButton)

        self._init_sizers() 
Example #3
Source File: hypercube.py    From spectral with MIT License 5 votes vote down vote up
def on_resize(self, event):
        """Process the resize event."""

        if wx.VERSION >= (2, 9) or self.canvas.GetContext():
            self.canvas.SetCurrent(self.canvas.context)
            self.Show()
            size = self.canvas.GetClientSize()
            self.resize(size.width, size.height)
            self.canvas.Refresh(False)
        event.Skip() 
Example #4
Source File: ndwindow.py    From spectral with MIT License 5 votes vote down vote up
def on_resize(self, event):
        '''Process the resize event.'''

        # For wx versions 2.9.x, GLCanvas.GetContext() always returns None,
        # whereas 2.8.x will return the context so test for both versions.

        if wx.VERSION >= (2, 9) or self.canvas.GetContext():
            self.canvas.SetCurrent(self.canvas.context)
            # Make sure the frame is shown before calling SetCurrent.
            self.Show()
            size = event.GetSize()
            self.resize(size.width, size.height)
            self.canvas.Refresh(False)
        event.Skip() 
Example #5
Source File: main.py    From wxGlade with MIT License 5 votes vote down vote up
def start_page(self, name):
        # create a ScrolledWindow and a Panel; with only ScrolledWindow, scrolling on gtk 3 does not work
        scrolled = wx.ScrolledWindow( self.notebook, name=name)
        panel = wx.Panel(scrolled, name="%s properties"%name)
        if wx.VERSION[0]<3:
            panel.SetBackgroundColour(scrolled.GetBackgroundColour())
        return panel 
Example #6
Source File: misc.py    From wxGlade with MIT License 5 votes vote down vote up
def check_wx_version_at_least(major, minor=0, release=0, revision=0):
    "returns True if the current wxPython version is at least major.minor.release"
    return wx.VERSION[:-1] >= (major, minor, release, revision)



########################################################################################################################
# error/warning/info messages 
Example #7
Source File: preferencesdialog.py    From wxGlade with MIT License 5 votes vote down vote up
def check_accessibility(self):
        # add a warning if not NVDA etc. compatible
        import sys, platform, compat
        if sys.platform!="win32" or not compat.IS_PHOENIX: return
        if platform.architecture()[0] != "32bit": return
        version = wx.VERSION[:3]
        if version < (4,0,4) or version > (4,0,7): return
        panel = self.sizer_accessibility.GetContainingWindow()
        text = wx.StaticText(panel, label="Please be warned that your version of wxPython\n"
                                          "probably does not support screen readers very well.\n"
                                          "This is a problem with wxPython versions\n"
                                          "4.0.4 to 4.0.7 on 32 bit Python on Windows.\n"
                                          "A workaround is to set the name argument of CheckBox.")
        self.sizer_accessibility.Insert(0, text, 0, wx.ALL, 10)
        self.sizer_accessibility.Layout() 
Example #8
Source File: edit_sizers.py    From wxGlade with MIT License 5 votes vote down vote up
def __init__(self, parent, rows, cols, vgap, hgap):
        wx.BoxSizer.__init__(self, wx.VERTICAL)
        self.parent = parent  # EditGridSizer or derived class
        self._create(rows, cols, vgap, hgap)
        wx.BoxSizer.Add(self, self.parent._btn, 0, wx.EXPAND)
        wx.BoxSizer.Add(self, self._grid, 1, wx.EXPAND)
        if wx.VERSION[:2] < (3,0):
            self._growable_rows = set()
            self._growable_cols = set() 
Example #9
Source File: ConfigEditor.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
def AppendMenu(parent, help, id, kind, text):
    if wx.VERSION >= (2, 6, 0):
        parent.Append(help=help, id=id, kind=kind, text=text)
    else:
        parent.Append(helpString=help, id=id, kind=kind, item=text) 
Example #10
Source File: Beremiz.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
def CreateApplication(self):

        BeremizAppType = wx.App if wx.VERSION >= (3, 0, 0) else wx.PySimpleApp

        class BeremizApp(BeremizAppType):
            def OnInit(_self):  # pylint: disable=no-self-argument
                self.ShowSplashScreen()
                return True

        self.app = BeremizApp(redirect=self.debug)
        self.app.SetAppName('beremiz')
        if wx.VERSION < (3, 0, 0):
            wx.InitAllImageHandlers() 
Example #11
Source File: PLCOpenEditor.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
def OnInit(self):
        self.SetAppName('plcopeneditor')
        self.ParseCommandLine()
        InstallLocalRessources(beremiz_dir)
        if wx.VERSION < (3, 0, 0):
            wx.InitAllImageHandlers()
        util.ExceptionHandler.AddExceptHook(version.app_version)
        self.frame = PLCOpenEditor(None, fileOpen=self.fileOpen)
        return True 
Example #12
Source File: geometry_viewer.py    From dials with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def add_goniometer_controls(self, goniometer):
        from wx.lib.agw import floatspin

        self.distance_ctrl = floatspin.FloatSpin(parent=self, increment=1, digits=2)
        self.distance_ctrl.SetValue(self.settings.detector_distance)
        self.distance_ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None)
        if wx.VERSION >= (2, 9):  # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa
            self.distance_ctrl.SetBackgroundColour(self.GetBackgroundColour())
        box = wx.BoxSizer(wx.HORIZONTAL)
        self.panel_sizer.Add(box)
        label = wx.StaticText(self, -1, "Detector distance")
        box.Add(self.distance_ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
        box.Add(label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
        self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, self.distance_ctrl)

        self.rotation_angle_ctrls = []
        if isinstance(goniometer, MultiAxisGoniometer):
            names = goniometer.get_names()
            axes = goniometer.get_axes()
            angles = goniometer.get_angles()
            for name, axis, angle in zip(names, axes, angles):
                ctrl = floatspin.FloatSpin(parent=self, increment=1, digits=3)
                ctrl.SetValue(angle)
                ctrl.Bind(wx.EVT_SET_FOCUS, lambda evt: None)
                if wx.VERSION >= (2, 9):  # XXX FloatSpin bug in 2.9.2/wxOSX_Cocoa
                    ctrl.SetBackgroundColour(self.GetBackgroundColour())
                box = wx.BoxSizer(wx.HORIZONTAL)
                self.panel_sizer.Add(box)
                label = wx.StaticText(self, -1, "%s angle" % name)
                box.Add(ctrl, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
                box.Add(label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 5)
                self.Bind(floatspin.EVT_FLOATSPIN, self.OnChangeSettings, ctrl)
                self.rotation_angle_ctrls.append(ctrl) 
Example #13
Source File: wx_viewer.py    From dials with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def OnSize(self, event=None):
        self.w, self.h = self.GetClientSize()
        if self.IsShownOnScreen():
            if self.context is not None:
                if wx.VERSION[0] != 3:
                    self.SetCurrent(self.context)
                else:
                    self.SetCurrent()
            gl.glViewport(0, 0, self.w, self.h) 
Example #14
Source File: commondialogs.py    From CANFestivino with GNU Lesser General Public License v2.1 4 votes vote down vote up
def _init_ctrls(self, prnt):
        wx.Dialog.__init__(self, id=ID_DCFENTRYVALUESDIALOG,
              name='DCFEntryValuesDialog', parent=prnt, pos=wx.Point(376, 223),
              size=wx.Size(400, 300), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER,
              title=_('Edit DCF Entry Values'))
        self.SetClientSize(wx.Size(400, 300))

        self.staticText1 = wx.StaticText(id=ID_VARIABLEEDITORPANELSTATICTEXT1,
              label=_('Entry Values:'), name='staticText1', parent=self,
              pos=wx.Point(0, 0), size=wx.Size(95, 17), style=0)

        self.ValuesGrid = wx.grid.Grid(id=ID_DCFENTRYVALUESDIALOGVALUESGRID,
              name='ValuesGrid', parent=self, pos=wx.Point(0, 0), 
              size=wx.Size(0, 150), style=wx.VSCROLL)
        self.ValuesGrid.SetFont(wx.Font(12, 77, wx.NORMAL, wx.NORMAL, False,
              'Sans'))
        self.ValuesGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL,
              False, 'Sans'))
        self.ValuesGrid.SetRowLabelSize(0)
        self.ValuesGrid.SetSelectionBackground(wx.WHITE)
        self.ValuesGrid.SetSelectionForeground(wx.BLACK)
        if wx.VERSION >= (2, 6, 0):
            self.ValuesGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnValuesGridCellChange)
            self.ValuesGrid.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnValuesGridSelectCell)
        else:
            wx.grid.EVT_GRID_CELL_CHANGE(self.ValuesGrid, self.OnValuesGridCellChange)
            wx.grid.EVT_GRID_SELECT_CELL(self.ValuesGrid, self.OnValuesGridSelectCell)
        
        self.AddButton = wx.Button(id=ID_DCFENTRYVALUESDIALOGADDBUTTON, label=_('Add'),
              name='AddButton', parent=self, pos=wx.Point(0, 0),
              size=wx.Size(72, 32), style=0)
        self.Bind(wx.EVT_BUTTON, self.OnAddButton, id=ID_DCFENTRYVALUESDIALOGADDBUTTON)

        self.DeleteButton = wx.Button(id=ID_DCFENTRYVALUESDIALOGDELETEBUTTON, label=_('Delete'),
              name='DeleteButton', parent=self, pos=wx.Point(0, 0),
              size=wx.Size(72, 32), style=0)
        self.Bind(wx.EVT_BUTTON, self.OnDeleteButton, id=ID_DCFENTRYVALUESDIALOGDELETEBUTTON)

        self.UpButton = wx.Button(id=ID_DCFENTRYVALUESDIALOGUPBUTTON, label='^',
              name='UpButton', parent=self, pos=wx.Point(0, 0),
              size=wx.Size(32, 32), style=0)
        self.Bind(wx.EVT_BUTTON, self.OnUpButton, id=ID_DCFENTRYVALUESDIALOGUPBUTTON)

        self.DownButton = wx.Button(id=ID_DCFENTRYVALUESDIALOGDOWNBUTTON, label='v',
              name='DownButton', parent=self, pos=wx.Point(0, 0),
              size=wx.Size(32, 32), style=0)
        self.Bind(wx.EVT_BUTTON, self.OnDownButton, id=ID_DCFENTRYVALUESDIALOGDOWNBUTTON)

        self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
        
        self._init_sizers() 
Example #15
Source File: main.py    From admin4 with Apache License 2.0 4 votes vote down vote up
def main(argv):
  adm.app = app
  adm.loaddir=os.path.dirname(os.path.abspath(argv[0]))
  SetLoaddir(adm.loaddir)


  _dn, an=os.path.split(argv[0])
  dot=an.rfind('.')
  if dot > 0:
    adm.appname=an[0:dot]
  else:
    adm.appname=an

  sys.excepthook=LoggerExceptionHook
  if wx.VERSION < (2,9):
    logger.debug("Using old wxPython version %s", wx.version())
  modules=[]

  if sys.platform == "darwin":    macOpt="p"
  else:                           macOpt=""
  opts, args = getopt.getopt(argv[1:], "m:n:%s" % macOpt, ["modules=", "name="])
  for opt in opts:
    if opt[0] in ['-m', '--modules']:
      modules = map(lambda x: "mod%s" % x.capitalize(), opt[1].split(','))
    elif opt[0] in ['-n', '--name']:
      adm.appname=opt[1]
    elif opt[0] == '-p':
      pass
  
  app.SetAppName(adm.appname)
  adm.config=config.Config(adm.appname)
  frame.LoggingDialog.Init()

  adm.appTitle=adm.config.Read("Title", adm.appname.title())
  if wx.VERSION > (2,9):
    app.SetAppDisplayName(adm.appTitle)
    from version import vendor, vendorDisplay
    app.SetVendorName(vendor)
    app.SetVendorDisplayName(vendorDisplay)

  
#  if not modules:
#    modules=adm.config.Read("Modules", [])
  if not modules:
    dot=adm.appname.find('-')
    if dot>0:
      modules=["mod" + adm.appname[:dot].capitalize()]

  loadModules(modules)
  xmlres.init(adm.loaddir)

  adm.mainframe=frame.DetailFrame(None, adm.appTitle, args)
  app.SetTopWindow(adm.mainframe)

  for panelclass in adm.getAllPreferencePanelClasses():
    if hasattr(panelclass, "Init"):
      panelclass.Init()

  adm.mainframe.Show()

  app.MainLoop() 
Example #16
Source File: DebugVariableGraphicViewer.py    From OpenPLC_Editor with GNU General Public License v3.0 4 votes vote down vote up
def draw(self, drawDC=None):
        """
        Render the figure.
        """
        # Render figure using agg
        FigureCanvasAgg.draw(self)

        # Get bitmap of figure rendered
        self.bitmap = _convert_agg_to_wx_bitmap(self.get_renderer(), None)
        if wx.VERSION < (3, 0, 0):
            self.bitmap.UseAlpha()

        # Create DC for rendering graphics in bitmap
        destDC = wx.MemoryDC()
        destDC.SelectObject(self.bitmap)

        # Get Graphics Context for DC, for anti-aliased and transparent
        # rendering
        destGC = wx.GCDC(destDC)

        destGC.BeginDrawing()

        # Get canvas size and figure bounding box in canvas
        width, height = self.GetSize()
        bbox = self.GetAxesBoundingBox()

        # If highlight to display is resize, draw thick grey line at bottom
        # side of canvas
        if self.Highlight == HIGHLIGHT_RESIZE:
            destGC.SetPen(HIGHLIGHT['RESIZE_PEN'])
            destGC.SetBrush(HIGHLIGHT['RESIZE_BRUSH'])
            destGC.DrawRectangle(0, height - 5, width, 5)

        # If highlight to display is merging graph, draw 50% transparent blue
        # rectangle on left or right part of figure depending on highlight type
        elif self.Highlight in [HIGHLIGHT_LEFT, HIGHLIGHT_RIGHT]:
            destGC.SetPen(HIGHLIGHT['DROP_PEN'])
            destGC.SetBrush(HIGHLIGHT['DROP_BRUSH'])

            x_offset = (bbox.width // 2
                        if self.Highlight == HIGHLIGHT_RIGHT
                        else 0)
            destGC.DrawRectangle(bbox.x + x_offset, bbox.y,
                                 bbox.width // 2, bbox.height)

        # Draw other Viewer common elements
        self.DrawCommonElements(destGC, self.GetButtons())

        destGC.EndDrawing()

        self._isDrawn = True
        self.gui_repaint(drawDC=drawDC)