GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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.GetLayerNotebook().GetPageCount()):
235  mapdisp = self.parent.GetLayerNotebook().GetPage(page).maptree.GetMapDisplay()
236  pos = mapdisp.GetPosition()
237  size = mapdisp.GetSize()
238 
239  dim += ',%d,%d,%d,%d' % (pos[0], pos[1], size[0], size[1])
240 
241  self.settings.Set(group = 'general', key = 'defWindowPos', subkey = 'dim', value = dim)
242  else:
243  self.settings.Set(group = 'general', key = 'defWindowPos', subkey = 'dim', value = '')
244 
245  return True
246 
248  """!User preferences dialog"""
249  def __init__(self, parent, title = _("GUI Settings"),
250  settings = UserSettings):
251 
252  PreferencesBaseDialog.__init__(self, parent = parent, title = title,
253  settings = settings)
254 
255  # create notebook pages
256  self._createGeneralPage(self.notebook)
258  self._createDisplayPage(self.notebook)
259  self._createCmdPage(self.notebook)
262 
263  self.SetMinSize(self.GetBestSize())
264  self.SetSize(self.size)
265 
266  def _createGeneralPage(self, notebook):
267  """!Create notebook page for general settings"""
268  panel = SP.ScrolledPanel(parent = notebook, id = wx.ID_ANY)
269  panel.SetupScrolling(scroll_x = False, scroll_y = True)
270  notebook.AddPage(page = panel, text = _("General"))
271 
272  border = wx.BoxSizer(wx.VERTICAL)
273  #
274  # Layer Manager settings
275  #
276  box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Layer Manager settings"))
277  sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
278 
279  gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
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  gridSizer.AddGrowableCol(0)
337 
338  sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
339  border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
340 
341  #
342  # workspace
343  #
344  box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Workspace settings"))
345  sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
346 
347  gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
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  gridSizer.AddGrowableCol(0)
384 
385  sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
386  border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
387 
388  panel.SetSizer(border)
389 
390  return panel
391 
392 
393  panel.SetSizer(border)
394 
395  return panel
396 
397  def _createAppearancePage(self, notebook):
398  """!Create notebook page for display settings"""
399  panel = SP.ScrolledPanel(parent = notebook, id = wx.ID_ANY)
400  panel.SetupScrolling(scroll_x = False, scroll_y = True)
401  notebook.AddPage(page = panel, text = _("Appearance"))
402 
403  border = wx.BoxSizer(wx.VERTICAL)
404 
405  box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Font settings"))
406  sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
407 
408  gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
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"))
424  gridSizer.Add(item = outfontButton,
425  flag = wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL,
426  pos = (row, 1))
427  gridSizer.AddGrowableCol(0)
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  sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
437  border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
438 
439  row = 0
440  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
441  label = _("Choose language (requires to save and GRASS restart):")),
442  flag = wx.ALIGN_LEFT |
443  wx.ALIGN_CENTER_VERTICAL,
444  pos = (row, 0))
445  locales = self.settings.Get(group = 'language', key = 'locale',
446  subkey = 'choices', internal = True)
447  loc = self.settings.Get(group = 'language', key = 'locale', subkey = 'lc_all')
448  elementList = wx.Choice(parent = panel, id = wx.ID_ANY, size = (325, -1),
449  choices = locales, name = "GetStringSelection")
450  if loc in locales:
451  elementList.SetStringSelection(loc)
452  self.winId['language:locale:lc_all'] = elementList.GetId()
453 
454  gridSizer.Add(item = elementList,
455  flag = wx.ALIGN_RIGHT |
456  wx.ALIGN_CENTER_VERTICAL,
457  pos = (row, 1))
458  gridSizer.AddGrowableCol(0)
459  #
460  # appearence
461  #
462  box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Appearance settings"))
463  sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
464 
465  gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
466 
467  #
468  # element list
469  #
470  row = 0
471  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
472  label = _("Element list:")),
473  flag = wx.ALIGN_LEFT |
474  wx.ALIGN_CENTER_VERTICAL,
475  pos = (row, 0))
476  elementList = wx.Choice(parent = panel, id = wx.ID_ANY, size = (325, -1),
477  choices = self.settings.Get(group = 'appearance', key = 'elementListExpand',
478  subkey = 'choices', internal = True),
479  name = "GetSelection")
480  elementList.SetSelection(self.settings.Get(group = 'appearance', key = 'elementListExpand',
481  subkey = 'selection'))
482  self.winId['appearance:elementListExpand:selection'] = elementList.GetId()
483 
484  gridSizer.Add(item = elementList,
485  flag = wx.ALIGN_RIGHT |
486  wx.ALIGN_CENTER_VERTICAL,
487  pos = (row, 1))
488 
489  #
490  # menu style
491  #
492  row += 1
493  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
494  label = _("Menu style (requires to save and GUI restart):")),
495  flag = wx.ALIGN_LEFT |
496  wx.ALIGN_CENTER_VERTICAL,
497  pos = (row, 0))
498  listOfStyles = self.settings.Get(group = 'appearance', key = 'menustyle',
499  subkey = 'choices', internal = True)
500 
501  menuItemText = wx.Choice(parent = panel, id = wx.ID_ANY, size = (325, -1),
502  choices = listOfStyles,
503  name = "GetSelection")
504  menuItemText.SetSelection(self.settings.Get(group = 'appearance', key = 'menustyle', subkey = 'selection'))
505 
506  self.winId['appearance:menustyle:selection'] = menuItemText.GetId()
507 
508  gridSizer.Add(item = menuItemText,
509  flag = wx.ALIGN_RIGHT,
510  pos = (row, 1))
511 
512  #
513  # gselect.TreeCtrlComboPopup height
514  #
515  row += 1
516 
517  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
518  label = _("Height of map selection popup window (in pixels):")),
519  flag = wx.ALIGN_LEFT |
520  wx.ALIGN_CENTER_VERTICAL,
521  pos = (row, 0))
522  min = self.settings.Get(group = 'appearance', key = 'gSelectPopupHeight', subkey = 'min', internal = True)
523  max = self.settings.Get(group = 'appearance', key = 'gSelectPopupHeight', subkey = 'max', internal = True)
524  value = self.settings.Get(group = 'appearance', key = 'gSelectPopupHeight', subkey = 'value')
525 
526  popupHeightSpin = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (100, -1))
527  popupHeightSpin.SetRange(min,max)
528  popupHeightSpin.SetValue(value)
529 
530  self.winId['appearance:gSelectPopupHeight:value'] = popupHeightSpin.GetId()
531 
532  gridSizer.Add(item = popupHeightSpin,
533  flag = wx.ALIGN_RIGHT,
534  pos = (row, 1))
535 
536 
537  #
538  # icon theme
539  #
540  row += 1
541  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
542  label = _("Icon theme (requires GUI restart):")),
543  flag = wx.ALIGN_LEFT |
544  wx.ALIGN_CENTER_VERTICAL,
545  pos = (row, 0))
546  iconTheme = wx.Choice(parent = panel, id = wx.ID_ANY, size = (100, -1),
547  choices = self.settings.Get(group = 'appearance', key = 'iconTheme',
548  subkey = 'choices', internal = True),
549  name = "GetStringSelection")
550  iconTheme.SetStringSelection(self.settings.Get(group = 'appearance', key = 'iconTheme', subkey = 'type'))
551  self.winId['appearance:iconTheme:type'] = iconTheme.GetId()
552 
553  gridSizer.Add(item = iconTheme,
554  flag = wx.ALIGN_RIGHT |
555  wx.ALIGN_CENTER_VERTICAL,
556  pos = (row, 1))
557  gridSizer.AddGrowableCol(0)
558 
559  sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
560  border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
561 
562  panel.SetSizer(border)
563 
564  # bindings
565  outfontButton.Bind(wx.EVT_BUTTON, self.OnSetOutputFont)
566 
567  return panel
568 
569  def _createDisplayPage(self, notebook):
570  """!Create notebook page for display settings"""
571  panel = SP.ScrolledPanel(parent = notebook, id = wx.ID_ANY)
572  panel.SetupScrolling(scroll_x = False, scroll_y = True)
573  notebook.AddPage(page = panel, text = _("Map Display"))
574 
575  border = wx.BoxSizer(wx.VERTICAL)
576 
577  box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Font settings"))
578  sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
579 
580  gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
581 
582  #
583  # font settings
584  #
585  row = 0
586  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
587  label = _("Default font for GRASS displays:")),
588  flag = wx.ALIGN_LEFT |
589  wx.ALIGN_CENTER_VERTICAL,
590  pos = (row, 0))
591  fontButton = wx.Button(parent = panel, id = wx.ID_ANY,
592  label = _("Set font"))
593  gridSizer.Add(item = fontButton,
594  flag = wx.ALIGN_RIGHT |
595  wx.ALIGN_CENTER_VERTICAL,
596  pos = (row, 1))
597  gridSizer.AddGrowableCol(0)
598 
599  sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
600  border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
601 
602  #
603  # display settings
604  #
605  box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Default display settings"))
606  sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
607 
608  gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
609 
610 
611  #
612  # display driver
613  #
614  row = 0
615  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
616  label = _("Display driver:")),
617  flag = wx.ALIGN_LEFT |
618  wx.ALIGN_CENTER_VERTICAL,
619  pos=(row, 0))
620  listOfDrivers = self.settings.Get(group='display', key='driver', subkey='choices', internal=True)
621  # check if cairo is available
622  if 'cairo' not in listOfDrivers:
623  for line in RunCommand('d.mon',
624  flags = 'l',
625  read = True).splitlines():
626  if 'cairo' in line:
627  listOfDrivers.append('cairo')
628  break
629 
630  driver = wx.Choice(parent=panel, id=wx.ID_ANY, size=(150, -1),
631  choices=listOfDrivers,
632  name="GetStringSelection")
633  driver.SetStringSelection(self.settings.Get(group='display', key='driver', subkey='type'))
634  self.winId['display:driver:type'] = driver.GetId()
635 
636  gridSizer.Add(item = driver,
637  flag = wx.ALIGN_RIGHT,
638  pos = (row, 1))
639 
640  #
641  # Statusbar mode
642  #
643  row += 1
644  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
645  label = _("Statusbar mode:")),
646  flag = wx.ALIGN_LEFT |
647  wx.ALIGN_CENTER_VERTICAL,
648  pos = (row, 0))
649  listOfModes = self.settings.Get(group = 'display', key = 'statusbarMode', subkey = 'choices', internal = True)
650  statusbarMode = wx.Choice(parent = panel, id = wx.ID_ANY, size = (150, -1),
651  choices = listOfModes,
652  name = "GetSelection")
653  statusbarMode.SetSelection(self.settings.Get(group = 'display', key = 'statusbarMode', subkey = 'selection'))
654  self.winId['display:statusbarMode:selection'] = statusbarMode.GetId()
655 
656  gridSizer.Add(item = statusbarMode,
657  flag = wx.ALIGN_RIGHT,
658  pos = (row, 1))
659 
660  #
661  # Background color
662  #
663  row += 1
664  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
665  label = _("Background color:")),
666  flag = wx.ALIGN_LEFT |
667  wx.ALIGN_CENTER_VERTICAL,
668  pos = (row, 0))
669  bgColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
670  colour = self.settings.Get(group = 'display', key = 'bgcolor', subkey = 'color'),
671  size = globalvar.DIALOG_COLOR_SIZE)
672  bgColor.SetName('GetColour')
673  self.winId['display:bgcolor:color'] = bgColor.GetId()
674 
675  gridSizer.Add(item = bgColor,
676  flag = wx.ALIGN_RIGHT,
677  pos = (row, 1))
678 
679  #
680  # Align extent to display size
681  #
682  row += 1
683  alignExtent = wx.CheckBox(parent = panel, id = wx.ID_ANY,
684  label = _("Align region extent based on display size"),
685  name = "IsChecked")
686  alignExtent.SetValue(self.settings.Get(group = 'display', key = 'alignExtent', subkey = 'enabled'))
687  self.winId['display:alignExtent:enabled'] = alignExtent.GetId()
688 
689  gridSizer.Add(item = alignExtent,
690  pos = (row, 0), span = (1, 2))
691 
692  #
693  # Use computation resolution
694  #
695  row += 1
696  compResolution = wx.CheckBox(parent = panel, id = wx.ID_ANY,
697  label = _("Constrain display resolution to computational settings"),
698  name = "IsChecked")
699  compResolution.SetValue(self.settings.Get(group = 'display', key = 'compResolution', subkey = 'enabled'))
700  self.winId['display:compResolution:enabled'] = compResolution.GetId()
701 
702  gridSizer.Add(item = compResolution,
703  pos = (row, 0), span = (1, 2))
704 
705  #
706  # auto-rendering
707  #
708  row += 1
709  autoRendering = wx.CheckBox(parent = panel, id = wx.ID_ANY,
710  label = _("Enable auto-rendering"),
711  name = "IsChecked")
712  autoRendering.SetValue(self.settings.Get(group = 'display', key = 'autoRendering', subkey = 'enabled'))
713  self.winId['display:autoRendering:enabled'] = autoRendering.GetId()
714 
715  gridSizer.Add(item = autoRendering,
716  pos = (row, 0), span = (1, 2))
717 
718  #
719  # auto-zoom
720  #
721  row += 1
722  autoZooming = wx.CheckBox(parent = panel, id = wx.ID_ANY,
723  label = _("Enable auto-zooming to selected map layer"),
724  name = "IsChecked")
725  autoZooming.SetValue(self.settings.Get(group = 'display', key = 'autoZooming', subkey = 'enabled'))
726  self.winId['display:autoZooming:enabled'] = autoZooming.GetId()
727 
728  gridSizer.Add(item = autoZooming,
729  pos = (row, 0), span = (1, 2))
730 
731  #
732  # mouse wheel zoom
733  #
734  row += 1
735  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
736  label = _("Mouse wheel action:")),
737  flag = wx.ALIGN_LEFT |
738  wx.ALIGN_CENTER_VERTICAL,
739  pos = (row, 0))
740  listOfModes = self.settings.Get(group = 'display', key = 'mouseWheelZoom', subkey = 'choices', internal = True)
741  zoomAction = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
742  choices = listOfModes,
743  name = "GetSelection")
744  zoomAction.SetSelection(self.settings.Get(group = 'display', key = 'mouseWheelZoom', subkey = 'selection'))
745  self.winId['display:mouseWheelZoom:selection'] = zoomAction.GetId()
746  gridSizer.Add(item = zoomAction,
747  flag = wx.ALIGN_RIGHT,
748  pos = (row, 1))
749  row += 1
750  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
751  label = _("Mouse scrolling direction:")),
752  flag = wx.ALIGN_LEFT |
753  wx.ALIGN_CENTER_VERTICAL,
754  pos = (row, 0))
755  listOfModes = self.settings.Get(group = 'display', key = 'scrollDirection', subkey = 'choices', internal = True)
756  scrollDir = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
757  choices = listOfModes,
758  name = "GetSelection")
759  scrollDir.SetSelection(self.settings.Get(group = 'display', key = 'scrollDirection', subkey = 'selection'))
760  self.winId['display:scrollDirection:selection'] = scrollDir.GetId()
761  gridSizer.Add(item = scrollDir,
762  flag = wx.ALIGN_RIGHT,
763  pos = (row, 1))
764  gridSizer.AddGrowableCol(0)
765 
766  sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
767  border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
768 
769 
770  #
771  # advanced
772  #
773 
774  # see initialization of nviz GLWindow
775  if globalvar.CheckWxVersion(version=[2, 8, 11]) and \
776  sys.platform not in ('win32', 'darwin'):
777  box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Advanced display settings"))
778  sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
779 
780  gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
781  row = 0
782  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
783  label = _("3D view depth buffer (possible values are 16, 24, 32):")),
784  flag = wx.ALIGN_LEFT |
785  wx.ALIGN_CENTER_VERTICAL,
786  pos = (row, 0))
787  value = self.settings.Get(group='display', key='nvizDepthBuffer', subkey='value')
788  textCtrl = wx.TextCtrl(parent=panel, id=wx.ID_ANY, value=str(value), validator=IntegerValidator())
789  self.winId['display:nvizDepthBuffer:value'] = textCtrl.GetId()
790  gridSizer.Add(item = textCtrl,
791  flag = wx.ALIGN_RIGHT |
792  wx.ALIGN_CENTER_VERTICAL,
793  pos = (row, 1))
794 
795  gridSizer.AddGrowableCol(0)
796  sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
797  border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
798 
799  panel.SetSizer(border)
800 
801  # bindings
802  fontButton.Bind(wx.EVT_BUTTON, self.OnSetFont)
803  zoomAction.Bind(wx.EVT_CHOICE, self.OnEnableWheelZoom)
804 
805  # enable/disable controls according to settings
806  self.OnEnableWheelZoom(None)
807 
808  return panel
809 
810  def _createCmdPage(self, notebook):
811  """!Create notebook page for commad dialog settings"""
812  panel = SP.ScrolledPanel(parent = notebook, id = wx.ID_ANY)
813  panel.SetupScrolling(scroll_x = False, scroll_y = True)
814  notebook.AddPage(page = panel, text = _("Command"))
815 
816  border = wx.BoxSizer(wx.VERTICAL)
817  box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Command dialog settings"))
818  sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
819 
820  gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
821 
822  #
823  # command dialog settings
824  #
825  row = 0
826  # overwrite
827  overwrite = wx.CheckBox(parent = panel, id = wx.ID_ANY,
828  label = _("Allow output files to overwrite existing files"),
829  name = "IsChecked")
830  overwrite.SetValue(self.settings.Get(group = 'cmd', key = 'overwrite', subkey = 'enabled'))
831  self.winId['cmd:overwrite:enabled'] = overwrite.GetId()
832 
833  gridSizer.Add(item = overwrite,
834  pos = (row, 0), span = (1, 2))
835  row += 1
836  # close
837  close = wx.CheckBox(parent = panel, id = wx.ID_ANY,
838  label = _("Close dialog when command is successfully finished"),
839  name = "IsChecked")
840  close.SetValue(self.settings.Get(group = 'cmd', key = 'closeDlg', subkey = 'enabled'))
841  self.winId['cmd:closeDlg:enabled'] = close.GetId()
842 
843  gridSizer.Add(item = close,
844  pos = (row, 0), span = (1, 2))
845  row += 1
846  # add layer
847  add = wx.CheckBox(parent = panel, id = wx.ID_ANY,
848  label = _("Add created map into layer tree"),
849  name = "IsChecked")
850  add.SetValue(self.settings.Get(group = 'cmd', key = 'addNewLayer', subkey = 'enabled'))
851  self.winId['cmd:addNewLayer:enabled'] = add.GetId()
852 
853  gridSizer.Add(item = add,
854  pos = (row, 0), span = (1, 2))
855 
856  row += 1
857  # interactive input
858  interactive = wx.CheckBox(parent = panel, id = wx.ID_ANY,
859  label = _("Allow interactive input"),
860  name = "IsChecked")
861  interactive.SetValue(self.settings.Get(group = 'cmd', key = 'interactiveInput', subkey = 'enabled'))
862  self.winId['cmd:interactiveInput:enabled'] = interactive.GetId()
863  gridSizer.Add(item = interactive,
864  pos = (row, 0), span = (1, 2))
865 
866  row += 1
867  # verbosity
868  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
869  label = _("Verbosity level:")),
870  flag = wx.ALIGN_LEFT |
871  wx.ALIGN_CENTER_VERTICAL,
872  pos = (row, 0))
873  verbosity = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
874  choices = self.settings.Get(group = 'cmd', key = 'verbosity', subkey = 'choices', internal = True),
875  name = "GetStringSelection")
876  verbosity.SetStringSelection(self.settings.Get(group = 'cmd', key = 'verbosity', subkey = 'selection'))
877  self.winId['cmd:verbosity:selection'] = verbosity.GetId()
878 
879  gridSizer.Add(item = verbosity,
880  pos = (row, 1), flag = wx.ALIGN_RIGHT)
881  gridSizer.AddGrowableCol(0)
882 
883  sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
884  border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
885 
886  #
887  # raster settings
888  #
889  box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Raster settings"))
890  sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
891 
892  gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
893 
894  #
895  # raster overlay
896  #
897  row = 0
898  rasterOverlay = wx.CheckBox(parent=panel, id=wx.ID_ANY,
899  label=_("Overlay raster maps"),
900  name='IsChecked')
901  rasterOverlay.SetValue(self.settings.Get(group='cmd', key='rasterOverlay', subkey='enabled'))
902  self.winId['cmd:rasterOverlay:enabled'] = rasterOverlay.GetId()
903 
904  gridSizer.Add(item=rasterOverlay,
905  pos=(row, 0), span=(1, 2))
906 
907  # default color table
908  row += 1
909  rasterCTCheck = wx.CheckBox(parent = panel, id = wx.ID_ANY,
910  label = _("Default color table"),
911  name = 'IsChecked')
912  rasterCTCheck.SetValue(self.settings.Get(group = 'cmd', key = 'rasterColorTable', subkey = 'enabled'))
913  self.winId['cmd:rasterColorTable:enabled'] = rasterCTCheck.GetId()
914  rasterCTCheck.Bind(wx.EVT_CHECKBOX, self.OnCheckColorTable)
915 
916  gridSizer.Add(item = rasterCTCheck, flag = wx.ALIGN_CENTER_VERTICAL,
917  pos = (row, 0))
918 
919  rasterCTName = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
920  choices = GetColorTables(),
921  name = "GetStringSelection")
922  rasterCTName.SetStringSelection(self.settings.Get(group = 'cmd', key = 'rasterColorTable', subkey = 'selection'))
923  self.winId['cmd:rasterColorTable:selection'] = rasterCTName.GetId()
924  if not rasterCTCheck.IsChecked():
925  rasterCTName.Enable(False)
926 
927  gridSizer.Add(item = rasterCTName,
928  pos = (row, 1))
929  gridSizer.AddGrowableCol(0)
930 
931  sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
932  border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
933 
934  #
935  # vector settings
936  #
937  box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Vector settings"))
938  sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
939 
940  gridSizer = wx.FlexGridSizer (cols = 7, hgap = 3, vgap = 3)
941 
942  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
943  label = _("Display:")),
944  flag = wx.ALIGN_CENTER_VERTICAL)
945 
946  for type in ('point', 'line', 'centroid', 'boundary',
947  'area', 'face'):
948  chkbox = wx.CheckBox(parent = panel, label = type)
949  checked = self.settings.Get(group = 'cmd', key = 'showType',
950  subkey = [type, 'enabled'])
951  chkbox.SetValue(checked)
952  self.winId['cmd:showType:%s:enabled' % type] = chkbox.GetId()
953  gridSizer.Add(item = chkbox)
954 
955  sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
956  border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
957 
958  panel.SetSizer(border)
959 
960  return panel
961 
962  def _createAttributeManagerPage(self, notebook):
963  """!Create notebook page for 'Attribute Table Manager' settings"""
964  panel = SP.ScrolledPanel(parent = notebook, id = wx.ID_ANY)
965  panel.SetupScrolling(scroll_x = False, scroll_y = True)
966  notebook.AddPage(page = panel, text = _("Attributes"))
967 
968  pageSizer = wx.BoxSizer(wx.VERTICAL)
969 
970  #
971  # highlighting
972  #
973  highlightBox = wx.StaticBox(parent = panel, id = wx.ID_ANY,
974  label = " %s " % _("Highlighting"))
975  highlightSizer = wx.StaticBoxSizer(highlightBox, wx.VERTICAL)
976 
977  flexSizer = wx.FlexGridSizer (cols = 2, hgap = 5, vgap = 5)
978 
979  label = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _("Color:"))
980  hlColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
981  colour = self.settings.Get(group = 'atm', key = 'highlight', subkey = 'color'),
982  size = globalvar.DIALOG_COLOR_SIZE)
983  hlColor.SetName('GetColour')
984  self.winId['atm:highlight:color'] = hlColor.GetId()
985 
986  flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
987  flexSizer.Add(hlColor, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
988 
989  label = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _("Line width (in pixels):"))
990  hlWidth = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (50, -1),
991  initial = self.settings.Get(group = 'atm', key = 'highlight',subkey = 'width'),
992  min = 1, max = 1e6)
993  self.winId['atm:highlight:width'] = hlWidth.GetId()
994 
995  flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
996  flexSizer.Add(hlWidth, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
997  flexSizer.AddGrowableCol(0)
998 
999  highlightSizer.Add(item = flexSizer,
1000  proportion = 0,
1001  flag = wx.ALL | wx.EXPAND,
1002  border = 5)
1003 
1004  pageSizer.Add(item = highlightSizer,
1005  proportion = 0,
1006  flag = wx.ALL | wx.EXPAND,
1007  border = 5)
1008 
1009  #
1010  # data browser related settings
1011  #
1012  dataBrowserBox = wx.StaticBox(parent = panel, id = wx.ID_ANY,
1013  label = " %s " % _("Data browser"))
1014  dataBrowserSizer = wx.StaticBoxSizer(dataBrowserBox, wx.VERTICAL)
1015 
1016  flexSizer = wx.FlexGridSizer (cols = 2, hgap = 5, vgap = 5)
1017  label = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _("Left mouse double click:"))
1018  leftDbClick = wx.Choice(parent = panel, id = wx.ID_ANY,
1019  choices = self.settings.Get(group = 'atm', key = 'leftDbClick', subkey = 'choices', internal = True),
1020  name = "GetSelection")
1021  leftDbClick.SetSelection(self.settings.Get(group = 'atm', key = 'leftDbClick', subkey = 'selection'))
1022  self.winId['atm:leftDbClick:selection'] = leftDbClick.GetId()
1023 
1024  flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
1025  flexSizer.Add(leftDbClick, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
1026 
1027  # encoding
1028  label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1029  label = _("Encoding (e.g. utf-8, ascii, iso8859-1, koi8-r):"))
1030  encoding = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
1031  value = self.settings.Get(group = 'atm', key = 'encoding', subkey = 'value'),
1032  name = "GetValue", size = (200, -1))
1033  self.winId['atm:encoding:value'] = encoding.GetId()
1034 
1035  flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
1036  flexSizer.Add(encoding, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
1037 
1038  # ask on delete record
1039  askOnDeleteRec = wx.CheckBox(parent = panel, id = wx.ID_ANY,
1040  label = _("Ask when deleting data record(s) from table"),
1041  name = 'IsChecked')
1042  askOnDeleteRec.SetValue(self.settings.Get(group = 'atm', key = 'askOnDeleteRec', subkey = 'enabled'))
1043  self.winId['atm:askOnDeleteRec:enabled'] = askOnDeleteRec.GetId()
1044 
1045  flexSizer.Add(askOnDeleteRec, proportion = 0)
1046  flexSizer.AddGrowableCol(0)
1047 
1048  dataBrowserSizer.Add(item = flexSizer,
1049  proportion = 0,
1050  flag = wx.ALL | wx.EXPAND,
1051  border = 5)
1052 
1053  pageSizer.Add(item = dataBrowserSizer,
1054  proportion = 0,
1055  flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND,
1056  border = 3)
1057 
1058  #
1059  # create table
1060  #
1061  createTableBox = wx.StaticBox(parent = panel, id = wx.ID_ANY,
1062  label = " %s " % _("Create table"))
1063  createTableSizer = wx.StaticBoxSizer(createTableBox, wx.VERTICAL)
1064 
1065  flexSizer = wx.FlexGridSizer (cols = 2, hgap = 5, vgap = 5)
1066 
1067  label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1068  label = _("Key column:"))
1069  keyColumn = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
1070  size = (250, -1))
1071  keyColumn.SetValue(self.settings.Get(group = 'atm', key = 'keycolumn', subkey = 'value'))
1072  self.winId['atm:keycolumn:value'] = keyColumn.GetId()
1073 
1074  flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
1075  flexSizer.Add(keyColumn, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
1076  flexSizer.AddGrowableCol(0)
1077 
1078  createTableSizer.Add(item = flexSizer,
1079  proportion = 0,
1080  flag = wx.ALL | wx.EXPAND,
1081  border = 5)
1082 
1083  pageSizer.Add(item = createTableSizer,
1084  proportion = 0,
1085  flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND,
1086  border = 3)
1087 
1088  panel.SetSizer(pageSizer)
1089 
1090  return panel
1091 
1092  def _createProjectionPage(self, notebook):
1093  """!Create notebook page for workspace settings"""
1094  panel = SP.ScrolledPanel(parent = notebook, id = wx.ID_ANY)
1095  panel.SetupScrolling(scroll_x = False, scroll_y = True)
1096  notebook.AddPage(page = panel, text = _("Projection"))
1097 
1098  border = wx.BoxSizer(wx.VERTICAL)
1099 
1100  #
1101  # projections statusbar settings
1102  #
1103  box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Projection statusbar settings"))
1104  sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
1105 
1106  gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
1107 
1108  # note for users expecting on-the-fly data reprojection
1109  row = 0
1110  note0 = wx.StaticText(parent = panel, id = wx.ID_ANY,
1111  label = _("\nNote: This only controls the coordinates "
1112  "displayed in the lower-left of the Map "
1113  "Display\nwindow's status bar. It is purely "
1114  "cosmetic and does not affect the working "
1115  "location's\nprojection in any way. You will "
1116  "need to enable the Projection check box in "
1117  "the drop-down\nmenu located at the bottom "
1118  "of the Map Display window.\n"))
1119  gridSizer.Add(item = note0,
1120  span = (1, 2),
1121  pos = (row, 0))
1122 
1123  # epsg
1124  row += 1
1125  label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1126  label = _("EPSG code:"))
1127  epsgCode = wx.ComboBox(parent = panel, id = wx.ID_ANY,
1128  name = "GetValue",
1129  size = (150, -1))
1130  self.epsgCodeDict = dict()
1131  epsgCode.SetValue(str(self.settings.Get(group = 'projection', key = 'statusbar', subkey = 'epsg')))
1132  self.winId['projection:statusbar:epsg'] = epsgCode.GetId()
1133 
1134  gridSizer.Add(item = label,
1135  pos = (row, 0),
1136  flag = wx.ALIGN_CENTER_VERTICAL)
1137  gridSizer.Add(item = epsgCode,
1138  pos = (row, 1), span = (1, 2))
1139 
1140  # proj
1141  row += 1
1142  label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1143  label = _("Proj.4 string (required):"))
1144  projString = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
1145  value = self.settings.Get(group = 'projection', key = 'statusbar', subkey = 'proj4'),
1146  name = "GetValue", size = (400, -1))
1147  self.winId['projection:statusbar:proj4'] = projString.GetId()
1148 
1149  gridSizer.Add(item = label,
1150  pos = (row, 0),
1151  flag = wx.ALIGN_CENTER_VERTICAL)
1152  gridSizer.Add(item = projString,
1153  pos = (row, 1), span = (1, 2),
1154  flag = wx.ALIGN_CENTER_VERTICAL)
1155 
1156  # epsg file
1157  row += 1
1158  label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1159  label = _("EPSG file:"))
1160  projFile = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
1161  value = self.settings.Get(group = 'projection', key = 'statusbar', subkey = 'projFile'),
1162  name = "GetValue", size = (400, -1))
1163  self.winId['projection:statusbar:projFile'] = projFile.GetId()
1164  gridSizer.Add(item = label,
1165  pos = (row, 0),
1166  flag = wx.ALIGN_CENTER_VERTICAL)
1167  gridSizer.Add(item = projFile,
1168  pos = (row, 1),
1169  flag = wx.ALIGN_CENTER_VERTICAL)
1170 
1171  # note + button
1172  row += 1
1173  note = wx.StaticText(parent = panel, id = wx.ID_ANY,
1174  label = _("Load EPSG codes (be patient), enter EPSG code or "
1175  "insert Proj.4 string directly."))
1176  gridSizer.Add(item = note,
1177  span = (1, 2),
1178  pos = (row, 0))
1179 
1180  row += 1
1181  epsgLoad = wx.Button(parent = panel, id = wx.ID_ANY,
1182  label = _("&Load EPSG codes"))
1183  gridSizer.Add(item = epsgLoad,
1184  flag = wx.ALIGN_RIGHT,
1185  pos = (row, 1))
1186  gridSizer.AddGrowableCol(1)
1187 
1188  sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
1189  border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
1190 
1191  #
1192  # format
1193  #
1194  box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Coordinates format"))
1195  sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
1196 
1197  gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
1198 
1199  row = 0
1200  # ll format
1201  ll = wx.RadioBox(parent = panel, id = wx.ID_ANY,
1202  label = " %s " % _("LL projections"),
1203  choices = ["DMS", "DEG"],
1204  name = "GetStringSelection")
1205  self.winId['projection:format:ll'] = ll.GetId()
1206  if self.settings.Get(group = 'projection', key = 'format', subkey = 'll') == 'DMS':
1207  ll.SetSelection(0)
1208  else:
1209  ll.SetSelection(1)
1210 
1211  # precision
1212  precision = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
1213  min = 0, max = 12,
1214  name = "GetValue")
1215  precision.SetValue(int(self.settings.Get(group = 'projection', key = 'format', subkey = 'precision')))
1216  self.winId['projection:format:precision'] = precision.GetId()
1217 
1218  gridSizer.Add(item = ll,
1219  pos = (row, 0))
1220  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
1221  label = _("Precision:")),
1222  flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.LEFT,
1223  border = 20,
1224  pos = (row, 1))
1225  gridSizer.Add(item = precision,
1226  flag = wx.ALIGN_CENTER_VERTICAL,
1227  pos = (row, 2))
1228  gridSizer.AddGrowableCol(2)
1229 
1230 
1231  sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
1232  border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
1233 
1234  panel.SetSizer(border)
1235 
1236  # bindings
1237  epsgLoad.Bind(wx.EVT_BUTTON, self.OnLoadEpsgCodes)
1238  epsgCode.Bind(wx.EVT_COMBOBOX, self.OnSetEpsgCode)
1239  epsgCode.Bind(wx.EVT_TEXT_ENTER, self.OnSetEpsgCode)
1240 
1241  return panel
1242 
1243  def OnCheckColorTable(self, event):
1244  """!Set/unset default color table"""
1245  win = self.FindWindowById(self.winId['cmd:rasterColorTable:selection'])
1246  if event.IsChecked():
1247  win.Enable()
1248  else:
1249  win.Enable(False)
1250 
1251  def OnLoadEpsgCodes(self, event):
1252  """!Load EPSG codes from the file"""
1253  win = self.FindWindowById(self.winId['projection:statusbar:projFile'])
1254  path = win.GetValue()
1255  wx.BeginBusyCursor()
1256  self.epsgCodeDict = ReadEpsgCodes(path)
1257 
1258  epsgCombo = self.FindWindowById(self.winId['projection:statusbar:epsg'])
1259  if type(self.epsgCodeDict) == type(''):
1260  wx.MessageBox(parent = self,
1261  message = _("Unable to read EPSG codes: %s") % self.epsgCodeDict,
1262  caption = _("Error"), style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
1263  self.epsgCodeDict = dict()
1264  epsgCombo.SetItems([])
1265  epsgCombo.SetValue('')
1266  self.FindWindowById(self.winId['projection:statusbar:proj4']).SetValue('')
1267  wx.EndBusyCursor()
1268  return
1269 
1270  choices = map(str, sorted(self.epsgCodeDict.keys()))
1271 
1272  epsgCombo.SetItems(choices)
1273  wx.EndBusyCursor()
1274  code = 4326 # default
1275  win = self.FindWindowById(self.winId['projection:statusbar:proj4'])
1276  if code in self.epsgCodeDict:
1277  epsgCombo.SetStringSelection(str(code))
1278  win.SetValue(self.epsgCodeDict[code][1].replace('<>', '').strip())
1279  else:
1280  epsgCombo.SetSelection(0)
1281  code = int(epsgCombo.GetStringSelection())
1282  win.SetValue(self.epsgCodeDict[code][1].replace('<>', '').strip())
1283 
1284  def OnSetEpsgCode(self, event):
1285  """!EPSG code selected"""
1286  winCode = self.FindWindowById(event.GetId())
1287  win = self.FindWindowById(self.winId['projection:statusbar:proj4'])
1288  if not self.epsgCodeDict:
1289  wx.MessageBox(parent = self,
1290  message = _("EPSG code %s not found") % event.GetString(),
1291  caption = _("Error"), style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
1292  winCode.SetValue('')
1293  win.SetValue('')
1294 
1295  try:
1296  code = int(event.GetString())
1297  except ValueError:
1298  wx.MessageBox(parent = self,
1299  message = _("EPSG code %s not found") % str(code),
1300  caption = _("Error"), style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
1301  winCode.SetValue('')
1302  win.SetValue('')
1303 
1304  try:
1305  win.SetValue(self.epsgCodeDict[code][1].replace('<>', '').strip())
1306  except KeyError:
1307  wx.MessageBox(parent = self,
1308  message = _("EPSG code %s not found") % str(code),
1309  caption = _("Error"), style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
1310  winCode.SetValue('')
1311  win.SetValue('')
1312 
1313  def OnSetFont(self, event):
1314  """'Set font' button pressed"""
1315  dlg = DefaultFontDialog(parent = self,
1316  title = _('Select default display font'),
1317  style = wx.DEFAULT_DIALOG_STYLE,
1318  type = 'font')
1319 
1320  if dlg.ShowModal() == wx.ID_OK:
1321  # set default font and encoding environmental variables
1322  if dlg.font:
1323  os.environ["GRASS_FONT"] = dlg.font
1324  self.settings.Set(group = 'display', value = dlg.font,
1325  key = 'font', subkey = 'type')
1326 
1327  if dlg.encoding and \
1328  dlg.encoding != "ISO-8859-1":
1329  os.environ["GRASS_ENCODING"] = dlg.encoding
1330  self.settings.Set(group = 'display', value = dlg.encoding,
1331  key = 'font', subkey = 'encoding')
1332 
1333  dlg.Destroy()
1334 
1335  event.Skip()
1336 
1337  def OnSetOutputFont(self, event):
1338  """'Set output font' button pressed
1339  """
1340  dlg = DefaultFontDialog(parent = self,
1341  title = _('Select output font'),
1342  style = wx.DEFAULT_DIALOG_STYLE,
1343  type = 'outputfont')
1344 
1345  if dlg.ShowModal() == wx.ID_OK:
1346  # set output font and font size variables
1347  if dlg.font:
1348  self.settings.Set(group = 'appearance', value = dlg.font,
1349  key = 'outputfont', subkey = 'type')
1350 
1351  self.settings.Set(group = 'appearance', value = dlg.fontsize,
1352  key = 'outputfont', subkey = 'size')
1353 
1354 # Standard font dialog broken for Mac in OS X 10.6
1355 # type = self.settings.Get(group = 'display', key = 'outputfont', subkey = 'type')
1356 
1357 # size = self.settings.Get(group = 'display', key = 'outputfont', subkey = 'size')
1358 # if size == None or size == 0: size = 10
1359 # size = float(size)
1360 
1361 # data = wx.FontData()
1362 # data.EnableEffects(True)
1363 # data.SetInitialFont(wx.Font(pointSize = size, family = wx.FONTFAMILY_MODERN, faceName = type, style = wx.NORMAL, weight = 0))
1364 
1365 # dlg = wx.FontDialog(self, data)
1366 
1367 # if dlg.ShowModal() == wx.ID_OK:
1368 # data = dlg.GetFontData()
1369 # font = data.GetChosenFont()
1370 
1371 # self.settings.Set(group = 'display', value = font.GetFaceName(),
1372 # key = 'outputfont', subkey = 'type')
1373 # self.settings.Set(group = 'display', value = font.GetPointSize(),
1374 # key = 'outputfont', subkey = 'size')
1375 
1376  dlg.Destroy()
1377 
1378  event.Skip()
1379 
1380  def OnEnableWheelZoom(self, event):
1381  """!Enable/disable wheel zoom mode control"""
1382  choiceId = self.winId['display:mouseWheelZoom:selection']
1383  choice = self.FindWindowById(choiceId)
1384  if choice.GetSelection() == 2:
1385  enable = False
1386  else:
1387  enable = True
1388  scrollId = self.winId['display:scrollDirection:selection']
1389  self.FindWindowById(scrollId).Enable(enable)
1390 
1391 class DefaultFontDialog(wx.Dialog):
1392  """
1393  Opens a file selection dialog to select default font
1394  to use in all GRASS displays
1395  """
1396  def __init__(self, parent, title, id = wx.ID_ANY,
1397  style = wx.DEFAULT_DIALOG_STYLE |
1398  wx.RESIZE_BORDER,
1399  settings = UserSettings,
1400  type = 'font'):
1401 
1402  self.settings = settings
1403  self.type = type
1404 
1405  wx.Dialog.__init__(self, parent, id, title, style = style)
1406 
1407  panel = wx.Panel(parent = self, id = wx.ID_ANY)
1408 
1409  self.fontlist = self.GetFonts()
1410 
1411  border = wx.BoxSizer(wx.VERTICAL)
1412  box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Font settings"))
1413  sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
1414 
1415  gridSizer = wx.GridBagSizer (hgap = 5, vgap = 5)
1416 
1417  label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1418  label = _("Select font:"))
1419  gridSizer.Add(item = label,
1420  flag = wx.ALIGN_TOP,
1421  pos = (0,0))
1422 
1423  self.fontlb = wx.ListBox(parent = panel, id = wx.ID_ANY, pos = wx.DefaultPosition,
1424  choices = self.fontlist,
1425  style = wx.LB_SINGLE|wx.LB_SORT)
1426  self.Bind(wx.EVT_LISTBOX, self.EvtListBox, self.fontlb)
1427  self.Bind(wx.EVT_LISTBOX_DCLICK, self.EvtListBoxDClick, self.fontlb)
1428 
1429  gridSizer.Add(item = self.fontlb,
1430  flag = wx.EXPAND, pos = (1, 0))
1431 
1432  if self.type == 'font':
1433  if "GRASS_FONT" in os.environ:
1434  self.font = os.environ["GRASS_FONT"]
1435  else:
1436  self.font = self.settings.Get(group = 'display',
1437  key = 'font', subkey = 'type')
1438  self.encoding = self.settings.Get(group = 'display',
1439  key = 'font', subkey = 'encoding')
1440 
1441  label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1442  label = _("Character encoding:"))
1443  gridSizer.Add(item = label,
1444  flag = wx.ALIGN_CENTER_VERTICAL,
1445  pos = (2, 0))
1446 
1447  self.textentry = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
1448  value = self.encoding)
1449  gridSizer.Add(item = self.textentry,
1450  flag = wx.EXPAND, pos = (3, 0))
1451 
1452  self.textentry.Bind(wx.EVT_TEXT, self.OnEncoding)
1453 
1454  elif self.type == 'outputfont':
1455  self.font = self.settings.Get(group = 'appearance',
1456  key = 'outputfont', subkey = 'type')
1457  self.fontsize = self.settings.Get(group = 'appearance',
1458  key = 'outputfont', subkey = 'size')
1459  label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1460  label = _("Font size:"))
1461  gridSizer.Add(item = label,
1462  flag = wx.ALIGN_CENTER_VERTICAL,
1463  pos = (2, 0))
1464 
1465  self.spin = wx.SpinCtrl(parent = panel, id = wx.ID_ANY)
1466  if self.fontsize:
1467  self.spin.SetValue(int(self.fontsize))
1468  self.spin.Bind(wx.EVT_SPINCTRL, self.OnSizeSpin)
1469  self.spin.Bind(wx.EVT_TEXT, self.OnSizeSpin)
1470  gridSizer.Add(item = self.spin,
1471  flag = wx.ALIGN_CENTER_VERTICAL,
1472  pos = (3, 0))
1473 
1474  else:
1475  return
1476 
1477  if self.font:
1478  self.fontlb.SetStringSelection(self.font, True)
1479 
1480  gridSizer.AddGrowableCol(0)
1481  sizer.Add(item = gridSizer, proportion = 1,
1482  flag = wx.EXPAND | wx.ALL,
1483  border = 5)
1484 
1485  border.Add(item = sizer, proportion = 1,
1486  flag = wx.ALL | wx.EXPAND, border = 3)
1487 
1488  btnsizer = wx.StdDialogButtonSizer()
1489 
1490  btn = wx.Button(parent = panel, id = wx.ID_OK)
1491  btn.SetDefault()
1492  btnsizer.AddButton(btn)
1493 
1494  btn = wx.Button(parent = panel, id = wx.ID_CANCEL)
1495  btnsizer.AddButton(btn)
1496  btnsizer.Realize()
1497 
1498  border.Add(item = btnsizer, proportion = 0,
1499  flag = wx.EXPAND | wx.ALIGN_RIGHT | wx.ALL, border = 5)
1500 
1501  panel.SetAutoLayout(True)
1502  panel.SetSizer(border)
1503  border.Fit(self)
1504 
1505  self.Layout()
1506 
1507  def EvtRadioBox(self, event):
1508  if event.GetInt() == 0:
1509  self.fonttype = 'grassfont'
1510  elif event.GetInt() == 1:
1511  self.fonttype = 'truetype'
1512 
1513  self.fontlist = self.GetFonts(self.fonttype)
1514  self.fontlb.SetItems(self.fontlist)
1515 
1516  def OnEncoding(self, event):
1517  self.encoding = event.GetString()
1518 
1519  def EvtListBox(self, event):
1520  self.font = event.GetString()
1521  event.Skip()
1522 
1523  def EvtListBoxDClick(self, event):
1524  self.font = event.GetString()
1525  event.Skip()
1526 
1527  def OnSizeSpin(self, event):
1528  self.fontsize = self.spin.GetValue()
1529  event.Skip()
1530 
1531  def GetFonts(self):
1532  """
1533  parses fonts directory or fretypecap file to get a list of fonts for the listbox
1534  """
1535  fontlist = []
1536 
1537  ret = RunCommand('d.font',
1538  read = True,
1539  flags = 'l')
1540 
1541  if not ret:
1542  return fontlist
1543 
1544  dfonts = ret.splitlines()
1545  dfonts.sort(lambda x,y: cmp(x.lower(), y.lower()))
1546  for item in range(len(dfonts)):
1547  # ignore duplicate fonts and those starting with #
1548  if not dfonts[item].startswith('#') and \
1549  dfonts[item] != dfonts[item-1]:
1550  fontlist.append(dfonts[item])
1551 
1552  return fontlist
1553 
1554 class MapsetAccess(wx.Dialog):
1555  """!Controls setting options and displaying/hiding map overlay
1556  decorations
1557  """
1558  def __init__(self, parent, id = wx.ID_ANY,
1559  title = _('Manage access to mapsets'),
1560  size = (350, 400),
1561  style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, **kwargs):
1562  wx.Dialog.__init__(self, parent, id, title, size = size, style = style, **kwargs)
1563 
1564  self.all_mapsets_ordered = ListOfMapsets(get = 'ordered')
1565  self.accessible_mapsets = ListOfMapsets(get = 'accessible')
1566  self.curr_mapset = grass.gisenv()['MAPSET']
1567 
1568  # make a checklistbox from available mapsets and check those that are active
1569  sizer = wx.BoxSizer(wx.VERTICAL)
1570 
1571  label = wx.StaticText(parent = self, id = wx.ID_ANY,
1572  label = _("Check a mapset to make it accessible, uncheck it to hide it.\n"
1573  " Notes:\n"
1574  " - The current mapset is always accessible.\n"
1575  " - You may only write to the current mapset.\n"
1576  " - You may only write to mapsets which you own."))
1577 
1578  sizer.Add(item = label, proportion = 0,
1579  flag = wx.ALL, border = 5)
1580 
1581  self.mapsetlb = CheckListMapset(parent = self)
1582  self.mapsetlb.LoadData()
1583 
1584  sizer.Add(item = self.mapsetlb, proportion = 1,
1585  flag = wx.ALL | wx.EXPAND, border = 5)
1586 
1587  # check all accessible mapsets
1588  for mset in self.accessible_mapsets:
1589  self.mapsetlb.CheckItem(self.all_mapsets_ordered.index(mset), True)
1590 
1591  # FIXME (howto?): grey-out current mapset
1592  #self.mapsetlb.Enable(0, False)
1593 
1594  # dialog buttons
1595  line = wx.StaticLine(parent = self, id = wx.ID_ANY,
1596  style = wx.LI_HORIZONTAL)
1597  sizer.Add(item = line, proportion = 0,
1598  flag = wx.EXPAND | wx.ALIGN_CENTRE | wx.ALL, border = 5)
1599 
1600  btnsizer = wx.StdDialogButtonSizer()
1601  okbtn = wx.Button(self, wx.ID_OK)
1602  okbtn.SetDefault()
1603  btnsizer.AddButton(okbtn)
1604 
1605  cancelbtn = wx.Button(self, wx.ID_CANCEL)
1606  btnsizer.AddButton(cancelbtn)
1607  btnsizer.Realize()
1608 
1609  sizer.Add(item = btnsizer, proportion = 0,
1610  flag = wx.EXPAND | wx.ALIGN_RIGHT | wx.ALL, border = 5)
1611 
1612  # do layout
1613  self.Layout()
1614  self.SetSizer(sizer)
1615  sizer.Fit(self)
1616 
1617  self.SetMinSize(size)
1618 
1619  def GetMapsets(self):
1620  """!Get list of checked mapsets"""
1621  ms = []
1622  i = 0
1623  for mset in self.all_mapsets_ordered:
1624  if self.mapsetlb.IsChecked(i):
1625  ms.append(mset)
1626  i += 1
1627 
1628  return ms
1629 
1630 class CheckListMapset(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.CheckListCtrlMixin):
1631  """!List of mapset/owner/group"""
1632  def __init__(self, parent, pos = wx.DefaultPosition,
1633  log = None):
1634  self.parent = parent
1635 
1636  wx.ListCtrl.__init__(self, parent, wx.ID_ANY,
1637  style = wx.LC_REPORT)
1638  listmix.CheckListCtrlMixin.__init__(self)
1639  self.log = log
1640 
1641  # setup mixins
1642  listmix.ListCtrlAutoWidthMixin.__init__(self)
1643 
1644  def LoadData(self):
1645  """!Load data into list"""
1646  self.InsertColumn(0, _('Mapset'))
1647  self.InsertColumn(1, _('Owner'))
1648  ### self.InsertColumn(2, _('Group'))
1649  gisenv = grass.gisenv()
1650  locationPath = os.path.join(gisenv['GISDBASE'], gisenv['LOCATION_NAME'])
1651 
1652  for mapset in self.parent.all_mapsets_ordered:
1653  index = self.InsertStringItem(sys.maxint, mapset)
1654  mapsetPath = os.path.join(locationPath,
1655  mapset)
1656  stat_info = os.stat(mapsetPath)
1657  if havePwd:
1658  self.SetStringItem(index, 1, "%s" % pwd.getpwuid(stat_info.st_uid)[0])
1659  # FIXME: get group name
1660  ### self.SetStringItem(index, 2, "%-8s" % stat_info.st_gid)
1661  else:
1662  # FIXME: no pwd under MS Windows (owner: 0, group: 0)
1663  self.SetStringItem(index, 1, "%-8s" % stat_info.st_uid)
1664  ### self.SetStringItem(index, 2, "%-8s" % stat_info.st_gid)
1665 
1666  self.SetColumnWidth(col = 0, width = wx.LIST_AUTOSIZE)
1667  ### self.SetColumnWidth(col = 1, width = wx.LIST_AUTOSIZE)
1668 
1669  def OnCheckItem(self, index, flag):
1670  """!Mapset checked/unchecked"""
1671  mapset = self.parent.all_mapsets_ordered[index]
1672  if mapset == self.parent.curr_mapset:
1673  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:36
def GetMapsets
Get list of checked mapsets.
def _updateSettings
Update user settings.
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:1406
def _createProjectionPage
Create notebook page for workspace settings.
def RunCommand
Run GRASS command.
Definition: gcmd.py:625
def _createAttributeManagerPage
Create notebook page for &#39;Attribute Table Manager&#39; settings.