[GRASS-SVN] r52759 - in grass/branches/releasebranch_6_4/gui/wxpython: . gui_core location_wizard

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Aug 20 03:43:12 PDT 2012


Author: annakrat
Date: 2012-08-20 03:43:12 -0700 (Mon, 20 Aug 2012)
New Revision: 52759

Modified:
   grass/branches/releasebranch_6_4/gui/wxpython/gis_set.py
   grass/branches/releasebranch_6_4/gui/wxpython/gui_core/ghelp.py
   grass/branches/releasebranch_6_4/gui/wxpython/location_wizard/base.py
   grass/branches/releasebranch_6_4/gui/wxpython/location_wizard/wizard.py
Log:
wxGUI/locationWizard: added help button to wizard, tooltips, HelpFrame base class changed to dialog

Modified: grass/branches/releasebranch_6_4/gui/wxpython/gis_set.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gis_set.py	2012-08-20 10:36:06 UTC (rev 52758)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gis_set.py	2012-08-20 10:43:12 UTC (rev 52759)
@@ -783,7 +783,7 @@
         # help text in lib/init/helptext.html
         file = os.path.join(self.gisbase, "docs", "html", "helptext.html")
 
-        helpFrame = HelpFrame(parent = self, id = wx.ID_ANY,
+        helpFrame = HelpFrame(parent = None, id = wx.ID_ANY,
                               title = _("GRASS Quickstart"),
                               size = (640, 480),
                               file = file)

Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_core/ghelp.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_core/ghelp.py	2012-08-20 10:36:06 UTC (rev 52758)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_core/ghelp.py	2012-08-20 10:43:12 UTC (rev 52759)
@@ -726,10 +726,16 @@
         """!Close window"""
         self.Close()
 
-class HelpFrame(wx.Frame):
-    """!GRASS Quickstart help window"""
+class HelpFrame(wx.Dialog):
+    """!GRASS Quickstart help window
+
+    As a base class wx.Dialog is used, because of not working
+    close button with wx.Frame when dialog is called from wizard.
+    If parent is None, application TopLevelWindow is used (wxPython standard behaviour).
+    """
     def __init__(self, parent, id, title, size, file):
-        wx.Frame.__init__(self, parent = parent, id = id, title = title, size = size)
+        wx.Dialog.__init__(self, parent = parent, id = id, title = title,
+                           size = size, style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER | wx.MINIMIZE_BOX)
         
         sizer = wx.BoxSizer(wx.VERTICAL)
         
@@ -743,6 +749,7 @@
         self.SetSizer(sizer)
         self.Layout()
 
+
 class HelpWindow(wx.html.HtmlWindow):
     """!This panel holds the text from GRASS docs.
     

Modified: grass/branches/releasebranch_6_4/gui/wxpython/location_wizard/base.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/location_wizard/base.py	2012-08-20 10:36:06 UTC (rev 52758)
+++ grass/branches/releasebranch_6_4/gui/wxpython/location_wizard/base.py	2012-08-20 10:43:12 UTC (rev 52759)
@@ -23,23 +23,32 @@
     def __init__(self):
         pass
 
-    def MakeLabel(self, text = "", style = wx.ALIGN_LEFT, parent = None):
+    def MakeLabel(self, text = "", style = wx.ALIGN_LEFT, parent = None, tooltip = None):
         """!Make aligned label"""
         if not parent:
             parent = self
-        return wx.StaticText(parent = parent, id = wx.ID_ANY, label = text,
-                             style = style)
+        label =  wx.StaticText(parent = parent, id = wx.ID_ANY, label = text,
+                              style = style)
+        if tooltip:
+            label.SetToolTipString(tooltip)
+        return label
 
-    def MakeTextCtrl(self, text = '', size = (100,-1), style = 0, parent = None):
+    def MakeTextCtrl(self, text = '', size = (100,-1), style = 0, parent = None, tooltip = None):
         """!Generic text control"""
         if not parent:
             parent = self
-        return wx.TextCtrl(parent = parent, id = wx.ID_ANY, value = text,
-                           size = size, style = style)
+        textCtrl = wx.TextCtrl(parent = parent, id = wx.ID_ANY, value = text,
+                               size = size, style = style)
+        if tooltip:
+            textCtrl.SetToolTipString(tooltip)
+        return textCtrl
 
-    def MakeButton(self, text, id = wx.ID_ANY, size = (-1,-1), parent = None):
+    def MakeButton(self, text, id = wx.ID_ANY, size = (-1,-1), parent = None, tooltip = None):
         """!Generic button"""
         if not parent:
             parent = self
-        return wx.Button(parent = parent, id = id, label = text,
-                         size = size)
+        button = wx.Button(parent = parent, id = id, label = text,
+                           size = size)
+        if tooltip:
+            button.SetToolTipString(tooltip)
+        return button

Modified: grass/branches/releasebranch_6_4/gui/wxpython/location_wizard/wizard.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/location_wizard/wizard.py	2012-08-20 10:36:06 UTC (rev 52758)
+++ grass/branches/releasebranch_6_4/gui/wxpython/location_wizard/wizard.py	2012-08-20 10:43:12 UTC (rev 52759)
@@ -19,6 +19,7 @@
  - wizard::CustomPage
  - wizard::SummaryPage
  - wizard::LocationWizard
+ - wizard::WizardWithHelpButton
 
 (C) 2007-2011 by the GRASS Development Team
 
@@ -40,6 +41,7 @@
 from core                    import globalvar
 from core                    import utils
 from core.gcmd               import RunCommand, GError, GMessage, GWarning
+from gui_core.ghelp          import HelpFrame
 from location_wizard.base    import BaseClass
 from location_wizard.dialogs import RegionDef, SelectTransformDialog
 
@@ -120,7 +122,8 @@
                        wx.ALL, border = 5,
                        pos = (1, 3))
         
-        self.sizer.Add(item = self.MakeLabel("%s:" % _("Project Location")),
+        self.sizer.Add(item = self.MakeLabel("%s:" % _("Project Location"),
+                                             tooltip = _("Name of location directory in GIS Data Directory")),
                        flag = wx.ALIGN_RIGHT |
                        wx.ALIGN_CENTER_VERTICAL |
                        wx.ALL, border = 5,
@@ -131,7 +134,9 @@
                        wx.ALL, border = 5,
                        pos = (2, 2))
 
-        self.sizer.Add(item = self.MakeLabel("%s:" % _("Location Title")),
+        self.sizer.Add(item = self.MakeLabel("%s:" % _("Location Title"),
+                                             tooltip = _("Optional location title, "
+                                                         "you can leave this field blank.")),
                        flag = wx.ALIGN_RIGHT |
                        wx.ALIGN_TOP | wx.ALIGN_CENTER_VERTICAL |
                        wx.ALL, border = 5,
@@ -1711,8 +1716,10 @@
         #
         # define wizard pages
         #
-        self.wizard = wiz.Wizard(parent, id = wx.ID_ANY, title = _("Define new GRASS Location"),
-                                 bitmap = wizbmp, style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)
+        self.wizard = WizardWithHelpButton(parent, id = wx.ID_ANY, title = _("Define new GRASS Location"),
+                                           bitmap = wizbmp)
+        self.wizard.Bind(wiz.EVT_WIZARD_HELP, self.OnHelp)
+
         self.startpage = DatabasePage(self.wizard, self, grassdatabase)
         self.csystemspage = CoordinateSystemPage(self.wizard, self)
         self.projpage = ProjectionsPage(self.wizard, self)
@@ -2048,3 +2055,22 @@
         proj4string = '%s +no_defs' % proj4string
         
         return proj4string
+
+    def OnHelp(self, event):
+        """'Help' button clicked"""
+        # help text in lib/init/helptext.html
+        filePath = os.path.join(os.getenv('GISBASE'), "docs", "html", "helptext.html")
+
+        helpFrame = HelpFrame(parent = None, id = wx.ID_ANY,
+                              title = _("GRASS Quickstart"),
+                              size = (640, 480),
+                              file = filePath)
+        helpFrame.Show(True)
+
+
+class WizardWithHelpButton(wiz.Wizard):
+    def __init__(self, parent, id, title, bitmap):
+        pre = wiz.PreWizard()
+        pre.SetExtraStyle(wx.wizard.WIZARD_EX_HELPBUTTON)
+        pre.Create(parent = parent, id = id, title = title, bitmap = bitmap)
+        self.PostCreate(pre)



More information about the grass-commit mailing list