[GRASS-SVN] r30356 - in grass/trunk/gui/wxpython: . gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Feb 26 09:02:00 EST 2008
Author: martinl
Date: 2008-02-26 09:02:00 -0500 (Tue, 26 Feb 2008)
New Revision: 30356
Modified:
grass/trunk/gui/wxpython/gui_modules/preferences.py
grass/trunk/gui/wxpython/wxgui.py
Log:
wxGUI: MapsetAccess dialog moved to preferences.py
Modified: grass/trunk/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/preferences.py 2008-02-26 11:53:43 UTC (rev 30355)
+++ grass/trunk/gui/wxpython/gui_modules/preferences.py 2008-02-26 14:02:00 UTC (rev 30356)
@@ -6,8 +6,9 @@
Sets default display font, etc.
Classes:
- * PreferencesDialog
- * SetDefaultFont
+ - PreferencesDialog
+ - SetDefaultFont
+ - MapsetAccess
(C) 2007-2008 by the GRASS Development Team
This program is free software under the GNU General Public
@@ -553,3 +554,81 @@
fontlist.append(dfonts[item])
return fontlist
+
+class MapsetAccess(wx.Dialog):
+ """
+ Controls setting options and displaying/hiding map overlay decorations
+ """
+ def __init__(self, parent, id, title=_('Set/unset access to mapsets in current location'),
+ pos=wx.DefaultPosition, size=(-1, -1),
+ style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER):
+ wx.Dialog.__init__(self, parent, id, title, pos, size, style)
+
+ self.all_mapsets, self.accessible_mapsets = utils.ListOfMapsets()
+ self.curr_mapset = grassenv.GetGRASSVariable('MAPSET')
+
+ # make a checklistbox from available mapsets and check those that are active
+ sizer = wx.BoxSizer(wx.VERTICAL)
+
+ label = wx.StaticText(parent=self, id=wx.ID_ANY,
+ label=_("Check mapset to make it accessible, uncheck it to hide it.%s"
+ "Note: PERMANENT and current mapset are always accessible.") % os.linesep)
+ sizer.Add(item=label, proportion=0,
+ flag=wx.ALL, border=5)
+
+ self.mapsetlb = wx.CheckListBox(parent=self, id=wx.ID_ANY, pos=wx.DefaultPosition,
+ size=(350,200), choices=self.all_mapsets)
+ self.mapsetlb.Bind(wx.EVT_CHECKLISTBOX, self.OnCheckMapset)
+
+ sizer.Add(item=self.mapsetlb, proportion=1,
+ flag=wx.ALL | wx.EXPAND, border=5)
+
+ # check all accessible mapsets
+ if globalSettings.Get('mapsetPath') == 'l':
+ for mset in self.all_mapsets:
+ self.mapsetlb.Check(self.all_mapsets.index(mset), True)
+ else:
+ for mset in self.accessible_mapsets:
+ self.mapsetlb.Check(self.all_mapsets.index(mset), True)
+
+ # dialog buttons
+ line = wx.StaticLine(parent=self, id=wx.ID_ANY,
+ style=wx.LI_HORIZONTAL)
+ sizer.Add(item=line, proportion=0,
+ flag=wx.EXPAND | wx.ALIGN_CENTRE | wx.ALL, border=5)
+
+ btnsizer = wx.StdDialogButtonSizer()
+ okbtn = wx.Button(self, wx.ID_OK)
+ okbtn.SetDefault()
+ btnsizer.AddButton(okbtn)
+
+ cancelbtn = wx.Button(self, wx.ID_CANCEL)
+ btnsizer.AddButton(cancelbtn)
+ btnsizer.Realize()
+
+ sizer.Add(item=btnsizer, proportion=0,
+ flag=wx.EXPAND | wx.ALIGN_RIGHT | wx.ALL, border=5)
+
+ # do layout
+ self.Layout()
+ self.SetSizer(sizer)
+ sizer.Fit(self)
+
+ self.SetMinSize(self.GetBestSize())
+
+ def OnCheckMapset(self, event):
+ """Mapset checked/unchecked"""
+ mapset = self.mapsetlb.GetString(event.GetSelection())
+ if mapset == 'PERMANENT' or mapset == self.curr_mapset:
+ self.mapsetlb.Check(event.GetSelection(), True)
+
+ def GetMapsets(self):
+ """Get list of checked mapsets"""
+ ms = []
+ i = 0
+ for mset in self.all_mapsets:
+ if self.mapsetlb.IsChecked(i):
+ ms.append(mset)
+ i += 1
+
+ return ms
Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py 2008-02-26 11:53:43 UTC (rev 30355)
+++ grass/trunk/gui/wxpython/wxgui.py 2008-02-26 14:02:00 UTC (rev 30356)
@@ -82,8 +82,8 @@
import gui_modules.globalvar as globalvar
from gui_modules.debug import Debug as Debug
from icons.icon import Icons as Icons
+from gui_modules.preferences import globalSettings as UserSettings
-
class GMFrame(wx.Frame):
"""
GIS Manager frame with notebook widget for controlling
@@ -330,27 +330,18 @@
"""
Launch mapset access dialog
"""
- dlg = MapsetAccess(self, wx.ID_ANY)
-
+ dlg = preferences.MapsetAccess(parent=self, id=wx.ID_ANY)
dlg.CenterOnScreen()
# if OK is pressed...
if dlg.ShowModal() == wx.ID_OK:
- # create string of accessible mapsets
- ms_string = 'PERMANENT'
- if dlg.curr_mapset == 'PERMANENT':
- ms_string = 'PERMANENT'
- else:
- ms_string = 'PERMANENT,%s' % dlg.curr_mapset
- for mset in dlg.all_mapsets:
- index = dlg.all_mapsets.index(mset)
- if dlg.mapsetlb.IsChecked(index):
- ms_string += ',%s' % mset
-
+ ms = dlg.GetMapsets()
# run g.mapsets with string of accessible mapsets
- cmdlist = ['g.mapsets', 'mapset=%s' % ms_string]
+ cmdlist = ['g.mapsets', 'mapset=%s' % ','.join(ms)]
gcmd.Command(cmdlist)
-
+ UserSettings.Set('mapsetPath', ms, internal=True)
+ print UserSettings.Get('mapsetPath', internal=True)
+
def OnRDigit(self, event):
"""
Launch raster digitizing module
@@ -1252,72 +1243,6 @@
dlg.ShowModal()
dlg.Destroy()
-class MapsetAccess(wx.Dialog):
- """
- Controls setting options and displaying/hiding map overlay decorations
- """
- def __init__(self, parent, id, title=_('Set/unset access to mapsets in current location'),
- pos=wx.DefaultPosition, size=(-1,-1),
- style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER):
- wx.Dialog.__init__(self, parent, id, title, pos, size, style)
-
- self.all_mapsets, self.accessible_mapsets = utils.ListOfMapsets()
- self.curr_mapset = grassenv.GetGRASSVariable('MAPSET')
-
- # remove PERMANENT and current mapset from list because they are always accessible
- self.PERMANENT_ndx = self.all_mapsets.index("PERMANENT")
- self.all_mapsets.pop(self.PERMANENT_ndx)
- if self.curr_mapset != "PERMANENT":
- self.curr_ndx = self.all_mapsets.index(self.curr_mapset)
- self.all_mapsets.pop(self.curr_ndx)
-
- # make a checklistbox from available mapsets and check those that are active
- sizer = wx.BoxSizer(wx.VERTICAL)
-
- box = wx.BoxSizer(wx.HORIZONTAL)
- if len(self.all_mapsets) == 0:
- label = wx.StaticText(self, -1, "No other accessible mapsets besides \
- \nPERMANENT and current mapset.",
- style=wx.ALIGN_CENTRE)
- else:
- label = wx.StaticText(self, -1, "Check mapset to make it accessible, uncheck it to hide it.\
- \nPERMANENT and current mapset are always accessible.",
- style=wx.ALIGN_CENTRE)
- box.Add(label, 0, wx.ALIGN_CENTRE)
- sizer.Add(box, 0, wx.ALIGN_CENTRE|wx.TOP|wx.BOTTOM, 5)
-
- box = wx.BoxSizer(wx.HORIZONTAL)
- self.mapsetlb = wx.CheckListBox(self, -1, pos=wx.DefaultPosition,
- size=(350,200), choices=self.all_mapsets)
- box.Add(self.mapsetlb, 0, wx.ALIGN_CENTRE)
- sizer.Add(box, 0, wx.ALIGN_CENTRE|wx.TOP|wx.BOTTOM, 5)
-
- # check all accessible mapsets
- for mset in self.accessible_mapsets:
- if mset != 'PERMANENT' and mset != self.curr_mapset:
- self.mapsetlb.Check(self.all_mapsets.index(mset),True)
-
- # dialog buttons
- line = wx.StaticLine(self, -1, size=(-1,-1), style=wx.LI_HORIZONTAL)
- sizer.Add(line, 0, wx.EXPAND|wx.ALIGN_CENTRE|wx.TOP|wx.BOTTOM, 5)
-
- btnsizer = wx.StdDialogButtonSizer()
-
- okbtn = wx.Button(self, wx.ID_OK)
- okbtn.SetDefault()
- btnsizer.AddButton(okbtn)
-
- cancelbtn = wx.Button(self, wx.ID_CANCEL)
- btnsizer.AddButton(cancelbtn)
- btnsizer.Realize()
-
- sizer.Add(btnsizer, 0, wx.EXPAND|wx.ALIGN_RIGHT|wx.ALL, 5)
-
- self.Layout()
- self.SetSizer(sizer)
-
- sizer.Fit(self)
-
class GMApp(wx.App):
"""
GMApp class
More information about the grass-commit
mailing list