Bläddra i källkod

wxGUI/locationWizard: added help button to wizard, tooltips, HelpFrame base class changed to dialog (merged from releasebranch, https://trac.osgeo.org/grass/changeset/52759)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@52763 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 12 år sedan
förälder
incheckning
a85eda2cf1

+ 1 - 1
gui/wxpython/gis_set.py

@@ -794,7 +794,7 @@ class GRASSStartup(wx.Frame):
         # help text in lib/init/helptext.html
         # help text in lib/init/helptext.html
         file = os.path.join(self.gisbase, "docs", "html", "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"),
                               title = _("GRASS Quickstart"),
                               size = (640, 480),
                               size = (640, 480),
                               file = file)
                               file = file)

+ 9 - 3
gui/wxpython/gui_core/ghelp.py

@@ -874,10 +874,16 @@ class AboutWindow(wx.Frame):
         """!Close window"""
         """!Close window"""
         self.Close()
         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):
     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)
         sizer = wx.BoxSizer(wx.VERTICAL)
         
         

+ 18 - 9
gui/wxpython/location_wizard/base.py

@@ -23,23 +23,32 @@ class BaseClass(wx.Object):
     def __init__(self):
     def __init__(self):
         pass
         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"""
         """!Make aligned label"""
         if not parent:
         if not parent:
             parent = self
             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"""
         """!Generic text control"""
         if not parent:
         if not parent:
             parent = self
             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"""
         """!Generic button"""
         if not parent:
         if not parent:
             parent = self
             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

+ 30 - 4
gui/wxpython/location_wizard/wizard.py

@@ -19,6 +19,7 @@ Classes:
  - wizard::CustomPage
  - wizard::CustomPage
  - wizard::SummaryPage
  - wizard::SummaryPage
  - wizard::LocationWizard
  - wizard::LocationWizard
+ - wizard::WizardWithHelpButton
 
 
 (C) 2007-2011 by the GRASS Development Team
 (C) 2007-2011 by the GRASS Development Team
 
 
@@ -40,6 +41,7 @@ import wx.lib.scrolledpanel as scrolled
 from core                    import globalvar
 from core                    import globalvar
 from core                    import utils
 from core                    import utils
 from core.gcmd               import RunCommand, GError, GMessage, GWarning
 from core.gcmd               import RunCommand, GError, GMessage, GWarning
+from gui_core.ghelp          import HelpFrame
 from location_wizard.base    import BaseClass
 from location_wizard.base    import BaseClass
 from location_wizard.dialogs import RegionDef, SelectTransformDialog
 from location_wizard.dialogs import RegionDef, SelectTransformDialog
 
 
@@ -120,7 +122,8 @@ class DatabasePage(TitledPage):
                        wx.ALL, border = 5,
                        wx.ALL, border = 5,
                        pos = (1, 3))
                        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 |
                        flag = wx.ALIGN_RIGHT |
                        wx.ALIGN_CENTER_VERTICAL |
                        wx.ALIGN_CENTER_VERTICAL |
                        wx.ALL, border = 5,
                        wx.ALL, border = 5,
@@ -131,7 +134,9 @@ class DatabasePage(TitledPage):
                        wx.ALL, border = 5,
                        wx.ALL, border = 5,
                        pos = (2, 2))
                        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 |
                        flag = wx.ALIGN_RIGHT |
                        wx.ALIGN_TOP | wx.ALIGN_CENTER_VERTICAL |
                        wx.ALIGN_TOP | wx.ALIGN_CENTER_VERTICAL |
                        wx.ALL, border = 5,
                        wx.ALL, border = 5,
@@ -1757,8 +1762,10 @@ class LocationWizard(wx.Object):
         #
         #
         # define wizard pages
         # 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.startpage = DatabasePage(self.wizard, self, grassdatabase)
         self.csystemspage = CoordinateSystemPage(self.wizard, self)
         self.csystemspage = CoordinateSystemPage(self.wizard, self)
         self.projpage = ProjectionsPage(self.wizard, self)
         self.projpage = ProjectionsPage(self.wizard, self)
@@ -2110,3 +2117,22 @@ class LocationWizard(wx.Object):
         proj4string = '%s +no_defs' % proj4string
         proj4string = '%s +no_defs' % proj4string
         
         
         return 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)