commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnue] r9606 - trunk/gnue-forms/src/uidrivers/wx26


From: johannes
Subject: [gnue] r9606 - trunk/gnue-forms/src/uidrivers/wx26
Date: Wed, 23 May 2007 02:20:49 -0500 (CDT)

Author: johannes
Date: 2007-05-23 02:20:48 -0500 (Wed, 23 May 2007)
New Revision: 9606

Modified:
   trunk/gnue-forms/src/uidrivers/wx26/UIdriver.py
Log:
Require wx for frozen environment on OS X since we have a 
semi-standalone application there


Modified: trunk/gnue-forms/src/uidrivers/wx26/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/UIdriver.py     2007-05-22 16:00:16 UTC 
(rev 9605)
+++ trunk/gnue-forms/src/uidrivers/wx26/UIdriver.py     2007-05-23 07:20:48 UTC 
(rev 9606)
@@ -23,20 +23,26 @@
 
 import sys
 import os.path
+
 from gnue.forms.uidrivers._base import Exceptions
 from gnue.forms.uidrivers._base.UIdriver import GFUserInterfaceBase
 
 try:
-  if not hasattr(sys, 'frozen'):
-    import wxversion
     if sys.platform == 'darwin':
-        wxversion.ensureMinimal('2.8')
+        minimal = '2.8'
     else:
-        wxversion.ensureMinimal('2.6')
+        minimal = '2.6'
 
+    # On Mac OS X we provide GNUe Forms as semi-standalone application.  Since
+    # sys.frozen is set there and the default version installed on OS X 10.3+
+    # is wx 2.5 we have to require 2.8 even if sys.frozen is set.
+    if not hasattr(sys, 'frozen') or sys.platform == 'darwin':
+        import wxversion
+        wxversion.ensureMinimal(minimal)
+
 except ImportError:
-  raise Exceptions.DriverNotSupported, \
-      _("This GNUe-Forms UI Driver requires at least wx 2.6.")
+    raise Exceptions.DriverNotSupported, \
+        _("This GNUe-Forms UI Driver requires at least wx %s.") % minimal
 
 import wx.lib.colourdb
 
@@ -49,148 +55,151 @@
 # =============================================================================
 
 class GFUserInterface (GFUserInterfaceBase):
-  """
-  An implementation of the common GUI toolkit interface using wx 2.6+.
+    """
+    An implementation of the common GUI toolkit interface using wx 2.6+.
 
-  @cvar __rearrange_boxes__: if True the bounding boxes of widgets will be
-       checked.  Additionally all widgets having a position within a box-tag
-       will get a child of that box (in the xml-object-tree).
-  """
+    @cvar __rearrange_boxes__: if True the bounding boxes of widgets will be
+         checked.  Additionally all widgets having a position within a box-tag
+         will get a child of that box (in the xml-object-tree).
+    """
 
-  __rearrange_boxes__ = True
+    __rearrange_boxes__ = True
 
-  # ---------------------------------------------------------------------------
-  # Constructor
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Constructor
+    # -------------------------------------------------------------------------
 
-  def __init__(self, eventHandler, name="Undefined", disableSplash=None,
-          parentContainer=None, moduleName=None):
+    def __init__(self, eventHandler, name="Undefined", disableSplash=None,
+            parentContainer=None, moduleName=None):
 
-      GFUserInterfaceBase.__init__(self, eventHandler, name,
-              disableSplash, parentContainer, moduleName)
+        GFUserInterfaceBase.__init__(self, eventHandler, name,
+                disableSplash, parentContainer, moduleName)
 
-      self.name = "wx 2.6"
-      self.app  = wx.GetApp () or wx.App ()
-      wx.InitAllImageHandlers()
-      wx.lib.colourdb.updateColourDB()
+        self.name = "wx 2.6"
+        self.app  = wx.GetApp() or wx.App()
+        wx.InitAllImageHandlers()
+        wx.lib.colourdb.updateColourDB()
 
-      (self.best_sizes, self.cellWidth, self.cellHeight) = self.__getSizes ()
+        (self.best_sizes, self.cellWidth, self.cellHeight) = self.__getSizes()
 
