[GRASS-SVN] r41890 - in grass/trunk/gui/wxpython: docs gui_modules
xml
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Apr 16 15:56:34 EDT 2010
Author: martinl
Date: 2010-04-16 15:56:34 -0400 (Fri, 16 Apr 2010)
New Revision: 41890
Modified:
grass/trunk/gui/wxpython/docs/wxGUI.html
grass/trunk/gui/wxpython/gui_modules/globalvar.py
grass/trunk/gui/wxpython/gui_modules/gmodeler.py
grass/trunk/gui/wxpython/gui_modules/preferences.py
grass/trunk/gui/wxpython/gui_modules/render.py
grass/trunk/gui/wxpython/gui_modules/vdigit.py
grass/trunk/gui/wxpython/xml/menudata.xml
grass/trunk/gui/wxpython/xml/menudata_modeler.xml
Log:
wxGUI/modeler: empty preferences dialog added
Modified: grass/trunk/gui/wxpython/docs/wxGUI.html
===================================================================
--- grass/trunk/gui/wxpython/docs/wxGUI.html 2010-04-16 18:52:47 UTC (rev 41889)
+++ grass/trunk/gui/wxpython/docs/wxGUI.html 2010-04-16 19:56:34 UTC (rev 41890)
@@ -495,7 +495,7 @@
<h2>CONFIGURATION</h2>
-<em>User GIS settings</em> dialog ('Config->Preferences') enables
+<em>User GIS settings</em> dialog ('Settings->Preferences') enables
configuration of various options.
<p>
Modified: grass/trunk/gui/wxpython/gui_modules/globalvar.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/globalvar.py 2010-04-16 18:52:47 UTC (rev 41889)
+++ grass/trunk/gui/wxpython/gui_modules/globalvar.py 2010-04-16 19:56:34 UTC (rev 41890)
@@ -94,6 +94,7 @@
DIALOG_GSELECT_SIZE = (400, -1)
DIALOG_TEXTCTRL_SIZE = (400, -1)
DIALOG_LAYER_SIZE = (100, -1)
+DIALOG_COLOR_SIZE = (30, 30)
MAP_WINDOW_SIZE = (770, 570)
HIST_WINDOW_SIZE = (500, 350)
Modified: grass/trunk/gui/wxpython/gui_modules/gmodeler.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gmodeler.py 2010-04-16 18:52:47 UTC (rev 41889)
+++ grass/trunk/gui/wxpython/gui_modules/gmodeler.py 2010-04-16 19:56:34 UTC (rev 41890)
@@ -14,7 +14,8 @@
- ModelRelation
- ProcessModelFile
- WriteModelFile
-
+ - PreferencesDialog
+
(C) 2010 by the GRASS Development Team
This program is free software under the GNU General Public License
(>=v2). Read the file COPYING that comes with GRASS for details.
@@ -42,6 +43,7 @@
import wx
import wx.lib.ogl as ogl
import wx.lib.flatnotebook as FN
+import wx.lib.colourselect as csel
import menu
import menudata
@@ -51,11 +53,10 @@
import utils
import goutput
import gselect
-from debug import Debug
-from gcmd import GMessage
-from gcmd import GError
-from gdialogs import ElementDialog
-from gdialogs import GetImageHandlers
+from debug import Debug
+from gcmd import GMessage, GError
+from gdialogs import ElementDialog, GetImageHandlers
+from preferences import PreferencesBaseDialog, globalSettings as UserSettings
from grass.script import core as grass
class Model(object):
@@ -252,6 +253,7 @@
"default" : wx.StockCursor(wx.CURSOR_ARROW),
"cross" : wx.StockCursor(wx.CURSOR_CROSS),
}
+ self.dialogs = { 'preferences' : None }
wx.Frame.__init__(self, parent = parent, id = id, title = title, **kwargs)
self.SetName("Modeler")
@@ -325,6 +327,18 @@
"""!Close window"""
self.Destroy()
+ def OnPreferences(self, event):
+ """!Open preferences dialog"""
+ if not self.dialogs['preferences']:
+ dlg = PreferencesDialog(parent = self)
+ self.dialogs['preferences'] = dlg
+ self.dialogs['preferences'].CenterOnParent()
+
+ self.dialogs['preferences'].ShowModal()
+
+ def OnModelProperties(self, event):
+ """!Model properties dialog"""
+
def OnDeleteData(self, event):
"""!Delete intermediate data"""
rast, vect, rast3d, msg = self.model.GetIntermediateData()
@@ -1766,6 +1780,91 @@
self.indent -= 4
+class PreferencesDialog(PreferencesBaseDialog):
+ """!User preferences dialog"""
+ def __init__(self, parent, settings = UserSettings,
+ title = _("Modeler settings")):
+
+ PreferencesBaseDialog.__init__(self, parent = parent, title = title,
+ settings = settings)
+
+ # create notebook pages
+ self._createDiagramPage(self.notebook)
+
+ self.SetMinSize(self.GetBestSize())
+ self.SetSize(self.size)
+
+ def _createDiagramPage(self, notebook):
+ """!Create notebook page for diagram settings"""
+ panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
+ notebook.AddPage(page = panel, text = _("Diagram"))
+
+ #
+ # action
+ #
+ border = wx.BoxSizer(wx.VERTICAL)
+ box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
+ label = " %s " % _("Action settings"))
+ sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
+
+ gridSizer = wx.GridBagSizer (hgap=3, vgap=3)
+ gridSizer.AddGrowableCol(0)
+
+ # colors
+ row = 0
+ gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
+ label=_("Valid:")),
+ flag=wx.ALIGN_LEFT |
+ wx.ALIGN_CENTER_VERTICAL,
+ pos=(row, 0))
+ vColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
+ colour = self.settings.Get(group='modeler', key='action', subkey=('color', 'valid')),
+ size = globalvar.DIALOG_COLOR_SIZE)
+ vColor.SetName('GetColour')
+ self.winId['modeler:action:validColor'] = vColor.GetId()
+
+ gridSizer.Add(item=vColor,
+ flag=wx.ALIGN_RIGHT |
+ wx.ALIGN_CENTER_VERTICAL,
+ pos=(row, 1))
+
+ row = 1
+ gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
+ label=_("Invalid:")),
+ flag=wx.ALIGN_LEFT |
+ wx.ALIGN_CENTER_VERTICAL,
+ pos=(row, 0))
+ iColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
+ colour = self.settings.Get(group='modeler', key='action', subkey=('color', 'invalid')),
+ size = globalvar.DIALOG_COLOR_SIZE)
+ iColor.SetName('GetColour')
+ self.winId['modeler:action:invalidColor'] = iColor.GetId()
+
+ gridSizer.Add(item=iColor,
+ flag=wx.ALIGN_RIGHT |
+ wx.ALIGN_CENTER_VERTICAL,
+ pos=(row, 1))
+
+ sizer.Add(item=gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
+ border.Add(item=sizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=3)
+
+ #
+ # data
+ #
+ box = wx.StaticBox (parent = panel, id = wx.ID_ANY,
+ label = " %s " % _("Data settings"))
+ sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
+
+ gridSizer = wx.GridBagSizer (hgap=3, vgap=3)
+ gridSizer.AddGrowableCol(0)
+
+ sizer.Add(item=gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
+ border.Add(item=sizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=3)
+
+ panel.SetSizer(border)
+
+ return panel
+
def main():
app = wx.PySimpleApp()
wx.InitAllImageHandlers()
Modified: grass/trunk/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/preferences.py 2010-04-16 18:52:47 UTC (rev 41889)
+++ grass/trunk/gui/wxpython/gui_modules/preferences.py 2010-04-16 19:56:34 UTC (rev 41890)
@@ -7,6 +7,7 @@
Classes:
- Settings
+ - PreferencesBaseDialog
- PreferencesDialog
- DefaultFontDialog
- MapsetAccess
@@ -510,6 +511,14 @@
},
},
},
+ 'modeler' : {
+ 'action' : {
+ 'color' : {
+ 'valid' : (211, 211, 211, 255), # light grey
+ 'invalid' : (255, 255, 255, 255), # white
+ },
+ },
+ },
}
#
@@ -831,76 +840,111 @@
globalSettings = Settings()
-class PreferencesDialog(wx.Dialog):
- """!User preferences dialog"""
- def __init__(self, parent, title=_("User GUI settings"),
- settings=globalSettings,
- style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
- self.parent = parent # GMFrame
- self.title = title
- wx.Dialog.__init__(self, parent=parent, id=wx.ID_ANY, title=title,
- style=style, size=(-1, -1))
-
+class PreferencesBaseDialog(wx.Dialog):
+ """!Base preferences dialog"""
+ def __init__(self, parent, settings, title = _("User settings"),
+ size = (500, 375),
+ style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
+ self.parent = parent # ModelerFrame
+ self.title = title
+ self.size = size
self.settings = settings
+
+ wx.Dialog.__init__(self, parent = parent, id = wx.ID_ANY, title = title,
+ style = style)
+
# notebook
- notebook = wx.Notebook(parent=self, id=wx.ID_ANY, style=wx.BK_DEFAULT)
-
+ self.notebook = wx.Notebook(parent=self, id=wx.ID_ANY, style=wx.BK_DEFAULT)
+
# dict for window ids
self.winId = {}
# create notebook pages
- self.__CreateGeneralPage(notebook)
- self.__CreateDisplayPage(notebook)
- self.__CreateCmdPage(notebook)
- self.__CreateAttributeManagerPage(notebook)
- self.__CreateProjectionPage(notebook)
- self.__CreateWorkspacePage(notebook)
- self.__CreateAdvancedPage(notebook)
-
+
# buttons
- btnDefault = wx.Button(self, wx.ID_ANY, _("Set to default"))
- btnSave = wx.Button(self, wx.ID_SAVE)
- btnApply = wx.Button(self, wx.ID_APPLY)
- btnCancel = wx.Button(self, wx.ID_CANCEL)
- btnSave.SetDefault()
-
+ self.btnDefault = wx.Button(self, wx.ID_ANY, _("Set to default"))
+ self.btnSave = wx.Button(self, wx.ID_SAVE)
+ self.btnApply = wx.Button(self, wx.ID_APPLY)
+ self.btnCancel = wx.Button(self, wx.ID_CANCEL)
+ self.btnSave.SetDefault()
+
# bindigs
- btnDefault.Bind(wx.EVT_BUTTON, self.OnDefault)
- btnDefault.SetToolTipString(_("Revert settings to default and apply changes"))
- btnApply.Bind(wx.EVT_BUTTON, self.OnApply)
- btnApply.SetToolTipString(_("Apply changes for the current session"))
- btnSave.Bind(wx.EVT_BUTTON, self.OnSave)
- btnSave.SetToolTipString(_("Apply and save changes to user settings file (default for next sessions)"))
- btnSave.SetDefault()
- btnCancel.Bind(wx.EVT_BUTTON, self.OnCancel)
- btnCancel.SetToolTipString(_("Close dialog and ignore changes"))
+ self.btnDefault.Bind(wx.EVT_BUTTON, self.OnDefault)
+ self.btnDefault.SetToolTipString(_("Revert settings to default and apply changes"))
+ self.btnApply.Bind(wx.EVT_BUTTON, self.OnApply)
+ self.btnApply.SetToolTipString(_("Apply changes for the current session"))
+ self.btnSave.Bind(wx.EVT_BUTTON, self.OnSave)
+ self.btnSave.SetToolTipString(_("Apply and save changes to user settings file (default for next sessions)"))
+ self.btnSave.SetDefault()
+ self.btnCancel.Bind(wx.EVT_BUTTON, self.OnCancel)
+ self.btnCancel.SetToolTipString(_("Close dialog and ignore changes"))
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
+ self._layout()
+
+ def _layout(self):
+ """!Layout window"""
# sizers
btnSizer = wx.BoxSizer(wx.HORIZONTAL)
- btnSizer.Add(item=btnDefault, proportion=1,
+ btnSizer.Add(item=self.btnDefault, proportion=1,
flag=wx.ALL, border=5)
btnStdSizer = wx.StdDialogButtonSizer()
- btnStdSizer.AddButton(btnCancel)
- btnStdSizer.AddButton(btnSave)
- btnStdSizer.AddButton(btnApply)
+ btnStdSizer.AddButton(self.btnCancel)
+ btnStdSizer.AddButton(self.btnSave)
+ btnStdSizer.AddButton(self.btnApply)
btnStdSizer.Realize()
mainSizer = wx.BoxSizer(wx.VERTICAL)
- mainSizer.Add(item=notebook, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)
+ mainSizer.Add(item=self.notebook, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)
mainSizer.Add(item=btnSizer, proportion=0,
flag=wx.EXPAND, border=0)
mainSizer.Add(item=btnStdSizer, proportion=0,
flag=wx.EXPAND | wx.ALL | wx.ALIGN_RIGHT, border=5)
-
+
self.SetSizer(mainSizer)
mainSizer.Fit(self)
+
+ def OnDefault(self, event):
+ """!Button 'Set to default' pressed"""
+ pass
+
+ def OnApply(self, event):
+ """!Button 'Apply' pressed"""
+ pass
+ def OnSave(self, event):
+ """!Button 'Save' pressed"""
+ pass
+
+ def OnCancel(self, event):
+ """!Button 'Cancel' pressed"""
+ self.Close()
+
+ def OnCloseWindow(self, event):
+ self.Hide()
+
+class PreferencesDialog(PreferencesBaseDialog):
+ """!User preferences dialog"""
+ def __init__(self, parent, title = _("GUI settings"),
+ settings = globalSettings):
+
+ PreferencesBaseDialog.__init__(self, parent = parent, title = title,
+ settings = settings)
+
+ # create notebook pages
+ self._CreateGeneralPage(self.notebook)
+ self._CreateDisplayPage(self.notebook)
+ self._CreateCmdPage(self.notebook)
+ self._CreateAttributeManagerPage(self.notebook)
+ self._CreateProjectionPage(self.notebook)
+ self._CreateWorkspacePage(self.notebook)
+ self._CreateAdvancedPage(self.notebook)
+
self.SetMinSize(self.GetBestSize())
- self.SetSize((500, 375))
-
- def __CreateGeneralPage(self, notebook):
+ self.SetSize(self.size)
+
+ def _CreateGeneralPage(self, notebook):
"""!Create notebook page for general settings"""
panel = wx.Panel(parent=notebook, id=wx.ID_ANY)
notebook.AddPage(page=panel, text=_("General"))
@@ -992,7 +1036,7 @@
return panel
- def __CreateDisplayPage(self, notebook):
+ def _CreateDisplayPage(self, notebook):
"""!Create notebook page for display settings"""
panel = wx.Panel(parent=notebook, id=wx.ID_ANY)
@@ -1098,7 +1142,7 @@
pos=(row, 0))
bgColor = csel.ColourSelect(parent=panel, id=wx.ID_ANY,
colour=self.settings.Get(group='display', key='bgcolor', subkey='color'),
- size=(35, 35))
+ size=globalvar.DIALOG_COLOR_SIZE)
bgColor.SetName('GetColour')
self.winId['display:bgcolor:color'] = bgColor.GetId()
@@ -1156,7 +1200,7 @@
return panel
- def __CreateCmdPage(self, notebook):
+ def _CreateCmdPage(self, notebook):
"""!Create notebook page for commad dialog settings"""
panel = wx.Panel(parent=notebook, id=wx.ID_ANY)
notebook.AddPage(page=panel, text=_("Command"))
@@ -1296,7 +1340,7 @@
return panel
- def __CreateAttributeManagerPage(self, notebook):
+ def _CreateAttributeManagerPage(self, notebook):
"""!Create notebook page for 'Attribute Table Manager' settings"""
panel = wx.Panel(parent=notebook, id=wx.ID_ANY)
notebook.AddPage(page=panel, text=_("Attributes"))
@@ -1316,7 +1360,7 @@
label = wx.StaticText(parent=panel, id=wx.ID_ANY, label=_("Color:"))
hlColor = csel.ColourSelect(parent=panel, id=wx.ID_ANY,
colour=self.settings.Get(group='atm', key='highlight', subkey='color'),
- size=(35, 35))
+ size=globalvar.DIALOG_COLOR_SIZE)
hlColor.SetName('GetColour')
self.winId['atm:highlight:color'] = hlColor.GetId()
@@ -1425,7 +1469,7 @@
return panel
- def __CreateProjectionPage(self, notebook):
+ def _CreateProjectionPage(self, notebook):
"""!Create notebook page for workspace settings"""
panel = wx.Panel(parent=notebook, id=wx.ID_ANY)
notebook.AddPage(page=panel, text=_("Projection"))
@@ -1560,7 +1604,7 @@
return panel
- def __CreateWorkspacePage(self, notebook):
+ def _CreateWorkspacePage(self, notebook):
"""!Create notebook page for workspace settings"""
panel = wx.Panel(parent=notebook, id=wx.ID_ANY)
notebook.AddPage(page=panel, text=_("Workspace"))
@@ -1604,7 +1648,7 @@
return panel
- def __CreateAdvancedPage(self, notebook):
+ def _CreateAdvancedPage(self, notebook):
"""!Create notebook page for advanced settings"""
panel = wx.Panel(parent=notebook, id=wx.ID_ANY)
notebook.AddPage(page=panel, text=_("Advanced"))
@@ -1790,14 +1834,14 @@
def OnSave(self, event):
"""!Button 'Save' pressed"""
- if self.__UpdateSettings():
+ if self._UpdateSettings():
file = self.settings.SaveToFile()
self.parent.goutput.WriteLog(_('Settings saved to file \'%s\'.') % file)
self.Close()
def OnApply(self, event):
"""!Button 'Apply' pressed"""
- if self.__UpdateSettings():
+ if self._UpdateSettings():
self.parent.goutput.WriteLog(_('Settings applied to current session but not saved'))
self.Close()
@@ -1830,7 +1874,7 @@
else:
value = win.SetValue(value)
- def __UpdateSettings(self):
+ def _UpdateSettings(self):
"""!Update user settings"""
for item in self.winId.keys():
try:
Modified: grass/trunk/gui/wxpython/gui_modules/render.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/render.py 2010-04-16 18:52:47 UTC (rev 41889)
+++ grass/trunk/gui/wxpython/gui_modules/render.py 2010-04-16 19:56:34 UTC (rev 41890)
@@ -409,7 +409,11 @@
sys.exit(_("GISBASE not set. You must be in GRASS GIS to run this program."))
self.env = self._runCommand(grass.gisenv)
-
+
+ def GetProjInfo(self):
+ """!Get projection info"""
+ return self.projinfo
+
def _projInfo(self):
"""!Return region projection and map units information
"""
Modified: grass/trunk/gui/wxpython/gui_modules/vdigit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/vdigit.py 2010-04-16 18:52:47 UTC (rev 41889)
+++ grass/trunk/gui/wxpython/gui_modules/vdigit.py 2010-04-16 19:56:34 UTC (rev 41890)
@@ -1203,7 +1203,7 @@
textLabel = wx.StaticText(panel, wx.ID_ANY, label)
color = csel.ColourSelect(panel, id=wx.ID_ANY,
colour=UserSettings.Get(group='vdigit', key='symbol',
- subkey=[key, 'color']), size=(25, 25))
+ subkey=[key, 'color']), size=globalvar.DIALOG_COLOR_SIZE)
isEnabled = UserSettings.Get(group='vdigit', key='symbol',
subkey=[key, 'enabled'])
if isEnabled is not None:
@@ -1284,7 +1284,7 @@
label=_("Snap also to vertex"))
self.snapVertex.SetValue(UserSettings.Get(group='vdigit', key="snapToVertex", subkey='enabled'))
vertexSizer.Add(item=self.snapVertex, proportion=0, flag=wx.EXPAND)
- self.mapUnits = self.parent.MapWindow.Map.ProjInfo()['units']
+ self.mapUnits = self.parent.MapWindow.Map.GetProjInfo()['units']
self.snappingInfo = wx.StaticText(parent=panel, id=wx.ID_ANY,
label=_("Snapping threshold is %(value).1f %(units)s") % \
{'value' : self.parent.digit.driver.GetThreshold(),
@@ -1385,7 +1385,7 @@
box = wx.StaticBox (parent=panel, id=wx.ID_ANY, label=" %s " % _("Choose query tool"))
sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
- LocUnits = self.parent.MapWindow.Map.ProjInfo()['units']
+ LocUnits = self.parent.MapWindow.Map.GetProjInfo()['units']
self.queryBox = wx.CheckBox(parent=panel, id=wx.ID_ANY, label=_("Select by box"))
self.queryBox.SetValue(UserSettings.Get(group='vdigit', key="query", subkey='box'))
Modified: grass/trunk/gui/wxpython/xml/menudata.xml
===================================================================
--- grass/trunk/gui/wxpython/xml/menudata.xml 2010-04-16 18:52:47 UTC (rev 41889)
+++ grass/trunk/gui/wxpython/xml/menudata.xml 2010-04-16 19:56:34 UTC (rev 41890)
@@ -675,7 +675,7 @@
</items>
</menu>
<menu>
- <label>C&onfig</label>
+ <label>&Settings</label>
<items>
<menu>
<label>Region</label>
Modified: grass/trunk/gui/wxpython/xml/menudata_modeler.xml
===================================================================
--- grass/trunk/gui/wxpython/xml/menudata_modeler.xml 2010-04-16 18:52:47 UTC (rev 41889)
+++ grass/trunk/gui/wxpython/xml/menudata_modeler.xml 2010-04-16 19:56:34 UTC (rev 41890)
@@ -52,6 +52,16 @@
</items>
</menu>
<menu>
+ <label>&Settings</label>
+ <items>
+ <menuitem>
+ <label>Preferences</label>
+ <help>Modeler settings</help>
+ <handler>OnPreferences</handler>
+ </menuitem>
+ </items>
+ </menu>
+ <menu>
<label>&Model</label>
<items>
<menuitem>
@@ -78,6 +88,12 @@
</menuitem>
<separator />
<menuitem>
+ <label>Model properties</label>
+ <help>Model properties (name, purpose, etc.)</help>
+ <handler>OnModelProperties</handler>
+ </menuitem>
+ <separator />
+ <menuitem>
<label>Delete intermediate data</label>
<help>Delete intermediate data defined in the model</help>
<handler>OnDeleteData</handler>
More information about the grass-commit
mailing list