GRASS Programmer's Manual  6.4.3(2013)-r
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages
gui_core/preferences.py
Go to the documentation of this file.
1 """!
2 @package gui_core.preferences
3 
4 @brief User preferences dialog
5 
6 Sets default display font, etc. If you want to add some value to
7 settings you have to add default value to defaultSettings and set
8 constraints in internalSettings in Settings class. Everything can be
9 used in PreferencesDialog.
10 
11 Classes:
12  - preferences::PreferencesBaseDialog
13  - preferences::PreferencesDialog
14  - preferences::DefaultFontDialog
15  - preferences::MapsetAccess
16  - preferences::CheckListMapset
17 
18 (C) 2007-2012 by the GRASS Development Team
19 
20 This program is free software under the GNU General Public License
21 (>=v2). Read the file COPYING that comes with GRASS for details.
22 
23 @author Michael Barton (Arizona State University)
24 @author Martin Landa <landa.martin gmail.com>
25 @author Vaclav Petras <wenzeslaus gmail.com> (menu customization)
26 @author Luca Delucchi <lucadeluge gmail.com> (language choice)
27 """
28 
29 import os
30 import sys
31 import copy
32 import locale
33 try:
34  import pwd
35  havePwd = True
36 except ImportError:
37  havePwd = False
38 
39 import wx
40 import wx.lib.colourselect as csel
41 import wx.lib.mixins.listctrl as listmix
42 import wx.lib.scrolledpanel as SP
43 
44 from wx.lib.newevent import NewEvent
45 
46 from grass.script import core as grass
47 
48 from core import globalvar
49 from core.gcmd import RunCommand
50 from core.utils import ListOfMapsets, GetColorTables, ReadEpsgCodes, GetSettingsPath
51 from core.settings import UserSettings
52 from gui_core.widgets import IntegerValidator
53 
54 wxSettingsChanged, EVT_SETTINGS_CHANGED = NewEvent()
55 
56 class PreferencesBaseDialog(wx.Dialog):
57  """!Base preferences dialog"""
58  def __init__(self, parent, settings, title = _("User settings"),
59  size = (500, 475),
60  style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
61  self.parent = parent # ModelerFrame
62  self.title = title
63  self.size = size
64  self.settings = settings
65 
66  wx.Dialog.__init__(self, parent = parent, id = wx.ID_ANY, title = title,
67  style = style)
68 
69  # notebook
70  self.notebook = wx.Notebook(parent = self, id = wx.ID_ANY, style = wx.BK_DEFAULT)
71 
72  # dict for window ids
73  self.winId = {}
74 
75  # create notebook pages
76 
77  # buttons
78  self.btnDefault = wx.Button(self, wx.ID_ANY, _("Set to default"))
79  self.btnSave = wx.Button(self, wx.ID_SAVE)
80  self.btnApply = wx.Button(self, wx.ID_APPLY)
81  self.btnCancel = wx.Button(self, wx.ID_CANCEL)
82  self.btnSave.SetDefault()
83 
84  # bindigs
85  self.btnDefault.Bind(wx.EVT_BUTTON, self.OnDefault)
86  self.btnDefault.SetToolTipString(_("Revert settings to default and apply changes"))
87  self.btnApply.Bind(wx.EVT_BUTTON, self.OnApply)
88  self.btnApply.SetToolTipString(_("Apply changes for the current session"))
89  self.btnSave.Bind(wx.EVT_BUTTON, self.OnSave)
90  self.btnSave.SetToolTipString(_("Apply and save changes to user settings file (default for next sessions)"))
91  self.btnSave.SetDefault()
92  self.btnCancel.Bind(wx.EVT_BUTTON, self.OnCancel)
93  self.btnCancel.SetToolTipString(_("Close dialog and ignore changes"))
94 
95  self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
96 
97  self._layout()
98 
99  def _layout(self):
100  """!Layout window"""
101  # sizers
102  btnSizer = wx.BoxSizer(wx.HORIZONTAL)
103  btnSizer.Add(item = self.btnDefault, proportion = 1,
104  flag = wx.ALL, border = 5)
105  btnStdSizer = wx.StdDialogButtonSizer()
106  btnStdSizer.AddButton(self.btnCancel)
107  btnStdSizer.AddButton(self.btnSave)
108  btnStdSizer.AddButton(self.btnApply)
109  btnStdSizer.Realize()
110 
111  mainSizer = wx.BoxSizer(wx.VERTICAL)
112  mainSizer.Add(item = self.notebook, proportion = 1, flag = wx.EXPAND | wx.ALL, border = 5)
113  mainSizer.Add(item = btnSizer, proportion = 0,
114  flag = wx.EXPAND, border = 0)
115  mainSizer.Add(item = btnStdSizer, proportion = 0,
116  flag = wx.EXPAND | wx.ALL | wx.ALIGN_RIGHT, border = 5)
117 
118  self.SetSizer(mainSizer)
119  mainSizer.Fit(self)
120 
121  def OnDefault(self, event):
122  """!Button 'Set to default' pressed"""
123  self.settings.userSettings = copy.deepcopy(self.settings.defaultSettings)
124 
125  # update widgets
126  for gks in self.winId.keys():
127  try:
128  group, key, subkey = gks.split(':')
129  value = self.settings.Get(group, key, subkey)
130  except ValueError:
131  group, key, subkey, subkey1 = gks.split(':')
132  value = self.settings.Get(group, key, [subkey, subkey1])
133  win = self.FindWindowById(self.winId[gks])
134 
135  if win.GetName() in ('GetValue', 'IsChecked'):
136  value = win.SetValue(value)
137  elif win.GetName() == 'GetSelection':
138  value = win.SetSelection(value)
139  elif win.GetName() == 'GetStringSelection':
140  value = win.SetStringSelection(value)
141  else:
142  value = win.SetValue(value)
143 
144  def OnApply(self, event):
145  """!Button 'Apply' pressed
146  Posts event EVT_SETTINGS_CHANGED.
147  """
148  if self._updateSettings():
149  self.parent.goutput.WriteLog(_('Settings applied to current session but not saved'))
150  event = wxSettingsChanged()
151  wx.PostEvent(self, event)
152  self.Close()
153 
154  def OnCloseWindow(self, event):
155  self.Hide()
156 
157  def OnCancel(self, event):
158  """!Button 'Cancel' pressed"""
159  self.Close()
160 
161  def OnSave(self, event):
162  """!Button 'Save' pressed
163  Posts event EVT_SETTINGS_CHANGED.
164  """
165  if self._updateSettings():
166  lang = self.settings.Get(group = 'language', key = 'locale', subkey = 'lc_all')
167  if lang == 'system':
168  # Most fool proof way to use system locale is to not provide any locale info at all
169  self.settings.Set(group = 'language', key = 'locale', subkey = 'lc_all', value = None)
170  lang = None
171  if lang == 'en':
172  # GRASS doesn't ship EN translation, default texts have to be used instead
173  self.settings.Set(group = 'language', key = 'locale', subkey = 'lc_all', value = 'C')
174  lang = 'C'
175  self.settings.SaveToFile()
176  self.parent.goutput.WriteLog(_('Settings saved to file \'%s\'.') % self.settings.filePath)
177  if lang:
178  RunCommand('g.gisenv', set = 'LANG=%s' % lang)
179  else:
180  RunCommand('g.gisenv', set = 'LANG=')
181  event = wxSettingsChanged()
182  wx.PostEvent(self, event)
183  self.Close()
184 
185  def _updateSettings(self):
186  """!Update user settings"""
187  for item in self.winId.keys():
188  try:
189  group, key, subkey = item.split(':')
190  subkey1 = None
191  except ValueError:
192  group, key, subkey, subkey1 = item.split(':')
193 
194  id = self.winId[item]
195  win = self.FindWindowById(id)
196  if win.GetName() == 'GetValue':
197  value = win.GetValue()
198  elif win.GetName() == 'GetSelection':
199  value = win.GetSelection()
200  elif win.GetName() == 'IsChecked':
201  value = win.IsChecked()
202  elif win.GetName() == 'GetStringSelection':
203  value = win.GetStringSelection()
204  elif win.GetName() == 'GetColour':
205  value = tuple(win.GetValue())
206  else:
207  value = win.GetValue()
208 
209  if key == 'keycolumn' and value == '':
210  wx.MessageBox(parent = self,
211  message = _("Key column cannot be empty string."),
212  caption = _("Error"), style = wx.OK | wx.ICON_ERROR)
213  win.SetValue(self.settings.Get(group = 'atm', key = 'keycolumn', subkey = 'value'))
214  return False
215 
216  if subkey1:
217  self.settings.Set(group, value, key, [subkey, subkey1])
218  else:
219  self.settings.Set(group, value, key, subkey)
220 
221  if self.parent.GetName() == 'Modeler':
222  return True
223 
224  #
225  # update default window dimension
226  #
227  if self.settings.Get(group = 'general', key = 'defWindowPos', subkey = 'enabled') is True:
228  dim = ''
229  # layer manager
230  pos = self.parent.GetPosition()
231  size = self.parent.GetSize()
232  dim = '%d,%d,%d,%d' % (pos[0], pos[1], size[0], size[1])
233  # opened displays
234  for page in range(0, self.parent.gm_cb.GetPageCount()):
235  pos = self.parent.gm_cb.GetPage(page).maptree.mapdisplay.GetPosition()
236  size = self.parent.gm_cb.GetPage(page).maptree.mapdisplay.GetSize()
237 
238  dim += ',%d,%d,%d,%d' % (pos[0], pos[1], size[0], size[1])
239 
240  self.settings.Set(group = 'general', key = 'defWindowPos', subkey = 'dim', value = dim)
241  else:
242  self.settings.Set(group = 'general', key = 'defWindowPos', subkey = 'dim', value = '')
243 
244  return True
245 
247  """!User preferences dialog"""
248  def __init__(self, parent, title = _("GUI Settings"),
249  settings = UserSettings):
250 
251  PreferencesBaseDialog.__init__(self, parent = parent, title = title,
252  settings = settings)
253 
254  # create notebook pages
255  self._createGeneralPage(self.notebook)
257  self._createDisplayPage(self.notebook)
258  self._createCmdPage(self.notebook)
261 
262  self.SetMinSize(self.GetBestSize())
263  self.SetSize(self.size)
264 
265  def _createGeneralPage(self, notebook):
266  """!Create notebook page for general settings"""
267  panel = SP.ScrolledPanel(parent = notebook, id = wx.ID_ANY)
268  panel.SetupScrolling(scroll_x = False, scroll_y = True)
269  notebook.AddPage(page = panel, text = _("General"))
270 
271  border = wx.BoxSizer(wx.VERTICAL)
272  #
273  # Layer Manager settings
274  #
275  box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Layer Manager settings"))
276  sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
277 
278  gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
279  gridSizer.AddGrowableCol(0)
280 
281  #
282  # ask when removing map layer from layer tree
283  #
284  row = 0
285  askOnRemoveLayer = wx.CheckBox(parent = panel, id = wx.ID_ANY,
286  label = _("Ask when removing map layer from layer tree"),
287  name = 'IsChecked')
288  askOnRemoveLayer.SetValue(self.settings.Get(group = 'manager', key = 'askOnRemoveLayer', subkey = 'enabled'))
289  self.winId['manager:askOnRemoveLayer:enabled'] = askOnRemoveLayer.GetId()
290 
291  gridSizer.Add(item = askOnRemoveLayer,
292  pos = (row, 0), span = (1, 2))
293 
294  row += 1
295  askOnQuit = wx.CheckBox(parent = panel, id = wx.ID_ANY,
296  label = _("Ask when quiting wxGUI or closing display"),
297  name = 'IsChecked')
298  askOnQuit.SetValue(self.settings.Get(group = 'manager', key = 'askOnQuit', subkey = 'enabled'))
299  self.winId['manager:askOnQuit:enabled'] = askOnQuit.GetId()
300 
301  gridSizer.Add(item = askOnQuit,
302  pos = (row, 0), span = (1, 2))
303 
304  row += 1
305  hideSearch = wx.CheckBox(parent = panel, id = wx.ID_ANY,
306  label = _("Hide '%s' tab (requires GUI restart)") % _("Search module"),
307  name = 'IsChecked')
308  hideSearch.SetValue(self.settings.Get(group = 'manager', key = 'hideTabs', subkey = 'search'))
309  self.winId['manager:hideTabs:search'] = hideSearch.GetId()
310 
311  gridSizer.Add(item = hideSearch,
312  pos = (row, 0), span = (1, 2))
313 
314  row += 1
315  hidePyShell = wx.CheckBox(parent = panel, id = wx.ID_ANY,
316  label = _("Hide '%s' tab (requires GUI restart)") % _("Python shell"),
317  name = 'IsChecked')
318  hidePyShell.SetValue(self.settings.Get(group = 'manager', key = 'hideTabs', subkey = 'pyshell'))
319  self.winId['manager:hideTabs:pyshell'] = hidePyShell.GetId()
320 
321  gridSizer.Add(item = hidePyShell,
322  pos = (row, 0), span = (1, 2))
323 
324  #
325  # Selected text is copied to clipboard
326  #
327  row += 1
328  copySelectedTextToClipboard = wx.CheckBox(parent = panel, id = wx.ID_ANY,
329  label = _("Automatically copy selected text to clipboard (in Command console)"),
330  name = 'IsChecked')
331  copySelectedTextToClipboard.SetValue(self.settings.Get(group = 'manager', key = 'copySelectedTextToClipboard', subkey = 'enabled'))
332  self.winId['manager:copySelectedTextToClipboard:enabled'] = copySelectedTextToClipboard.GetId()
333 
334  gridSizer.Add(item = copySelectedTextToClipboard,
335  pos = (row, 0), span = (1, 2))
336 
337  sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
338  border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
339 
340  #
341  # workspace
342  #
343  box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Workspace settings"))
344  sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
345 
346  gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
347  gridSizer.AddGrowableCol(0)
348 
349  row = 0
350  posDisplay = wx.CheckBox(parent = panel, id = wx.ID_ANY,
351  label = _("Suppress positioning Map Display Window(s)"),
352  name = 'IsChecked')
353  posDisplay.SetValue(self.settings.Get(group = 'general', key = 'workspace',
354  subkey = ['posDisplay', 'enabled']))
355  self.winId['general:workspace:posDisplay:enabled'] = posDisplay.GetId()
356 
357  gridSizer.Add(item = posDisplay,
358  pos = (row, 0), span = (1, 2))
359 
360  row += 1
361 
362  posManager = wx.CheckBox(parent = panel, id = wx.ID_ANY,
363  label = _("Suppress positioning Layer Manager window"),
364  name = 'IsChecked')
365  posManager.SetValue(self.settings.Get(group = 'general', key = 'workspace',
366  subkey = ['posManager', 'enabled']))
367  self.winId['general:workspace:posManager:enabled'] = posManager.GetId()
368 
369  gridSizer.Add(item = posManager,
370  pos = (row, 0), span = (1, 2))
371 
372  row += 1
373  defaultPos = wx.CheckBox(parent = panel, id = wx.ID_ANY,
374  label = _("Save current window layout as default"),
375  name = 'IsChecked')
376  defaultPos.SetValue(self.settings.Get(group = 'general', key = 'defWindowPos', subkey = 'enabled'))
377  defaultPos.SetToolTip(wx.ToolTip (_("Save current position and size of Layer Manager window and opened "
378  "Map Display window(s) and use as default for next sessions.")))
379  self.winId['general:defWindowPos:enabled'] = defaultPos.GetId()
380 
381  gridSizer.Add(item = defaultPos,
382  pos = (row, 0), span = (1, 2))
383 
384  sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
385  border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
386 
387  panel.SetSizer(border)
388 
389  return panel
390 
391 
392  panel.SetSizer(border)
393 
394  return panel
395 
396  def _createAppearancePage(self, notebook):
397  """!Create notebook page for display settings"""
398  panel = SP.ScrolledPanel(parent = notebook, id = wx.ID_ANY)
399  panel.SetupScrolling(scroll_x = False, scroll_y = True)
400  notebook.AddPage(page = panel, text = _("Appearance"))
401 
402  border = wx.BoxSizer(wx.VERTICAL)
403 
404  box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Font settings"))
405  sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
406 
407  gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
408  gridSizer.AddGrowableCol(0)
409 
410  #
411  # font settings
412  #
413  sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
414  border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
415 
416  row = 0
417  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
418  label = _("Font for command output:")),
419  flag = wx.ALIGN_LEFT |
420  wx.ALIGN_CENTER_VERTICAL,
421  pos = (row, 0))
422  outfontButton = wx.Button(parent = panel, id = wx.ID_ANY,
423  label = _("Set font"), size = (100, -1))
424  gridSizer.Add(item = outfontButton,
425  flag = wx.ALIGN_RIGHT |
426  wx.ALIGN_CENTER_VERTICAL,
427  pos = (row, 1))
428 
429  #
430  # languages
431  #
432  box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Language settings"))
433  sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
434 
435  gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
436  gridSizer.AddGrowableCol(0)
437  sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
438  border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
439 
440  row = 0
441  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
442  label = _("Choose language (requires to save and GRASS restart):")),
443  flag = wx.ALIGN_LEFT |
444  wx.ALIGN_CENTER_VERTICAL,
445  pos = (row, 0))
446  locales = self.settings.Get(group = 'language', key = 'locale',
447  subkey = 'choices', internal = True)
448  loc = self.settings.Get(group = 'language', key = 'locale', subkey = 'lc_all')
449  elementList = wx.Choice(parent = panel, id = wx.ID_ANY, size = (325, -1),
450  choices = locales, name = "GetStringSelection")
451  if loc in locales:
452  elementList.SetStringSelection(loc)
453  if loc == 'C':
454  elementList.SetStringSelection('en')
455  self.winId['language:locale:lc_all'] = elementList.GetId()
456 
457  gridSizer.Add(item = elementList,
458  flag = wx.ALIGN_RIGHT |
459  wx.ALIGN_CENTER_VERTICAL,
460  pos = (row, 1))
461  #
462  # appearence
463  #
464  box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Appearance settings"))
465  sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
466 
467  gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
468  gridSizer.AddGrowableCol(0)
469 
470  #
471  # element list
472  #
473  row = 0
474  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
475  label = _("Element list:")),
476  flag = wx.ALIGN_LEFT |
477  wx.ALIGN_CENTER_VERTICAL,
478  pos = (row, 0))
479  elementList = wx.Choice(parent = panel, id = wx.ID_ANY, size = (325, -1),
480  choices = self.settings.Get(group = 'appearance', key = 'elementListExpand',
481  subkey = 'choices', internal = True),
482  name = "GetSelection")
483  elementList.SetSelection(self.settings.Get(group = 'appearance', key = 'elementListExpand',
484  subkey = 'selection'))
485  self.winId['appearance:elementListExpand:selection'] = elementList.GetId()
486 
487  gridSizer.Add(item = elementList,
488  flag = wx.ALIGN_RIGHT |
489  wx.ALIGN_CENTER_VERTICAL,
490  pos = (row, 1))
491 
492  #
493  # menu style
494  #
495  row += 1
496  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
497  label = _("Menu style (requires to save and GUI restart):")),
498  flag = wx.ALIGN_LEFT |
499  wx.ALIGN_CENTER_VERTICAL,
500  pos = (row, 0))
501  listOfStyles = self.settings.Get(group = 'appearance', key = 'menustyle',
502  subkey = 'choices', internal = True)
503 
504  menuItemText = wx.Choice(parent = panel, id = wx.ID_ANY, size = (325, -1),
505  choices = listOfStyles,
506  name = "GetSelection")
507  menuItemText.SetSelection(self.settings.Get(group = 'appearance', key = 'menustyle', subkey = 'selection'))
508 
509  self.winId['appearance:menustyle:selection'] = menuItemText.GetId()
510 
511  gridSizer.Add(item = menuItemText,
512  flag = wx.ALIGN_RIGHT,
513  pos = (row, 1))
514 
515  #
516  # gselect.TreeCtrlComboPopup height
517  #
518  row += 1
519 
520  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
521  label = _("Height of map selection popup window (in pixels):")),
522  flag = wx.ALIGN_LEFT |
523  wx.ALIGN_CENTER_VERTICAL,
524  pos = (row, 0))
525  min = self.settings.Get(group = 'appearance', key = 'gSelectPopupHeight', subkey = 'min', internal = True)
526  max = self.settings.Get(group = 'appearance', key = 'gSelectPopupHeight', subkey = 'max', internal = True)
527  value = self.settings.Get(group = 'appearance', key = 'gSelectPopupHeight', subkey = 'value')
528 
529  popupHeightSpin = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (100, -1))
530  popupHeightSpin.SetRange(min,max)
531  popupHeightSpin.SetValue(value)
532 
533  self.winId['appearance:gSelectPopupHeight:value'] = popupHeightSpin.GetId()
534 
535  gridSizer.Add(item = popupHeightSpin,
536  flag = wx.ALIGN_RIGHT,
537  pos = (row, 1))
538 
539 
540  #
541  # icon theme
542  #
543  row += 1
544  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
545  label = _("Icon theme (requires GUI restart):")),
546  flag = wx.ALIGN_LEFT |
547  wx.ALIGN_CENTER_VERTICAL,
548  pos = (row, 0))
549  iconTheme = wx.Choice(parent = panel, id = wx.ID_ANY, size = (100, -1),
550  choices = self.settings.Get(group = 'appearance', key = 'iconTheme',
551  subkey = 'choices', internal = True),
552  name = "GetStringSelection")
553  iconTheme.SetStringSelection(self.settings.Get(group = 'appearance', key = 'iconTheme', subkey = 'type'))
554  self.winId['appearance:iconTheme:type'] = iconTheme.GetId()
555 
556  gridSizer.Add(item = iconTheme,
557  flag = wx.ALIGN_RIGHT |
558  wx.ALIGN_CENTER_VERTICAL,
559  pos = (row, 1))
560 
561  sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
562  border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
563 
564  panel.SetSizer(border)
565 
566  # bindings
567  outfontButton.Bind(wx.EVT_BUTTON, self.OnSetOutputFont)
568 
569  return panel
570 
571  def _createDisplayPage(self, notebook):
572  """!Create notebook page for display settings"""
573  panel = SP.ScrolledPanel(parent = notebook, id = wx.ID_ANY)
574  panel.SetupScrolling(scroll_x = False, scroll_y = True)
575  notebook.AddPage(page = panel, text = _("Map Display"))
576 
577  border = wx.BoxSizer(wx.VERTICAL)
578 
579  box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Font settings"))
580  sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
581 
582  gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
583  gridSizer.AddGrowableCol(0)
584 
585  #
586  # font settings
587  #
588  row = 0
589  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
590  label = _("Default font for GRASS displays:")),
591  flag = wx.ALIGN_LEFT |
592  wx.ALIGN_CENTER_VERTICAL,
593  pos = (row, 0))
594  fontButton = wx.Button(parent = panel, id = wx.ID_ANY,
595  label = _("Set font"), size = (100, -1))
596  gridSizer.Add(item = fontButton,
597  flag = wx.ALIGN_RIGHT |
598  wx.ALIGN_CENTER_VERTICAL,
599  pos = (row, 1))
600 
601  sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
602  border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
603 
604  #
605  # display settings
606  #
607  box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Default display settings"))
608  sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
609 
610  gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
611  gridSizer.AddGrowableCol(0)
612 
613 
614  #
615  # display driver
616  #
617  row = 0
618  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
619  label = _("Display driver:")),
620  flag = wx.ALIGN_LEFT |
621  wx.ALIGN_CENTER_VERTICAL,
622  pos=(row, 0))
623  listOfDrivers = self.settings.Get(group='display', key='driver', subkey='choices', internal=True)
624  # check if cairo is available
625  if 'cairo' not in listOfDrivers:
626  for line in RunCommand('d.mon',
627  flags = 'l',
628  read = True).splitlines():
629  if 'cairo' in line:
630  # FIXME: commented out, d.mon<->cairo driver<->wxgui hangs the GUI: #943
631  #listOfDrivers.append('cairo')
632  break
633 
634  driver = wx.Choice(parent=panel, id=wx.ID_ANY, size=(150, -1),
635  choices=listOfDrivers,
636  name="GetStringSelection")
637  driver.SetStringSelection(self.settings.Get(group='display', key='driver', subkey='type'))
638  self.winId['display:driver:type'] = driver.GetId()
639 
640  gridSizer.Add(item = driver,
641  flag = wx.ALIGN_RIGHT,
642  pos = (row, 1))
643 
644  #
645  # Statusbar mode
646  #
647  row += 1
648  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
649  label = _("Statusbar mode:")),
650  flag = wx.ALIGN_LEFT |
651  wx.ALIGN_CENTER_VERTICAL,
652  pos = (row, 0))
653  listOfModes = self.settings.Get(group = 'display', key = 'statusbarMode', subkey = 'choices', internal = True)
654  statusbarMode = wx.Choice(parent = panel, id = wx.ID_ANY, size = (150, -1),
655  choices = listOfModes,
656  name = "GetSelection")
657  statusbarMode.SetSelection(self.settings.Get(group = 'display', key = 'statusbarMode', subkey = 'selection'))
658  self.winId['display:statusbarMode:selection'] = statusbarMode.GetId()
659 
660  gridSizer.Add(item = statusbarMode,
661  flag = wx.ALIGN_RIGHT,
662  pos = (row, 1))
663 
664  #
665  # Background color
666  #
667  row += 1
668  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
669  label = _("Background color:")),
670  flag = wx.ALIGN_LEFT |
671  wx.ALIGN_CENTER_VERTICAL,
672  pos = (row, 0))
673  bgColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
674  colour = self.settings.Get(group = 'display', key = 'bgcolor', subkey = 'color'),
675  size = globalvar.DIALOG_COLOR_SIZE)
676  bgColor.SetName('GetColour')
677  self.winId['display:bgcolor:color'] = bgColor.GetId()
678 
679  gridSizer.Add(item = bgColor,
680  flag = wx.ALIGN_RIGHT,
681  pos = (row, 1))
682 
683  #
684  # Align extent to display size
685  #
686  row += 1
687  alignExtent = wx.CheckBox(parent = panel, id = wx.ID_ANY,
688  label = _("Align region extent based on display size"),
689  name = "IsChecked")
690  alignExtent.SetValue(self.settings.Get(group = 'display', key = 'alignExtent', subkey = 'enabled'))
691  self.winId['display:alignExtent:enabled'] = alignExtent.GetId()
692 
693  gridSizer.Add(item = alignExtent,
694  pos = (row, 0), span = (1, 2))
695 
696  #
697  # Use computation resolution
698  #
699  row += 1
700  compResolution = wx.CheckBox(parent = panel, id = wx.ID_ANY,
701  label = _("Constrain display resolution to computational settings"),
702  name = "IsChecked")
703  compResolution.SetValue(self.settings.Get(group = 'display', key = 'compResolution', subkey = 'enabled'))
704  self.winId['display:compResolution:enabled'] = compResolution.GetId()
705 
706  gridSizer.Add(item = compResolution,
707  pos = (row, 0), span = (1, 2))
708 
709  #
710  # auto-rendering
711  #
712  row += 1
713  autoRendering = wx.CheckBox(parent = panel, id = wx.ID_ANY,
714  label = _("Enable auto-rendering"),
715  name = "IsChecked")
716  autoRendering.SetValue(self.settings.Get(group = 'display', key = 'autoRendering', subkey = 'enabled'))
717  self.winId['display:autoRendering:enabled'] = autoRendering.GetId()
718 
719  gridSizer.Add(item = autoRendering,
720  pos = (row, 0), span = (1, 2))
721 
722  #
723  # auto-zoom
724  #
725  row += 1
726  autoZooming = wx.CheckBox(parent = panel, id = wx.ID_ANY,
727  label = _("Enable auto-zooming to selected map layer"),
728  name = "IsChecked")
729  autoZooming.SetValue(self.settings.Get(group = 'display', key = 'autoZooming', subkey = 'enabled'))
730  self.winId['display:autoZooming:enabled'] = autoZooming.GetId()
731 
732  gridSizer.Add(item = autoZooming,
733  pos = (row, 0), span = (1, 2))
734 
735  #
736  # mouse wheel zoom
737  #
738  row += 1
739  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
740  label = _("Mouse wheel action:")),
741  flag = wx.ALIGN_LEFT |
742  wx.ALIGN_CENTER_VERTICAL,
743  pos = (row, 0))
744  listOfModes = self.settings.Get(group = 'display', key = 'mouseWheelZoom', subkey = 'choices', internal = True)
745  zoomAction = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
746  choices = listOfModes,
747  name = "GetSelection")
748  zoomAction.SetSelection(self.settings.Get(group = 'display', key = 'mouseWheelZoom', subkey = 'selection'))
749  self.winId['display:mouseWheelZoom:selection'] = zoomAction.GetId()
750  gridSizer.Add(item = zoomAction,
751  flag = wx.ALIGN_RIGHT,
752  pos = (row, 1))
753  row += 1
754  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
755  label = _("Mouse scrolling direction:")),
756  flag = wx.ALIGN_LEFT |
757  wx.ALIGN_CENTER_VERTICAL,
758  pos = (row, 0))
759  listOfModes = self.settings.Get(group = 'display', key = 'scrollDirection', subkey = 'choices', internal = True)
760  scrollDir = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
761  choices = listOfModes,
762  name = "GetSelection")
763  scrollDir.SetSelection(self.settings.Get(group = 'display', key = 'scrollDirection', subkey = 'selection'))
764  self.winId['display:scrollDirection:selection'] = scrollDir.GetId()
765  gridSizer.Add(item = scrollDir,
766  flag = wx.ALIGN_RIGHT,
767  pos = (row, 1))
768 
769  sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
770  border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
771 
772 
773  #
774  # advanced
775  #
776 
777  # see initialization of nviz GLWindow
778  if globalvar.CheckWxVersion(version=[2, 8, 11]) and \
779  sys.platform not in ('win32', 'darwin'):
780  box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Advanced display settings"))
781  sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
782 
783  gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
784  row = 0
785  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
786  label = _("3D view depth buffer (possible values are 16, 24, 32):")),
787  flag = wx.ALIGN_LEFT |
788  wx.ALIGN_CENTER_VERTICAL,
789  pos = (row, 0))
790  value = self.settings.Get(group='display', key='nvizDepthBuffer', subkey='value')
791  textCtrl = wx.TextCtrl(parent=panel, id=wx.ID_ANY, value=str(value), validator=IntegerValidator())
792  self.winId['display:nvizDepthBuffer:value'] = textCtrl.GetId()
793  gridSizer.Add(item = textCtrl,
794  flag = wx.ALIGN_RIGHT |
795  wx.ALIGN_CENTER_VERTICAL,
796  pos = (row, 1))
797 
798  gridSizer.AddGrowableCol(0)
799  sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
800  border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
801 
802  panel.SetSizer(border)
803 
804  # bindings
805  fontButton.Bind(wx.EVT_BUTTON, self.OnSetFont)
806  zoomAction.Bind(wx.EVT_CHOICE, self.OnEnableWheelZoom)
807 
808  # enable/disable controls according to settings
809  self.OnEnableWheelZoom(None)
810 
811  return panel
812 
813  def _createCmdPage(self, notebook):
814  """!Create notebook page for commad dialog settings"""
815  panel = SP.ScrolledPanel(parent = notebook, id = wx.ID_ANY)
816  panel.SetupScrolling(scroll_x = False, scroll_y = True)
817  notebook.AddPage(page = panel, text = _("Command"))
818 
819  border = wx.BoxSizer(wx.VERTICAL)
820  box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Command dialog settings"))
821  sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
822 
823  gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
824  gridSizer.AddGrowableCol(0)
825 
826  #
827  # command dialog settings
828  #
829  row = 0
830  # overwrite
831  overwrite = wx.CheckBox(parent = panel, id = wx.ID_ANY,
832  label = _("Allow output files to overwrite existing files"),
833  name = "IsChecked")
834  overwrite.SetValue(self.settings.Get(group = 'cmd', key = 'overwrite', subkey = 'enabled'))
835  self.winId['cmd:overwrite:enabled'] = overwrite.GetId()
836 
837  gridSizer.Add(item = overwrite,
838  pos = (row, 0), span = (1, 2))
839  row += 1
840  # close
841  close = wx.CheckBox(parent = panel, id = wx.ID_ANY,
842  label = _("Close dialog when command is successfully finished"),
843  name = "IsChecked")
844  close.SetValue(self.settings.Get(group = 'cmd', key = 'closeDlg', subkey = 'enabled'))
845  self.winId['cmd:closeDlg:enabled'] = close.GetId()
846 
847  gridSizer.Add(item = close,
848  pos = (row, 0), span = (1, 2))
849  row += 1
850  # add layer
851  add = wx.CheckBox(parent = panel, id = wx.ID_ANY,
852  label = _("Add created map into layer tree"),
853  name = "IsChecked")
854  add.SetValue(self.settings.Get(group = 'cmd', key = 'addNewLayer', subkey = 'enabled'))
855  self.winId['cmd:addNewLayer:enabled'] = add.GetId()
856 
857  gridSizer.Add(item = add,
858  pos = (row, 0), span = (1, 2))
859 
860  row += 1
861  # interactive input
862  interactive = wx.CheckBox(parent = panel, id = wx.ID_ANY,
863  label = _("Allow interactive input"),
864  name = "IsChecked")
865  interactive.SetValue(self.settings.Get(group = 'cmd', key = 'interactiveInput', subkey = 'enabled'))
866  self.winId['cmd:interactiveInput:enabled'] = interactive.GetId()
867  gridSizer.Add(item = interactive,
868  pos = (row, 0), span = (1, 2))
869 
870  row += 1
871  # verbosity
872  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
873  label = _("Verbosity level:")),
874  flag = wx.ALIGN_LEFT |
875  wx.ALIGN_CENTER_VERTICAL,
876  pos = (row, 0))
877  verbosity = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
878  choices = self.settings.Get(group = 'cmd', key = 'verbosity', subkey = 'choices', internal = True),
879  name = "GetStringSelection")
880  verbosity.SetStringSelection(self.settings.Get(group = 'cmd', key = 'verbosity', subkey = 'selection'))
881  self.winId['cmd:verbosity:selection'] = verbosity.GetId()
882 
883  gridSizer.Add(item = verbosity,
884  pos = (row, 1), flag = wx.ALIGN_RIGHT)
885 
886  sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
887  border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
888 
889  #
890  # raster settings
891  #
892  box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Raster settings"))
893  sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
894 
895  gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
896  gridSizer.AddGrowableCol(0)
897 
898  #
899  # raster overlay
900  #
901  row = 0
902  rasterOverlay = wx.CheckBox(parent=panel, id=wx.ID_ANY,
903  label=_("Overlay raster maps"),
904  name='IsChecked')
905  rasterOverlay.SetValue(self.settings.Get(group='cmd', key='rasterOverlay', subkey='enabled'))
906  self.winId['cmd:rasterOverlay:enabled'] = rasterOverlay.GetId()
907 
908  gridSizer.Add(item=rasterOverlay,
909  pos=(row, 0), span=(1, 2))
910 
911  # default color table
912  row += 1
913  rasterCTCheck = wx.CheckBox(parent = panel, id = wx.ID_ANY,
914  label = _("Default color table"),
915  name = 'IsChecked')
916  rasterCTCheck.SetValue(self.settings.Get(group = 'cmd', key = 'rasterColorTable', subkey = 'enabled'))
917  self.winId['cmd:rasterColorTable:enabled'] = rasterCTCheck.GetId()
918  rasterCTCheck.Bind(wx.EVT_CHECKBOX, self.OnCheckColorTable)
919 
920  gridSizer.Add(item = rasterCTCheck, flag = wx.ALIGN_CENTER_VERTICAL,
921  pos = (row, 0))
922 
923  rasterCTName = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
924  choices = GetColorTables(),
925  name = "GetStringSelection")
926  rasterCTName.SetStringSelection(self.settings.Get(group = 'cmd', key = 'rasterColorTable', subkey = 'selection'))
927  self.winId['cmd:rasterColorTable:selection'] = rasterCTName.GetId()
928  if not rasterCTCheck.IsChecked():
929  rasterCTName.Enable(False)
930 
931  gridSizer.Add(item = rasterCTName,
932  pos = (row, 1))
933 
934  sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
935  border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
936 
937  #
938  # vector settings
939  #
940  box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Vector settings"))
941  sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
942 
943  gridSizer = wx.FlexGridSizer (cols = 7, hgap = 3, vgap = 3)
944 
945  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
946  label = _("Display:")),
947  flag = wx.ALIGN_CENTER_VERTICAL)
948 
949  for type in ('point', 'line', 'centroid', 'boundary',
950  'area', 'face'):
951  chkbox = wx.CheckBox(parent = panel, label = type)
952  checked = self.settings.Get(group = 'cmd', key = 'showType',
953  subkey = [type, 'enabled'])
954  chkbox.SetValue(checked)
955  self.winId['cmd:showType:%s:enabled' % type] = chkbox.GetId()
956  gridSizer.Add(item = chkbox)
957 
958  sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
959  border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
960 
961  panel.SetSizer(border)
962 
963  return panel
964 
965  def _createAttributeManagerPage(self, notebook):
966  """!Create notebook page for 'Attribute Table Manager' settings"""
967  panel = SP.ScrolledPanel(parent = notebook, id = wx.ID_ANY)
968  panel.SetupScrolling(scroll_x = False, scroll_y = True)
969  notebook.AddPage(page = panel, text = _("Attributes"))
970 
971  pageSizer = wx.BoxSizer(wx.VERTICAL)
972 
973  #
974  # highlighting
975  #
976  highlightBox = wx.StaticBox(parent = panel, id = wx.ID_ANY,
977  label = " %s " % _("Highlighting"))
978  highlightSizer = wx.StaticBoxSizer(highlightBox, wx.VERTICAL)
979 
980  flexSizer = wx.FlexGridSizer (cols = 2, hgap = 5, vgap = 5)
981  flexSizer.AddGrowableCol(0)
982 
983  label = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _("Color:"))
984  hlColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
985  colour = self.settings.Get(group = 'atm', key = 'highlight', subkey = 'color'),
986  size = globalvar.DIALOG_COLOR_SIZE)
987  hlColor.SetName('GetColour')
988  self.winId['atm:highlight:color'] = hlColor.GetId()
989 
990  flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
991  flexSizer.Add(hlColor, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
992 
993  label = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _("Line width (in pixels):"))
994  hlWidth = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (50, -1),
995  initial = self.settings.Get(group = 'atm', key = 'highlight',subkey = 'width'),
996  min = 1, max = 1e6)
997  self.winId['atm:highlight:width'] = hlWidth.GetId()
998 
999  flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
1000  flexSizer.Add(hlWidth, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
1001 
1002  highlightSizer.Add(item = flexSizer,
1003  proportion = 0,
1004  flag = wx.ALL | wx.EXPAND,
1005  border = 5)
1006 
1007  pageSizer.Add(item = highlightSizer,
1008  proportion = 0,
1009  flag = wx.ALL | wx.EXPAND,
1010  border = 5)
1011 
1012  #
1013  # data browser related settings
1014  #
1015  dataBrowserBox = wx.StaticBox(parent = panel, id = wx.ID_ANY,
1016  label = " %s " % _("Data browser"))
1017  dataBrowserSizer = wx.StaticBoxSizer(dataBrowserBox, wx.VERTICAL)
1018 
1019  flexSizer = wx.FlexGridSizer (cols = 2, hgap = 5, vgap = 5)
1020  flexSizer.AddGrowableCol(0)
1021  label = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _("Left mouse double click:"))
1022  leftDbClick = wx.Choice(parent = panel, id = wx.ID_ANY,
1023  choices = self.settings.Get(group = 'atm', key = 'leftDbClick', subkey = 'choices', internal = True),
1024  name = "GetSelection")
1025  leftDbClick.SetSelection(self.settings.Get(group = 'atm', key = 'leftDbClick', subkey = 'selection'))
1026  self.winId['atm:leftDbClick:selection'] = leftDbClick.GetId()
1027 
1028  flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
1029  flexSizer.Add(leftDbClick, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
1030 
1031  # encoding
1032  label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1033  label = _("Encoding (e.g. utf-8, ascii, iso8859-1, koi8-r):"))
1034  encoding = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
1035  value = self.settings.Get(group = 'atm', key = 'encoding', subkey = 'value'),
1036  name = "GetValue", size = (200, -1))
1037  self.winId['atm:encoding:value'] = encoding.GetId()
1038 
1039  flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
1040  flexSizer.Add(encoding, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
1041 
1042  # ask on delete record
1043  askOnDeleteRec = wx.CheckBox(parent = panel, id = wx.ID_ANY,
1044  label = _("Ask when deleting data record(s) from table"),
1045  name = 'IsChecked')
1046  askOnDeleteRec.SetValue(self.settings.Get(group = 'atm', key = 'askOnDeleteRec', subkey = 'enabled'))
1047  self.winId['atm:askOnDeleteRec:enabled'] = askOnDeleteRec.GetId()
1048 
1049  flexSizer.Add(askOnDeleteRec, proportion = 0)
1050 
1051  dataBrowserSizer.Add(item = flexSizer,
1052  proportion = 0,
1053  flag = wx.ALL | wx.EXPAND,
1054  border = 5)
1055 
1056  pageSizer.Add(item = dataBrowserSizer,
1057  proportion = 0,
1058  flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND,
1059  border = 3)
1060 
1061  #
1062  # create table
1063  #
1064  createTableBox = wx.StaticBox(parent = panel, id = wx.ID_ANY,
1065  label = " %s " % _("Create table"))
1066  createTableSizer = wx.StaticBoxSizer(createTableBox, wx.VERTICAL)
1067 
1068  flexSizer = wx.FlexGridSizer (cols = 2, hgap = 5, vgap = 5)
1069  flexSizer.AddGrowableCol(0)
1070 
1071  label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1072  label = _("Key column:"))
1073  keyColumn = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
1074  size = (250, -1))
1075  keyColumn.SetValue(self.settings.Get(group = 'atm', key = 'keycolumn', subkey = 'value'))
1076  self.winId['atm:keycolumn:value'] = keyColumn.GetId()
1077 
1078  flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
1079  flexSizer.Add(keyColumn, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
1080 
1081  createTableSizer.Add(item = flexSizer,
1082  proportion = 0,
1083  flag = wx.ALL | wx.EXPAND,
1084  border = 5)
1085 
1086  pageSizer.Add(item = createTableSizer,
1087  proportion = 0,
1088  flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND,
1089  border = 3)
1090 
1091  panel.SetSizer(pageSizer)
1092 
1093  return panel
1094 
1095  def _createProjectionPage(self, notebook):
1096  """!Create notebook page for workspace settings"""
1097  panel = SP.ScrolledPanel(parent = notebook, id = wx.ID_ANY)
1098  panel.SetupScrolling(scroll_x = False, scroll_y = True)
1099  notebook.AddPage(page = panel, text = _("Projection"))
1100 
1101  border = wx.BoxSizer(wx.VERTICAL)
1102 
1103  #
1104  # projections statusbar settings
1105  #
1106  box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Projection statusbar settings"))
1107  sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
1108 
1109  gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
1110  gridSizer.AddGrowableCol(1)
1111 
1112  # note for users expecting on-the-fly data reprojection
1113  row = 0
1114  note0 = wx.StaticText(parent = panel, id = wx.ID_ANY,
1115  label = _("\nNote: This only controls the coordinates "
1116  "displayed in the lower-left of the Map "
1117  "Display\nwindow's status bar. It is purely "
1118  "cosmetic and does not affect the working "
1119  "location's\nprojection in any way. You will "
1120  "need to enable the Projection check box in "
1121  "the drop-down\nmenu located at the bottom "
1122  "of the Map Display window.\n"))
1123  gridSizer.Add(item = note0,
1124  span = (1, 2),
1125  pos = (row, 0))
1126 
1127  # epsg
1128  row += 1
1129  label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1130  label = _("EPSG code:"))
1131  epsgCode = wx.ComboBox(parent = panel, id = wx.ID_ANY,
1132  name = "GetValue",
1133  size = (150, -1))
1134  self.epsgCodeDict = dict()
1135  epsgCode.SetValue(str(self.settings.Get(group = 'projection', key = 'statusbar', subkey = 'epsg')))
1136  self.winId['projection:statusbar:epsg'] = epsgCode.GetId()
1137 
1138  gridSizer.Add(item = label,
1139  pos = (row, 0),
1140  flag = wx.ALIGN_CENTER_VERTICAL)
1141  gridSizer.Add(item = epsgCode,
1142  pos = (row, 1), span = (1, 2))
1143 
1144  # proj
1145  row += 1
1146  label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1147  label = _("Proj.4 string (required):"))
1148  projString = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
1149  value = self.settings.Get(group = 'projection', key = 'statusbar', subkey = 'proj4'),
1150  name = "GetValue", size = (400, -1))
1151  self.winId['projection:statusbar:proj4'] = projString.GetId()
1152 
1153  gridSizer.Add(item = label,
1154  pos = (row, 0),
1155  flag = wx.ALIGN_CENTER_VERTICAL)
1156  gridSizer.Add(item = projString,
1157  pos = (row, 1), span = (1, 2),
1158  flag = wx.ALIGN_CENTER_VERTICAL)
1159 
1160  # epsg file
1161  row += 1
1162  label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1163  label = _("EPSG file:"))
1164  projFile = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
1165  value = self.settings.Get(group = 'projection', key = 'statusbar', subkey = 'projFile'),
1166  name = "GetValue", size = (400, -1))
1167  self.winId['projection:statusbar:projFile'] = projFile.GetId()
1168  gridSizer.Add(item = label,
1169  pos = (row, 0),
1170  flag = wx.ALIGN_CENTER_VERTICAL)
1171  gridSizer.Add(item = projFile,
1172  pos = (row, 1),
1173  flag = wx.ALIGN_CENTER_VERTICAL)
1174 
1175  # note + button
1176  row += 1
1177  note = wx.StaticText(parent = panel, id = wx.ID_ANY,
1178  label = _("Load EPSG codes (be patient), enter EPSG code or "
1179  "insert Proj.4 string directly."))
1180  gridSizer.Add(item = note,
1181  span = (1, 2),
1182  pos = (row, 0))
1183 
1184  row += 1
1185  epsgLoad = wx.Button(parent = panel, id = wx.ID_ANY,
1186  label = _("&Load EPSG codes"))
1187  gridSizer.Add(item = epsgLoad,
1188  flag = wx.ALIGN_RIGHT,
1189  pos = (row, 1))
1190 
1191  sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
1192  border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
1193 
1194  #
1195  # format
1196  #
1197  box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Coordinates format"))
1198  sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
1199 
1200  gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
1201  gridSizer.AddGrowableCol(2)
1202 
1203  row = 0
1204  # ll format
1205  ll = wx.RadioBox(parent = panel, id = wx.ID_ANY,
1206  label = " %s " % _("LL projections"),
1207  choices = ["DMS", "DEG"],
1208  name = "GetStringSelection")
1209  self.winId['projection:format:ll'] = ll.GetId()
1210  if self.settings.Get(group = 'projection', key = 'format', subkey = 'll') == 'DMS':
1211  ll.SetSelection(0)
1212  else:
1213  ll.SetSelection(1)
1214 
1215  # precision
1216  precision = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
1217  min = 0, max = 12,
1218  name = "GetValue")
1219  precision.SetValue(int(self.settings.Get(group = 'projection', key = 'format', subkey = 'precision')))
1220  self.winId['projection:format:precision'] = precision.GetId()
1221 
1222  gridSizer.Add(item = ll,
1223  pos = (row, 0))
1224  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
1225  label = _("Precision:")),
1226  flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.LEFT,
1227  border = 20,
1228  pos = (row, 1))
1229  gridSizer.Add(item = precision,
1230  flag = wx.ALIGN_CENTER_VERTICAL,
1231  pos = (row, 2))
1232 
1233 
1234  sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
1235  border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
1236 
1237  panel.SetSizer(border)
1238 
1239  # bindings
1240  epsgLoad.Bind(wx.EVT_BUTTON, self.OnLoadEpsgCodes)
1241  epsgCode.Bind(wx.EVT_COMBOBOX, self.OnSetEpsgCode)
1242  epsgCode.Bind(wx.EVT_TEXT_ENTER, self.OnSetEpsgCode)
1243 
1244  return panel
1245 
1246  def OnCheckColorTable(self, event):
1247  """!Set/unset default color table"""
1248  win = self.FindWindowById(self.winId['cmd:rasterColorTable:selection'])
1249  if event.IsChecked():
1250  win.Enable()
1251  else:
1252  win.Enable(False)
1253 
1254  def OnLoadEpsgCodes(self, event):
1255  """!Load EPSG codes from the file"""
1256  win = self.FindWindowById(self.winId['projection:statusbar:projFile'])
1257  path = win.GetValue()
1258  wx.BeginBusyCursor()
1259  self.epsgCodeDict = ReadEpsgCodes(path)
1260 
1261  epsgCombo = self.FindWindowById(self.winId['projection:statusbar:epsg'])
1262  if type(self.epsgCodeDict) == type(''):
1263  wx.MessageBox(parent = self,
1264  message = _("Unable to read EPSG codes: %s") % self.epsgCodeDict,
1265  caption = _("Error"), style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
1266  self.epsgCodeDict = dict()
1267  epsgCombo.SetItems([])
1268  epsgCombo.SetValue('')
1269  self.FindWindowById(self.winId['projection:statusbar:proj4']).SetValue('')
1270  wx.EndBusyCursor()
1271  return
1272 
1273  choices = map(str, sorted(self.epsgCodeDict.keys()))
1274 
1275  epsgCombo.SetItems(choices)
1276  wx.EndBusyCursor()
1277  code = 4326 # default
1278  win = self.FindWindowById(self.winId['projection:statusbar:proj4'])
1279  if code in self.epsgCodeDict:
1280  epsgCombo.SetStringSelection(str(code))
1281  win.SetValue(self.epsgCodeDict[code][1].replace('<>', '').strip())
1282  else:
1283  epsgCombo.SetSelection(0)
1284  code = int(epsgCombo.GetStringSelection())
1285  win.SetValue(self.epsgCodeDict[code][1].replace('<>', '').strip())
1286 
1287  def OnSetEpsgCode(self, event):
1288  """!EPSG code selected"""
1289  winCode = self.FindWindowById(event.GetId())
1290  win = self.FindWindowById(self.winId['projection:statusbar:proj4'])
1291  if not self.epsgCodeDict:
1292  wx.MessageBox(parent = self,
1293  message = _("EPSG code %s not found") % event.GetString(),
1294  caption = _("Error"), style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
1295  winCode.SetValue('')
1296  win.SetValue('')
1297 
1298  try:
1299  code = int(event.GetString())
1300  except ValueError:
1301  wx.MessageBox(parent = self,
1302  message = _("EPSG code %s not found") % str(code),
1303  caption = _("Error"), style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
1304  winCode.SetValue('')
1305  win.SetValue('')
1306 
1307  try:
1308  win.SetValue(self.epsgCodeDict[code][1].replace('<>', '').strip())
1309  except KeyError:
1310  wx.MessageBox(parent = self,
1311  message = _("EPSG code %s not found") % str(code),
1312  caption = _("Error"), style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
1313  winCode.SetValue('')
1314  win.SetValue('')
1315 
1316  def OnSetFont(self, event):
1317  """'Set font' button pressed"""
1318  dlg = DefaultFontDialog(parent = self,
1319  title = _('Select default display font'),
1320  style = wx.DEFAULT_DIALOG_STYLE,
1321  type = 'font')
1322 
1323  if dlg.ShowModal() == wx.ID_OK:
1324  # set default font and encoding environmental variables
1325  if dlg.font:
1326  os.environ["GRASS_FONT"] = dlg.font
1327  self.settings.Set(group = 'display', value = dlg.font,
1328  key = 'font', subkey = 'type')
1329 
1330  if dlg.encoding and \
1331  dlg.encoding != "ISO-8859-1":
1332  os.environ["GRASS_ENCODING"] = dlg.encoding
1333  self.settings.Set(group = 'display', value = dlg.encoding,
1334  key = 'font', subkey = 'encoding')
1335 
1336  dlg.Destroy()
1337 
1338  event.Skip()
1339 
1340  def OnSetOutputFont(self, event):
1341  """'Set output font' button pressed
1342  """
1343  dlg = DefaultFontDialog(parent = self,
1344  title = _('Select output font'),
1345  style = wx.DEFAULT_DIALOG_STYLE,
1346  type = 'outputfont')
1347 
1348  if dlg.ShowModal() == wx.ID_OK:
1349  # set output font and font size variables
1350  if dlg.font:
1351  self.settings.Set(group = 'appearance', value = dlg.font,
1352  key = 'outputfont', subkey = 'type')
1353 
1354  self.settings.Set(group = 'appearance', value = dlg.fontsize,
1355  key = 'outputfont', subkey = 'size')
1356 
1357 # Standard font dialog broken for Mac in OS X 10.6
1358 # type = self.settings.Get(group = 'display', key = 'outputfont', subkey = 'type')
1359 
1360 # size = self.settings.Get(group = 'display', key = 'outputfont', subkey = 'size')
1361 # if size == None or size == 0: size = 10
1362 # size = float(size)
1363 
1364 # data = wx.FontData()
1365 # data.EnableEffects(True)
1366 # data.SetInitialFont(wx.Font(pointSize = size, family = wx.FONTFAMILY_MODERN, faceName = type, style = wx.NORMAL, weight = 0))
1367 
1368 # dlg = wx.FontDialog(self, data)
1369 
1370 # if dlg.ShowModal() == wx.ID_OK:
1371 # data = dlg.GetFontData()
1372 # font = data.GetChosenFont()
1373 
1374 # self.settings.Set(group = 'display', value = font.GetFaceName(),
1375 # key = 'outputfont', subkey = 'type')
1376 # self.settings.Set(group = 'display', value = font.GetPointSize(),
1377 # key = 'outputfont', subkey = 'size')
1378 
1379  dlg.Destroy()
1380 
1381  event.Skip()
1382 
1383  def OnEnableWheelZoom(self, event):
1384  """!Enable/disable wheel zoom mode control"""
1385  choiceId = self.winId['display:mouseWheelZoom:selection']
1386  choice = self.FindWindowById(choiceId)
1387  if choice.GetSelection() == 2:
1388  enable = False
1389  else:
1390  enable = True
1391  scrollId = self.winId['display:scrollDirection:selection']
1392  self.FindWindowById(scrollId).Enable(enable)
1393 
1394 class DefaultFontDialog(wx.Dialog):
1395  """
1396  Opens a file selection dialog to select default font
1397  to use in all GRASS displays
1398  """
1399  def __init__(self, parent, title, id = wx.ID_ANY,
1400  style = wx.DEFAULT_DIALOG_STYLE |
1401  wx.RESIZE_BORDER,
1402  settings = UserSettings,
1403  type = 'font'):
1404 
1405  self.settings = settings
1406  self.type = type
1407 
1408  wx.Dialog.__init__(self, parent, id, title, style = style)
1409 
1410  panel = wx.Panel(parent = self, id = wx.ID_ANY)
1411 
1412  self.fontlist = self.GetFonts()
1413 
1414  border = wx.BoxSizer(wx.VERTICAL)
1415  box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Font settings"))
1416  sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
1417 
1418  gridSizer = wx.GridBagSizer (hgap = 5, vgap = 5)
1419  gridSizer.AddGrowableCol(0)
1420 
1421  label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1422  label = _("Select font:"))
1423  gridSizer.Add(item = label,
1424  flag = wx.ALIGN_TOP,
1425  pos = (0,0))
1426 
1427  self.fontlb = wx.ListBox(parent = panel, id = wx.ID_ANY, pos = wx.DefaultPosition,
1428  choices = self.fontlist,
1429  style = wx.LB_SINGLE|wx.LB_SORT)
1430  self.Bind(wx.EVT_LISTBOX, self.EvtListBox, self.fontlb)
1431  self.Bind(wx.EVT_LISTBOX_DCLICK, self.EvtListBoxDClick, self.fontlb)
1432 
1433  gridSizer.Add(item = self.fontlb,
1434  flag = wx.EXPAND, pos = (1, 0))
1435 
1436  if self.type == 'font':
1437  if "GRASS_FONT" in os.environ:
1438  self.font = os.environ["GRASS_FONT"]
1439  else:
1440  self.font = self.settings.Get(group = 'display',
1441  key = 'font', subkey = 'type')
1442  self.encoding = self.settings.Get(group = 'display',
1443  key = 'font', subkey = 'encoding')
1444 
1445  label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1446  label = _("Character encoding:"))
1447  gridSizer.Add(item = label,
1448  flag = wx.ALIGN_CENTER_VERTICAL,
1449  pos = (2, 0))
1450 
1451  self.textentry = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
1452  value = self.encoding)
1453  gridSizer.Add(item = self.textentry,
1454  flag = wx.EXPAND, pos = (3, 0))
1455 
1456  self.textentry.Bind(wx.EVT_TEXT, self.OnEncoding)
1457 
1458  elif self.type == 'outputfont':
1459  self.font = self.settings.Get(group = 'appearance',
1460  key = 'outputfont', subkey = 'type')
1461  self.fontsize = self.settings.Get(group = 'appearance',
1462  key = 'outputfont', subkey = 'size')
1463  label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1464  label = _("Font size:"))
1465  gridSizer.Add(item = label,
1466  flag = wx.ALIGN_CENTER_VERTICAL,
1467  pos = (2, 0))
1468 
1469  self.spin = wx.SpinCtrl(parent = panel, id = wx.ID_ANY)
1470  if self.fontsize:
1471  self.spin.SetValue(int(self.fontsize))
1472  self.spin.Bind(wx.EVT_SPINCTRL, self.OnSizeSpin)
1473  self.spin.Bind(wx.EVT_TEXT, self.OnSizeSpin)
1474  gridSizer.Add(item = self.spin,
1475  flag = wx.ALIGN_CENTER_VERTICAL,
1476  pos = (3, 0))
1477 
1478  else:
1479  return
1480 
1481  if self.font:
1482  self.fontlb.SetStringSelection(self.font, True)
1483 
1484  sizer.Add(item = gridSizer, proportion = 1,
1485  flag = wx.EXPAND | wx.ALL,
1486  border = 5)
1487 
1488  border.Add(item = sizer, proportion = 1,
1489  flag = wx.ALL | wx.EXPAND, border = 3)
1490 
1491  btnsizer = wx.StdDialogButtonSizer()
1492 
1493  btn = wx.Button(parent = panel, id = wx.ID_OK)
1494  btn.SetDefault()
1495  btnsizer.AddButton(btn)
1496 
1497  btn = wx.Button(parent = panel, id = wx.ID_CANCEL)
1498  btnsizer.AddButton(btn)
1499  btnsizer.Realize()
1500 
1501  border.Add(item = btnsizer, proportion = 0,
1502  flag = wx.EXPAND | wx.ALIGN_RIGHT | wx.ALL, border = 5)
1503 
1504  panel.SetAutoLayout(True)
1505  panel.SetSizer(border)
1506  border.Fit(self)
1507 
1508  self.Layout()
1509 
1510  def EvtRadioBox(self, event):
1511  if event.GetInt() == 0:
1512  self.fonttype = 'grassfont'
1513  elif event.GetInt() == 1:
1514  self.fonttype = 'truetype'
1515 
1516  self.fontlist = self.GetFonts(self.fonttype)
1517  self.fontlb.SetItems(self.fontlist)
1518 
1519  def OnEncoding(self, event):
1520  self.encoding = event.GetString()
1521 
1522  def EvtListBox(self, event):
1523  self.font = event.GetString()
1524  event.Skip()
1525 
1526  def EvtListBoxDClick(self, event):
1527  self.font = event.GetString()
1528  event.Skip()
1529 
1530  def OnSizeSpin(self, event):
1531  self.fontsize = self.spin.GetValue()
1532  event.Skip()
1533 
1534  def GetFonts(self):
1535  """
1536  parses fonts directory or fretypecap file to get a list of fonts for the listbox
1537  """
1538  fontlist = []
1539 
1540  ret = RunCommand('d.font',
1541  read = True,
1542  flags = 'l')
1543 
1544  if not ret:
1545  return fontlist
1546 
1547  dfonts = ret.splitlines()
1548  dfonts.sort(lambda x,y: cmp(x.lower(), y.lower()))
1549  for item in range(len(dfonts)):
1550  # ignore duplicate fonts and those starting with #
1551  if not dfonts[item].startswith('#') and \
1552  dfonts[item] != dfonts[item-1]:
1553  fontlist.append(dfonts[item])
1554 
1555  return fontlist
1556 
1557 class MapsetAccess(wx.Dialog):
1558  """!Controls setting options and displaying/hiding map overlay
1559  decorations
1560  """
1561  def __init__(self, parent, id = wx.ID_ANY,
1562  title = _('Manage access to mapsets'),
1563  size = (350, 400),
1564  style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, **kwargs):
1565  wx.Dialog.__init__(self, parent, id, title, size = size, style = style, **kwargs)
1566 
1567  self.all_mapsets_ordered = ListOfMapsets(get = 'ordered')
1568  self.accessible_mapsets = ListOfMapsets(get = 'accessible')
1569  self.curr_mapset = grass.gisenv()['MAPSET']
1570 
1571  # make a checklistbox from available mapsets and check those that are active
1572  sizer = wx.BoxSizer(wx.VERTICAL)
1573 
1574  label = wx.StaticText(parent = self, id = wx.ID_ANY,
1575  label = _("Check a mapset to make it accessible, uncheck it to hide it.\n"
1576  " Notes:\n"
1577  " - The current mapset is always accessible.\n"
1578  " - You may only write to the current mapset.\n"
1579  " - You may only write to mapsets which you own."))
1580 
1581  sizer.Add(item = label, proportion = 0,
1582  flag = wx.ALL, border = 5)
1583 
1584  self.mapsetlb = CheckListMapset(parent = self)
1585  self.mapsetlb.LoadData()
1586 
1587  sizer.Add(item = self.mapsetlb, proportion = 1,
1588  flag = wx.ALL | wx.EXPAND, border = 5)
1589 
1590  # check all accessible mapsets
1591  for mset in self.accessible_mapsets:
1592  self.mapsetlb.CheckItem(self.all_mapsets_ordered.index(mset), True)
1593 
1594  # FIXME (howto?): grey-out current mapset
1595  #self.mapsetlb.Enable(0, False)
1596 
1597  # dialog buttons
1598  line = wx.StaticLine(parent = self, id = wx.ID_ANY,
1599  style = wx.LI_HORIZONTAL)
1600  sizer.Add(item = line, proportion = 0,
1601  flag = wx.EXPAND | wx.ALIGN_CENTRE | wx.ALL, border = 5)
1602 
1603  btnsizer = wx.StdDialogButtonSizer()
1604  okbtn = wx.Button(self, wx.ID_OK)
1605  okbtn.SetDefault()
1606  btnsizer.AddButton(okbtn)
1607 
1608  cancelbtn = wx.Button(self, wx.ID_CANCEL)
1609  btnsizer.AddButton(cancelbtn)
1610  btnsizer.Realize()
1611 
1612  sizer.Add(item = btnsizer, proportion = 0,
1613  flag = wx.EXPAND | wx.ALIGN_RIGHT | wx.ALL, border = 5)
1614 
1615  # do layout
1616  self.Layout()
1617  self.SetSizer(sizer)
1618  sizer.Fit(self)
1619 
1620  self.SetMinSize(size)
1621 
1622  def GetMapsets(self):
1623  """!Get list of checked mapsets"""
1624  ms = []
1625  i = 0
1626  for mset in self.all_mapsets_ordered:
1627  if self.mapsetlb.IsChecked(i):
1628  ms.append(mset)
1629  i += 1
1630 
1631  return ms
1632 
1633 class CheckListMapset(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.CheckListCtrlMixin):
1634  """!List of mapset/owner/group"""
1635  def __init__(self, parent, pos = wx.DefaultPosition,
1636  log = None):
1637  self.parent = parent
1638 
1639  wx.ListCtrl.__init__(self, parent, wx.ID_ANY,
1640  style = wx.LC_REPORT)
1641  listmix.CheckListCtrlMixin.__init__(self)
1642  self.log = log
1643 
1644  # setup mixins
1645  listmix.ListCtrlAutoWidthMixin.__init__(self)
1646 
1647  def LoadData(self):
1648  """!Load data into list"""
1649  self.InsertColumn(0, _('Mapset'))
1650  self.InsertColumn(1, _('Owner'))
1651  ### self.InsertColumn(2, _('Group'))
1652  gisenv = grass.gisenv()
1653  locationPath = os.path.join(gisenv['GISDBASE'], gisenv['LOCATION_NAME'])
1654 
1655  for mapset in self.parent.all_mapsets_ordered:
1656  index = self.InsertStringItem(sys.maxint, mapset)
1657  mapsetPath = os.path.join(locationPath,
1658  mapset)
1659  stat_info = os.stat(mapsetPath)
1660  if havePwd:
1661  self.SetStringItem(index, 1, "%s" % pwd.getpwuid(stat_info.st_uid)[0])
1662  # FIXME: get group name
1663  ### self.SetStringItem(index, 2, "%-8s" % stat_info.st_gid)
1664  else:
1665  # FIXME: no pwd under MS Windows (owner: 0, group: 0)
1666  self.SetStringItem(index, 1, "%-8s" % stat_info.st_uid)
1667  ### self.SetStringItem(index, 2, "%-8s" % stat_info.st_gid)
1668 
1669  self.SetColumnWidth(col = 0, width = wx.LIST_AUTOSIZE)
1670  ### self.SetColumnWidth(col = 1, width = wx.LIST_AUTOSIZE)
1671 
1672  def OnCheckItem(self, index, flag):
1673  """!Mapset checked/unchecked"""
1674  mapset = self.parent.all_mapsets_ordered[index]
1675  if mapset == self.parent.curr_mapset:
1676  self.CheckItem(index, True)
List of mapset/owner/group.
def OnCheckItem
Mapset checked/unchecked.
wxGUI command interface
Controls setting options and displaying/hiding map overlay decorations.
def OnCancel
Button &#39;Cancel&#39; pressed.
def CheckWxVersion
Check wx version.
Definition: globalvar.py:33
def GetMapsets
Get list of checked mapsets.
def _updateSettings
Update user settings.
int
Definition: y.tab.c:1344
def OnDefault
Button &#39;Set to default&#39; pressed.
User preferences dialog.
Core GUI widgets.
def OnEnableWheelZoom
Enable/disable wheel zoom mode control.
def SetValue
Definition: widgets.py:115
def _createCmdPage
Create notebook page for commad dialog settings.
def ListOfMapsets
Get list of available/accessible mapsets.
Definition: core/utils.py:245
def OnApply
Button &#39;Apply&#39; pressed Posts event EVT_SETTINGS_CHANGED.
def LoadData
Load data into list.
def _createGeneralPage
Create notebook page for action settings.
def OnLoadEpsgCodes
Load EPSG codes from the file.
def ReadEpsgCodes
Read EPSG code from the file.
Definition: core/utils.py:560
def _createDisplayPage
Create notebook page for display settings.
def GetColorTables
Get list of color tables.
Definition: core/utils.py:694
Misc utilities for wxGUI.
def OnSetEpsgCode
EPSG code selected.
def _createAppearancePage
Create notebook page for display settings.
Default GUI settings.
def OnSave
Button &#39;Save&#39; pressed Posts event EVT_SETTINGS_CHANGED.
def OnCheckColorTable
Set/unset default color table.
tuple range
Definition: tools.py:1402
def _createProjectionPage
Create notebook page for workspace settings.
def RunCommand
Run GRASS command.
Definition: gcmd.py:633
def _createAttributeManagerPage
Create notebook page for &#39;Attribute Table Manager&#39; settings.