-      self.textWidth  = self.widgetWidth  = self.cellWidth
-      self.textHeight = self.widgetHeight = self.cellHeight
+        self.textWidth  = self.widgetWidth  = self.cellWidth
+        self.textHeight = self.widgetHeight = self.cellHeight
 
-      if not self._disableSplash:
-          self.__splash = UISplashScreen.SplashScreen ()
-          self.__splash.Show ()
-      else:
-          self.__splash = None
+        if not self._disableSplash:
+            self.__splash = UISplashScreen.SplashScreen()
+            self.__splash.Show()
+        else:
+            self.__splash = None
 
 
-  # ---------------------------------------------------------------------------
-  # Get the widget sizes and the dimension of a form cell
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Get the widget sizes and the dimension of a form cell
+    # -------------------------------------------------------------------------
 
-  def __getSizes (self):
+    def __getSizes(self):
 
-    frame  = wx.Frame (None)
-    result = {}
+        frame  = wx.Frame(None)
+        result = {}
 
-    try:
-      # First of all find out the preferred size of all widgets needed
-      text = wx.TextCtrl (frame, wx.ID_ANY)
-      result['default'] = text.GetBestSize()
+        try:
+        # First of all find out the preferred size of all widgets needed
+            text = wx.TextCtrl(frame, wx.ID_ANY)
+            result['default'] = text.GetBestSize()
 
-      combo = wx.ComboBox (frame, wx.ID_ANY)
-      result['dropdown'] = combo.GetBestSize()
+            combo = wx.ComboBox(frame, wx.ID_ANY)
+            result['dropdown'] = combo.GetBestSize()
 
-      label = wx.StaticText (frame, wx.ID_ANY)
-      result['label'] = label.GetBestSize()
+            label = wx.StaticText(frame, wx.ID_ANY)
+            result['label'] = label.GetBestSize()
 
-      # Get the height and width of a form-cell for which we use the tallest
-      # control and the avarage character width of the application font
-      cellHeight = max([i[1] for i in result.values()]) + 2
-      cellWidth  = frame.GetCharWidth () + 1
+            # Get the height and width of a form-cell for which we use the
+            # tallest control and the avarage character width of the
+            # application font
+            cellHeight = max([i[1] for i in result.values()]) + 2
+            cellWidth  = frame.GetCharWidth() + 1
 
-      # Add the button after calculating the cellHeight.  This is because a
-      # button is too big on GTK.
-      button = wx.Button (frame, wx.ID_ANY)
-      result['button'] = button.GetBestSize()
+            # Add the button after calculating the cellHeight.  This is because
+            # a button is too big on GTK.
+            button = wx.Button(frame, wx.ID_ANY)
+            result['button'] = button.GetBestSize()
 
-      multi = wx.TextCtrl (frame, -1, style=wx.TE_MULTILINE)
-      result['multiline'] = multi.GetBestSize()
+            multi = wx.TextCtrl(frame, -1, style=wx.TE_MULTILINE)
+            result['multiline'] = multi.GetBestSize()
 
-    finally:
-      frame.Destroy ()
+        finally:
+            frame.Destroy()
 
-    return (result, cellWidth, cellHeight)
+        return (result, cellWidth, cellHeight)
 
-  # ---------------------------------------------------------------------------
-  # Get the border for a given type of control
-  # ---------------------------------------------------------------------------
 
-  def control_border(self, control):
-      return (self.cellHeight - self.best_sizes.get(control, [0,0])[1]) / 2
+    # -------------------------------------------------------------------------
+    # Get the border for a given type of control
+    # -------------------------------------------------------------------------
 
+    def control_border(self, control):
 
-  # ---------------------------------------------------------------------------
-  # Hide the splash screen
-  # ---------------------------------------------------------------------------
+        return (self.cellHeight - self.best_sizes.get(control, [0,0])[1]) / 2
 
-  def hide_splash(self):
-      """
-      Hide the Splash-Screen (if it is visible).
-      """
 
-      if self.__splash is not None:
-          try:
-              self.__splash.Close ()
-          finally:
-              self.__splash = None
+    # -------------------------------------------------------------------------
+    # Hide the splash screen
+    # -------------------------------------------------------------------------
 
+    def hide_splash(self):
+        """
+        Hide the Splash-Screen (if it is visible).
+        """
 
-  # ---------------------------------------------------------------------------
-  # Start the application's main loop
-  # ---------------------------------------------------------------------------
+        if self.__splash is not None:
+            try:
+                self.__splash.Close()
+            finally:
+                self.__splash = None
 
-  def mainLoop (self):
-      """
-      Start the main loop of the current application instance (wx.App ())
-      """
 
-      assert gEnter (6)
+    # -------------------------------------------------------------------------
+    # Start the application's main loop
+    # -------------------------------------------------------------------------
 
-      # Main loop might already be running if this has been called with
-      # runForm()
-      if not self.app.IsMainLoopRunning():
-          self.app.MainLoop ()
+    def mainLoop(self):
+        """
+        Start the main loop of the current application instance (wx.App())
+        """
 
-      assert gLeave (6)
+        assert gEnter(6)
 
+        # Main loop might already be running if this has been called with
+        # runForm()
+        if not self.app.IsMainLoopRunning():
+            self.app.MainLoop()
 
-  # ---------------------------------------------------------------------------
-  # Create and run an input dialog
-  # ---------------------------------------------------------------------------
+        assert gLeave(6)
 
-  def _getInput (self, title, fields, cancel = True):
-    
-    dialog = dialogs.InputDialog (title, fields, cancel)
 
-    try:
-      dialog.ShowModal ()
-      return dialog.inputData
+    # -------------------------------------------------------------------------
+    # Create and run an input dialog
+    # -------------------------------------------------------------------------
 
-    finally:
-      dialog.Destroy ()
+    def _getInput(self, title, fields, cancel = True):
 
+        dialog = dialogs.InputDialog(title, fields, cancel)
 
-  # ---------------------------------------------------------------------------
-  # Show a simple error message
-  # ---------------------------------------------------------------------------
+        try:
+            dialog.ShowModal()
+            return dialog.inputData
 
-  def _ui_show_error_(self, message):
+        finally:
+            dialog.Destroy()
 
+
+    # -------------------------------------------------------------------------
+    # Show a simple error message
+    # -------------------------------------------------------------------------
+
+    def _ui_show_error_(self, message):
+
         if self.__splash:
-            self.__splash.Close ()
+            self.__splash.Close()
 
         dialog = wx.MessageDialog(None, message, "GNU Enterprise",
                 wx.ICON_ERROR | wx.OK)
@@ -200,35 +209,35 @@
             dialog.Destroy()
 
 
-  # ---------------------------------------------------------------------------
-  # Show an exception dialog
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Show an exception dialog
+    # -------------------------------------------------------------------------
 
-  def _ui_show_exception_(self, group, name, message, detail):
+    def _ui_show_exception_(self, group, name, message, detail):
 
-    if self.__splash:
-        self.__splash.Close()
+        if self.__splash:
+            self.__splash.Close()
 
-    dlg = dialogs.ExceptionDialog (group, name, message, detail)
-    try:
-      dlg.ShowModal ()
+        dlg = dialogs.ExceptionDialog(group, name, message, detail)
+        try:
+            dlg.ShowModal()
 
-    finally:
-      dlg.Destroy ()
+        finally:
+            dlg.Destroy()
 
 
-  # ---------------------------------------------------------------------------
-  # Exit the application
-  # ---------------------------------------------------------------------------
+    # -------------------------------------------------------------------------
+    # Exit the application
+    # -------------------------------------------------------------------------
 
-  def _ui_exit_(self):
-    """
-    Exit the application.
-    """
+    def _ui_exit_(self):
+        """
+        Exit the application.
+        """
 
-    assert gEnter(6)
+        assert gEnter(6)
 
-    for child in self._children:
-        child.main_window.Close(True)
+        for child in self._children:
+            child.main_window.Close(True)
 
-    assert gLeave(6)
+        assert gLeave(6)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]