GRASS Programmer's Manual  6.4.4(2014)-r
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 
280  #
281  # ask when removing map layer from layer tree
282  #
283  row = 0
284  askOnRemoveLayer = wx.CheckBox(parent = panel, id = wx.ID_ANY,
285  label = _("Ask when removing map layer from layer tree"),
286  name = 'IsChecked')
287  askOnRemoveLayer.SetValue(self.settings.Get(group = 'manager', key = 'askOnRemoveLayer', subkey = 'enabled'))
288  self.winId['manager:askOnRemoveLayer:enabled'] = askOnRemoveLayer.GetId()
289 
290  gridSizer.Add(item = askOnRemoveLayer,
291  pos = (row, 0), span = (1, 2))
292 
293  row += 1
294  askOnQuit = wx.CheckBox(parent = panel, id = wx.ID_ANY,
295  label = _("Ask when quiting wxGUI or closing display"),
296  name = 'IsChecked')
297  askOnQuit.SetValue(self.settings.Get(group = 'manager', key = 'askOnQuit', subkey = 'enabled'))
298  self.winId['manager:askOnQuit:enabled'] = askOnQuit.GetId()
299 
300  gridSizer.Add(item = askOnQuit,
301  pos = (row, 0), span = (1, 2))
302 
303  row += 1
304  hideSearch = wx.CheckBox(parent = panel, id = wx.ID_ANY,
305  label = _("Hide '%s' tab (requires GUI restart)") % _("Search module"),
306  name = 'IsChecked')
307  hideSearch.SetValue(self.settings.Get(group = 'manager', key = 'hideTabs', subkey = 'search'))
308  self.winId['manager:hideTabs:search'] = hideSearch.GetId()
309 
310  gridSizer.Add(item = hideSearch,
311  pos = (row, 0), span = (1, 2))
312 
313  row += 1
314  hidePyShell = wx.CheckBox(parent = panel, id = wx.ID_ANY,
315  label = _("Hide '%s' tab (requires GUI restart)") % _("Python shell"),
316  name = 'IsChecked')
317  hidePyShell.SetValue(self.settings.Get(group = 'manager', key = 'hideTabs', subkey = 'pyshell'))
318  self.winId['manager:hideTabs:pyshell'] = hidePyShell.GetId()
319 
320  gridSizer.Add(item = hidePyShell,
321  pos = (row, 0), span = (1, 2))
322 
323  #
324  # Selected text is copied to clipboard
325  #
326  row += 1
327  copySelectedTextToClipboard = wx.CheckBox(parent = panel, id = wx.ID_ANY,
328  label = _("Automatically copy selected text to clipboard (in Command console)"),
329  name = 'IsChecked')
330  copySelectedTextToClipboard.SetValue(self.settings.Get(group = 'manager', key = 'copySelectedTextToClipboard', subkey = 'enabled'))
331  self.winId['manager:copySelectedTextToClipboard:enabled'] = copySelectedTextToClipboard.GetId()
332 
333  gridSizer.Add(item = copySelectedTextToClipboard,
334  pos = (row, 0), span = (1, 2))
335  gridSizer.AddGrowableCol(0)
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 
348  row = 0
349  posDisplay = wx.CheckBox(parent = panel, id = wx.ID_ANY,
350  label = _("Suppress positioning Map Display Window(s)"),
351  name = 'IsChecked')
352  posDisplay.SetValue(self.settings.Get(group = 'general', key = 'workspace',
353  subkey = ['posDisplay', 'enabled']))
354  self.winId['general:workspace:posDisplay:enabled'] = posDisplay.GetId()
355 
356  gridSizer.Add(item = posDisplay,
357  pos = (row, 0), span = (1, 2))
358 
359  row += 1
360 
361  posManager = wx.CheckBox(parent = panel, id = wx.ID_ANY,
362  label = _("Suppress positioning Layer Manager window"),
363  name = 'IsChecked')
364  posManager.SetValue(self.settings.Get(group = 'general', key = 'workspace',
365  subkey = ['posManager', 'enabled']))
366  self.winId['general:workspace:posManager:enabled'] = posManager.GetId()
367 
368  gridSizer.Add(item = posManager,
369  pos = (row, 0), span = (1, 2))
370 
371  row += 1
372  defaultPos = wx.CheckBox(parent = panel, id = wx.ID_ANY,
373  label = _("Save current window layout as default"),
374  name = 'IsChecked')
375  defaultPos.SetValue(self.settings.Get(group = 'general', key = 'defWindowPos', subkey = 'enabled'))
376  defaultPos.SetToolTip(wx.ToolTip (_("Save current position and size of Layer Manager window and opened "
377  "Map Display window(s) and use as default for next sessions.")))
378  self.winId['general:defWindowPos:enabled'] = defaultPos.GetId()
379 
380  gridSizer.Add(item = defaultPos,
381  pos = (row, 0), span = (1, 2))
382  gridSizer.AddGrowableCol(0)
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 
409  #
410  # font settings
411  #
412  sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
413  border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
414 
415  row = 0
416  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
417  label = _("Font for command output:")),
418  flag = wx.ALIGN_LEFT |
419  wx.ALIGN_CENTER_VERTICAL,
420  pos = (row, 0))
421  outfontButton = wx.Button(parent = panel, id = wx.ID_ANY,
422  label = _("Set font"), size = (100, -1))
423  gridSizer.Add(item = outfontButton,
424  flag = wx.ALIGN_RIGHT |
425  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  if loc == 'C':
453  elementList.SetStringSelection('en')
454  self.winId['language:locale:lc_all'] = elementList.GetId()
455 
456  gridSizer.Add(item = elementList,
457  flag = wx.ALIGN_RIGHT |
458  wx.ALIGN_CENTER_VERTICAL,
459  pos = (row, 1))
460  gridSizer.AddGrowableCol(0)
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 
469  #
470  # element list
471  #
472  row = 0
473  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
474  label = _("Element list:")),
475  flag = wx.ALIGN_LEFT |
476  wx.ALIGN_CENTER_VERTICAL,
477  pos = (row, 0))
478  elementList = wx.Choice(parent = panel, id = wx.ID_ANY, size = (325, -1),
479  choices = self.settings.Get(group = 'appearance', key = 'elementListExpand',
480  subkey = 'choices', internal = True),
481  name = "GetSelection")
482  elementList.SetSelection(self.settings.Get(group = 'appearance', key = 'elementListExpand',
483  subkey = 'selection'))
484  self.winId['appearance:elementListExpand:selection'] = elementList.GetId()
485 
486  gridSizer.Add(item = elementList,
487  flag = wx.ALIGN_RIGHT |
488  wx.ALIGN_CENTER_VERTICAL,
489  pos = (row, 1))
490 
491  #
492  # menu style
493  #
494  row += 1
495  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
496  label = _("Menu style (requires to save and GUI restart):")),
497  flag = wx.ALIGN_LEFT |
498  wx.ALIGN_CENTER_VERTICAL,
499  pos = (row, 0))
500  listOfStyles = self.settings.Get(group = 'appearance', key = 'menustyle',
501  subkey = 'choices', internal = True)
502 
503  menuItemText = wx.Choice(parent = panel, id = wx.ID_ANY, size = (325, -1),
504  choices = listOfStyles,
505  name = "GetSelection")
506  menuItemText.SetSelection(self.settings.Get(group = 'appearance', key = 'menustyle', subkey = 'selection'))
507 
508  self.winId['appearance:menustyle:selection'] = menuItemText.GetId()
509 
510  gridSizer.Add(item = menuItemText,
511  flag = wx.ALIGN_RIGHT,
512  pos = (row, 1))
513 
514  #
515  # gselect.TreeCtrlComboPopup height
516  #
517  row += 1
518 
519  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
520  label = _("Height of map selection popup window (in pixels):")),
521  flag = wx.ALIGN_LEFT |
522  wx.ALIGN_CENTER_VERTICAL,
523  pos = (row, 0))
524  min = self.settings.Get(group = 'appearance', key = 'gSelectPopupHeight', subkey = 'min', internal = True)
525  max = self.settings.Get(group = 'appearance', key = 'gSelectPopupHeight', subkey = 'max', internal = True)
526  value = self.settings.Get(group = 'appearance', key = 'gSelectPopupHeight', subkey = 'value')
527 
528  popupHeightSpin = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (100, -1))
529  popupHeightSpin.SetRange(min,max)
530  popupHeightSpin.SetValue(value)
531 
532  self.winId['appearance:gSelectPopupHeight:value'] = popupHeightSpin.GetId()
533 
534  gridSizer.Add(item = popupHeightSpin,
535  flag = wx.ALIGN_RIGHT,
536  pos = (row, 1))
537 
538 
539  #
540  # icon theme
541  #
542  row += 1
543  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
544  label = _("Icon theme (requires GUI restart):")),
545  flag = wx.ALIGN_LEFT |
546  wx.ALIGN_CENTER_VERTICAL,
547  pos = (row, 0))
548  iconTheme = wx.Choice(parent = panel, id = wx.ID_ANY, size = (100, -1),
549  choices = self.settings.Get(group = 'appearance', key = 'iconTheme',
550  subkey = 'choices', internal = True),
551  name = "GetStringSelection")
552  iconTheme.SetStringSelection(self.settings.Get(group = 'appearance', key = 'iconTheme', subkey = 'type'))
553  self.winId['appearance:iconTheme:type'] = iconTheme.GetId()
554 
555  gridSizer.Add(item = iconTheme,
556  flag = wx.ALIGN_RIGHT |
557  wx.ALIGN_CENTER_VERTICAL,
558  pos = (row, 1))
559  gridSizer.AddGrowableCol(0)
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 
584  #
585  # font settings
586  #
587  row = 0
588  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
589  label = _("Default font for GRASS displays:")),
590  flag = wx.ALIGN_LEFT |
591  wx.ALIGN_CENTER_VERTICAL,
592  pos = (row, 0))
593  fontButton = wx.Button(parent = panel, id = wx.ID_ANY,
594  label = _("Set font"), size = (100, -1))
595  gridSizer.Add(item = fontButton,
596  flag = wx.ALIGN_RIGHT |
597  wx.ALIGN_CENTER_VERTICAL,
598  pos = (row, 1))
599  gridSizer.AddGrowableCol(0)
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 
612 
613  #
614  # display driver
615  #
616  row = 0
617  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
618  label = _("Display driver:")),
619  flag = wx.ALIGN_LEFT |
620  wx.ALIGN_CENTER_VERTICAL,
621  pos=(row, 0))
622  listOfDrivers = self.settings.Get(group='display', key='driver', subkey='choices', internal=True)
623  # check if cairo is available
624  if 'cairo' not in listOfDrivers:
625  for line in RunCommand('d.mon',
626  flags = 'l',
627  read = True).splitlines():
628  if 'cairo' in line:
629  # FIXME: commented out, d.mon<->cairo driver<->wxgui hangs the GUI: #943
630  #listOfDrivers.append('cairo')
631  break
632 
633  driver = wx.Choice(parent=panel, id=wx.ID_ANY, size=(150, -1),
634  choices=listOfDrivers,
635  name="GetStringSelection")
636  driver.SetStringSelection(self.settings.Get(group='display', key='driver', subkey='type'))
637  self.winId['display:driver:type'] = driver.GetId()
638 
639  gridSizer.Add(item = driver,
640  flag = wx.ALIGN_RIGHT,
641  pos = (row, 1))
642 
643  #
644  # Statusbar mode
645  #
646  row += 1
647  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
648  label = _("Statusbar mode:")),
649  flag = wx.ALIGN_LEFT |
650  wx.ALIGN_CENTER_VERTICAL,
651  pos = (row, 0))
652  listOfModes = self.settings.Get(group = 'display', key = 'statusbarMode', subkey = 'choices', internal = True)
653  statusbarMode = wx.Choice(parent = panel, id = wx.ID_ANY, size = (150, -1),
654  choices = listOfModes,
655  name = "GetSelection")
656  statusbarMode.SetSelection(self.settings.Get(group = 'display', key = 'statusbarMode', subkey = 'selection'))
657  self.winId['display:statusbarMode:selection'] = statusbarMode.GetId()
658 
659  gridSizer.Add(item = statusbarMode,
660  flag = wx.ALIGN_RIGHT,
661  pos = (row, 1))
662 
663  #
664  # Background color
665  #
666  row += 1
667  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
668  label = _("Background color:")),
669  flag = wx.ALIGN_LEFT |
670  wx.ALIGN_CENTER_VERTICAL,
671  pos = (row, 0))
672  bgColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
673  colour = self.settings.Get(group = 'display', key = 'bgcolor', subkey = 'color'),
674  size = globalvar.DIALOG_COLOR_SIZE)
675  bgColor.SetName('GetColour')
676  self.winId['display:bgcolor:color'] = bgColor.GetId()
677 
678  gridSizer.Add(item = bgColor,
679  flag = wx.ALIGN_RIGHT,
680  pos = (row, 1))
681 
682  #
683  # Align extent to display size
684  #
685  row += 1
686  alignExtent = wx.CheckBox(parent = panel, id = wx.ID_ANY,
687  label = _("Align region extent based on display size"),
688  name = "IsChecked")
689  alignExtent.SetValue(self.settings.Get(group = 'display', key = 'alignExtent', subkey = 'enabled'))
690  self.winId['display:alignExtent:enabled'] = alignExtent.GetId()
691 
692  gridSizer.Add(item = alignExtent,
693  pos = (row, 0), span = (1, 2))
694 
695  #
696  # Use computation resolution
697  #
698  row += 1
699  compResolution = wx.CheckBox(parent = panel, id = wx.ID_ANY,
700  label = _("Constrain display resolution to computational settings"),
701  name = "IsChecked")
702  compResolution.SetValue(self.settings.Get(group = 'display', key = 'compResolution', subkey = 'enabled'))
703  self.winId['display:compResolution:enabled'] = compResolution.GetId()
704 
705  gridSizer.Add(item = compResolution,
706  pos = (row, 0), span = (1, 2))
707 
708  #
709  # auto-rendering
710  #
711  row += 1
712  autoRendering = wx.CheckBox(parent = panel, id = wx.ID_ANY,
713  label = _("Enable auto-rendering"),
714  name = "IsChecked")
715  autoRendering.SetValue(self.settings.Get(group = 'display', key = 'autoRendering', subkey = 'enabled'))
716  self.winId['display:autoRendering:enabled'] = autoRendering.GetId()
717 
718  gridSizer.Add(item = autoRendering,
719  pos = (row, 0), span = (1, 2))
720 
721  #
722  # auto-zoom
723  #
724  row += 1
725  autoZooming = wx.CheckBox(parent = panel, id = wx.ID_ANY,
726  label = _("Enable auto-zooming to selected map layer"),
727  name = "IsChecked")
728  autoZooming.SetValue(self.settings.Get(group = 'display', key = 'autoZooming', subkey = 'enabled'))
729  self.winId['display:autoZooming:enabled'] = autoZooming.GetId()
730 
731  gridSizer.Add(item = autoZooming,
732  pos = (row, 0), span = (1, 2))
733 
734  #
735  # mouse wheel zoom
736  #
737  row += 1
738  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
739  label = _("Mouse wheel action:")),
740  flag = wx.ALIGN_LEFT |
741  wx.ALIGN_CENTER_VERTICAL,
742  pos = (row, 0))
743  listOfModes = self.settings.Get(group = 'display', key = 'mouseWheelZoom', subkey = 'choices', internal = True)
744  zoomAction = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
745  choices = listOfModes,
746  name = "GetSelection")
747  zoomAction.SetSelection(self.settings.Get(group = 'display', key = 'mouseWheelZoom', subkey = 'selection'))
748  self.winId['display:mouseWheelZoom:selection'] = zoomAction.GetId()
749  gridSizer.Add(item = zoomAction,
750  flag = wx.ALIGN_RIGHT,
751  pos = (row, 1))
752  row += 1
753  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
754  label = _("Mouse scrolling direction:")),
755  flag = wx.ALIGN_LEFT |
756  wx.ALIGN_CENTER_VERTICAL,
757  pos = (row, 0))
758  listOfModes = self.settings.Get(group = 'display', key = 'scrollDirection', subkey = 'choices', internal = True)
759  scrollDir = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
760  choices = listOfModes,
761  name = "GetSelection")
762  scrollDir.SetSelection(self.settings.Get(group = 'display', key = 'scrollDirection', subkey = 'selection'))
763  self.winId['display:scrollDirection:selection'] = scrollDir.GetId()
764  gridSizer.Add(item = scrollDir,
765  flag = wx.ALIGN_RIGHT,
766  pos = (row, 1))
767  gridSizer.AddGrowableCol(0)
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 
825  #
826  # command dialog settings
827  #
828  row = 0
829  # overwrite
830  overwrite = wx.CheckBox(parent = panel, id = wx.ID_ANY,
831  label = _("Allow output files to overwrite existing files"),
832  name = "IsChecked")
833  overwrite.SetValue(self.settings.Get(group = 'cmd', key = 'overwrite', subkey = 'enabled'))
834  self.winId['cmd:overwrite:enabled'] = overwrite.GetId()
835 
836  gridSizer.Add(item = overwrite,
837  pos = (row, 0), span = (1, 2))
838  row += 1
839  # close
840  close = wx.CheckBox(parent = panel, id = wx.ID_ANY,
841  label = _("Close dialog when command is successfully finished"),
842  name = "IsChecked")
843  close.SetValue(self.settings.Get(group = 'cmd', key = 'closeDlg', subkey = 'enabled'))
844  self.winId['cmd:closeDlg:enabled'] = close.GetId()
845 
846  gridSizer.Add(item = close,
847  pos = (row, 0), span = (1, 2))
848  row += 1
849  # add layer
850  add = wx.CheckBox(parent = panel, id = wx.ID_ANY,
851  label = _("Add created map into layer tree"),
852  name = "IsChecked")
853  add.SetValue(self.settings.Get(group = 'cmd', key = 'addNewLayer', subkey = 'enabled'))
854  self.winId['cmd:addNewLayer:enabled'] = add.GetId()
855 
856  gridSizer.Add(item = add,
857  pos = (row, 0), span = (1, 2))
858 
859  row += 1
860  # interactive input
861  interactive = wx.CheckBox(parent = panel, id = wx.ID_ANY,
862  label = _("Allow interactive input"),
863  name = "IsChecked")
864  interactive.SetValue(self.settings.Get(group = 'cmd', key = 'interactiveInput', subkey = 'enabled'))
865  self.winId['cmd:interactiveInput:enabled'] = interactive.GetId()
866  gridSizer.Add(item = interactive,
867  pos = (row, 0), span = (1, 2))
868 
869  row += 1
870  # verbosity
871  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
872  label = _("Verbosity level:")),
873  flag = wx.ALIGN_LEFT |
874  wx.ALIGN_CENTER_VERTICAL,
875  pos = (row, 0))
876  verbosity = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
877  choices = self.settings.Get(group = 'cmd', key = 'verbosity', subkey = 'choices', internal = True),
878  name = "GetStringSelection")
879  verbosity.SetStringSelection(self.settings.Get(group = 'cmd', key = 'verbosity', subkey = 'selection'))
880  self.winId['cmd:verbosity:selection'] = verbosity.GetId()
881 
882  gridSizer.Add(item = verbosity,
883  pos = (row, 1), flag = wx.ALIGN_RIGHT)
884  gridSizer.AddGrowableCol(0)
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 
897  #
898  # raster overlay
899  #
900  row = 0
901  rasterOverlay = wx.CheckBox(parent=panel, id=wx.ID_ANY,
902  label=_("Overlay raster maps"),
903  name='IsChecked')
904  rasterOverlay.SetValue(self.settings.Get(group='cmd', key='rasterOverlay', subkey='enabled'))
905  self.winId['cmd:rasterOverlay:enabled'] = rasterOverlay.GetId()
906 
907  gridSizer.Add(item=rasterOverlay,
908  pos=(row, 0), span=(1, 2))
909 
910  # default color table
911  row += 1
912  rasterCTCheck = wx.CheckBox(parent = panel, id = wx.ID_ANY,
913  label = _("Default color table"),
914  name = 'IsChecked')
915  rasterCTCheck.SetValue(self.settings.Get(group = 'cmd', key = 'rasterColorTable', subkey = 'enabled'))
916  self.winId['cmd:rasterColorTable:enabled'] = rasterCTCheck.GetId()
917  rasterCTCheck.Bind(wx.EVT_CHECKBOX, self.OnCheckColorTable)
918 
919  gridSizer.Add(item = rasterCTCheck, flag = wx.ALIGN_CENTER_VERTICAL,
920  pos = (row, 0))
921 
922  rasterCTName = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
923  choices = GetColorTables(),
924  name = "GetStringSelection")
925  rasterCTName.SetStringSelection(self.settings.Get(group = 'cmd', key = 'rasterColorTable', subkey = 'selection'))
926  self.winId['cmd:rasterColorTable:selection'] = rasterCTName.GetId()
927  if not rasterCTCheck.IsChecked():
928  rasterCTName.Enable(False)
929 
930  gridSizer.Add(item = rasterCTName,
931  pos = (row, 1))
932  gridSizer.AddGrowableCol(0)
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 
982  label = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _("Color:"))
983  hlColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
984  colour = self.settings.Get(group = 'atm', key = 'highlight', subkey = 'color'),
985  size = globalvar.DIALOG_COLOR_SIZE)
986  hlColor.SetName('GetColour')
987  self.winId['atm:highlight:color'] = hlColor.GetId()
988 
989  flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
990  flexSizer.Add(hlColor, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
991 
992  label = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _("Line width (in pixels):"))
993  hlWidth = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (50, -1),
994  initial = self.settings.Get(group = 'atm', key = 'highlight',subkey = 'width'),
995  min = 1, max = 1e6)
996  self.winId['atm:highlight:width'] = hlWidth.GetId()
997 
998  flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
999  flexSizer.Add(hlWidth, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
1000  flexSizer.AddGrowableCol(0)
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  label = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _("Left mouse double click:"))
1021  leftDbClick = wx.Choice(parent = panel, id = wx.ID_ANY,
1022  choices = self.settings.Get(group = 'atm', key = 'leftDbClick', subkey = 'choices', internal = True),
1023  name = "GetSelection")
1024  leftDbClick.SetSelection(self.settings.Get(group = 'atm', key = 'leftDbClick', subkey = 'selection'))
1025  self.winId['atm:leftDbClick:selection'] = leftDbClick.GetId()
1026 
1027  flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
1028  flexSizer.Add(leftDbClick, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
1029 
1030  # encoding
1031  label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1032  label = _("Encoding (e.g. utf-8, ascii, iso8859-1, koi8-r):"))
1033  encoding = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
1034  value = self.settings.Get(group = 'atm', key = 'encoding', subkey = 'value'),
1035  name = "GetValue", size = (200, -1))
1036  self.winId['atm:encoding:value'] = encoding.GetId()
1037 
1038  flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
1039  flexSizer.Add(encoding, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
1040 
1041  # ask on delete record
1042  askOnDeleteRec = wx.CheckBox(parent = panel, id = wx.ID_ANY,
1043  label = _("Ask when deleting data record(s) from table"),
1044  name = 'IsChecked')
1045  askOnDeleteRec.SetValue(self.settings.Get(group = 'atm', key = 'askOnDeleteRec', subkey = 'enabled'))
1046  self.winId['atm:askOnDeleteRec:enabled'] = askOnDeleteRec.GetId()
1047 
1048  flexSizer.Add(askOnDeleteRec, proportion = 0)
1049  flexSizer.AddGrowableCol(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 
1070  label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1071  label = _("Key column:"))
1072  keyColumn = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
1073  size = (250, -1))
1074  keyColumn.SetValue(self.settings.Get(group = 'atm', key = 'keycolumn', subkey = 'value'))
1075  self.winId['atm:keycolumn:value'] = keyColumn.GetId()
1076 
1077  flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
1078  flexSizer.Add(keyColumn, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
1079  flexSizer.AddGrowableCol(0)
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 
1111  # note for users expecting on-the-fly data reprojection
1112  row = 0
1113  note0 = wx.StaticText(parent = panel, id = wx.ID_ANY,
1114  label = _("\nNote: This only controls the coordinates "
1115  "displayed in the lower-left of the Map "
1116  "Display\nwindow's status bar. It is purely "
1117  "cosmetic and does not affect the working "
1118  "location's\nprojection in any way. You will "
1119  "need to enable the Projection check box in "
1120  "the drop-down\nmenu located at the bottom "
1121  "of the Map Display window.\n"))
1122  gridSizer.Add(item = note0,
1123  span = (1, 2),
1124  pos = (row, 0))
1125 
1126  # epsg
1127  row += 1
1128  label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1129  label = _("EPSG code:"))
1130  epsgCode = wx.ComboBox(parent = panel, id = wx.ID_ANY,
1131  name = "GetValue",
1132  size = (150, -1))
1133  self.epsgCodeDict = dict()
1134  epsgCode.SetValue(str(self.settings.Get(group = 'projection', key = 'statusbar', subkey = 'epsg')))
1135  self.winId['projection:statusbar:epsg'] = epsgCode.GetId()
1136 
1137  gridSizer.Add(item = label,
1138  pos = (row, 0),
1139  flag = wx.ALIGN_CENTER_VERTICAL)
1140  gridSizer.Add(item = epsgCode,
1141  pos = (row, 1), span = (1, 2))
1142 
1143  # proj
1144  row += 1
1145  label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1146  label = _("Proj.4 string (required):"))
1147  projString = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
1148  value = self.settings.Get(group = 'projection', key = 'statusbar', subkey = 'proj4'),
1149  name = "GetValue", size = (400, -1))
1150  self.winId['projection:statusbar:proj4'] = projString.GetId()
1151 
1152  gridSizer.Add(item = label,
1153  pos = (row, 0),
1154  flag = wx.ALIGN_CENTER_VERTICAL)
1155  gridSizer.Add(item = projString,
1156  pos = (row, 1), span = (1, 2),
1157  flag = wx.ALIGN_CENTER_VERTICAL)
1158 
1159  # epsg file
1160  row += 1
1161  label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1162  label = _("EPSG file:"))
1163  projFile = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
1164  value = self.settings.Get(group = 'projection', key = 'statusbar', subkey = 'projFile'),
1165  name = "GetValue", size = (400, -1))
1166  self.winId['projection:statusbar:projFile'] = projFile.GetId()
1167  gridSizer.Add(item = label,
1168  pos = (row, 0),
1169  flag = wx.ALIGN_CENTER_VERTICAL)
1170  gridSizer.Add(item = projFile,
1171  pos = (row, 1),
1172  flag = wx.ALIGN_CENTER_VERTICAL)
1173 
1174  # note + button
1175  row += 1
1176  note = wx.StaticText(parent = panel, id = wx.ID_ANY,
1177  label = _("Load EPSG codes (be patient), enter EPSG code or "
1178  "insert Proj.4 string directly."))
1179  gridSizer.Add(item = note,
1180  span = (1, 2),
1181  pos = (row, 0))
1182 
1183  row += 1
1184  epsgLoad = wx.Button(parent = panel, id = wx.ID_ANY,
1185  label = _("&Load EPSG codes"))
1186  gridSizer.Add(item = epsgLoad,
1187  flag = wx.ALIGN_RIGHT,
1188  pos = (row, 1))
1189  gridSizer.AddGrowableCol(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 
1202  row = 0
1203  # ll format
1204  ll = wx.RadioBox(parent = panel, id = wx.ID_ANY,
1205  label = " %s " % _("LL projections"),
1206  choices = ["DMS", "DEG"],
1207  name = "GetStringSelection")
1208  self.winId['projection:format:ll'] = ll.GetId()
1209  if self.settings.Get(group = 'projection', key = 'format', subkey = 'll') == 'DMS':
1210  ll.SetSelection(0)
1211  else:
1212  ll.SetSelection(1)
1213 
1214  # precision
1215  precision = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
1216  min = 0, max = 12,
1217  name = "GetValue")
1218  precision.SetValue(int(self.settings.Get(group = 'projection', key = 'format', subkey = 'precision')))
1219  self.winId['projection:format:precision'] = precision.GetId()
1220 
1221  gridSizer.Add(item = ll,
1222  pos = (row, 0))
1223  gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
1224  label = _("Precision:")),
1225  flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.LEFT,
1226  border = 20,
1227  pos = (row, 1))
1228  gridSizer.Add(item = precision,
1229  flag = wx.ALIGN_CENTER_VERTICAL,
1230  pos = (row, 2))
1231  gridSizer.AddGrowableCol(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 
1420  label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1421  label = _("Select font:"))
1422  gridSizer.Add(item = label,
1423  flag = wx.ALIGN_TOP,
1424  pos = (0,0))
1425 
1426  self.fontlb = wx.ListBox(parent = panel, id = wx.ID_ANY, pos = wx.DefaultPosition,
1427  choices = self.fontlist,
1428  style = wx.LB_SINGLE|wx.LB_SORT)
1429  self.Bind(wx.EVT_LISTBOX, self.EvtListBox, self.fontlb)
1430  self.Bind(wx.EVT_LISTBOX_DCLICK, self.EvtListBoxDClick, self.fontlb)
1431 
1432  gridSizer.Add(item = self.fontlb,
1433  flag = wx.EXPAND, pos = (1, 0))
1434 
1435  if self.type == 'font':
1436  if "GRASS_FONT" in os.environ:
1437  self.font = os.environ["GRASS_FONT"]
1438  else:
1439  self.font = self.settings.Get(group = 'display',
1440  key = 'font', subkey = 'type')
1441  self.encoding = self.settings.Get(group = 'display',
1442  key = 'font', subkey = 'encoding')
1443 
1444  label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1445  label = _("Character encoding:"))
1446  gridSizer.Add(item = label,
1447  flag = wx.ALIGN_CENTER_VERTICAL,
1448  pos = (2, 0))
1449 
1450  self.textentry = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
1451  value = self.encoding)
1452  gridSizer.Add(item = self.textentry,
1453  flag = wx.EXPAND, pos = (3, 0))
1454 
1455  self.textentry.Bind(wx.EVT_TEXT, self.OnEncoding)
1456 
1457  elif self.type == 'outputfont':
1458  self.font = self.settings.Get(group = 'appearance',
1459  key = 'outputfont', subkey = 'type')
1460  self.fontsize = self.settings.Get(group = 'appearance',
1461  key = 'outputfont', subkey = 'size')
1462  label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1463  label = _("Font size:"))
1464  gridSizer.Add(item = label,
1465  flag = wx.ALIGN_CENTER_VERTICAL,
1466  pos = (2, 0))
1467 
1468  self.spin = wx.SpinCtrl(parent = panel, id = wx.ID_ANY)
1469  if self.fontsize:
1470  self.spin.SetValue(int(self.fontsize))
1471  self.spin.Bind(wx.EVT_SPINCTRL, self.OnSizeSpin)
1472  self.spin.Bind(wx.EVT_TEXT, self.OnSizeSpin)
1473  gridSizer.Add(item = self.spin,
1474  flag = wx.ALIGN_CENTER_VERTICAL,
1475  pos = (3, 0))
1476 
1477  else:
1478  return
1479 
1480  if self.font:
1481  self.fontlb.SetStringSelection(self.font, True)
1482 
1483  gridSizer.AddGrowableCol(0)
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(self, index, flag)
Mapset checked/unchecked.
wxGUI command interface
Controls setting options and displaying/hiding map overlay decorations.
def _createProjectionPage(self, notebook)
Create notebook page for workspace settings.
User preferences dialog.
def OnEnableWheelZoom(self, event)
Enable/disable wheel zoom mode control.
def SetValue(self, value)
Definition: widgets.py:115
def GetColorTables()
Get list of color tables.
Definition: core/utils.py:694
Core GUI widgets.
def OnApply(self, event)
Button 'Apply' pressed Posts event EVT_SETTINGS_CHANGED.
def _createDisplayPage(self, notebook)
Create notebook page for display settings.
def OnLoadEpsgCodes(self, event)
Load EPSG codes from the file.
def _createGeneralPage(self, notebook)
Create notebook page for action settings.
def ListOfMapsets
Get list of available/accessible mapsets.
Definition: core/utils.py:245
def OnCheckColorTable(self, event)
Set/unset default color table.
def ReadEpsgCodes(path)
Read EPSG code from the file.
Definition: core/utils.py:560
def _updateSettings(self)
Update user settings.
def CheckWxVersion(version=[2)
Check wx version.
Definition: globalvar.py:33
def __init__(self, parent, id=wx.ID_ANY, title=_('Manage access to mapsets'), size=(350, 400, style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER, kwargs)
Misc utilities for wxGUI.
def _createAttributeManagerPage(self, notebook)
Create notebook page for 'Attribute Table Manager' settings.
def OnSave(self, event)
Button 'Save' pressed Posts event EVT_SETTINGS_CHANGED.
def OnDefault(self, event)
Button 'Set to default' pressed.
def RunCommand(prog, flags="", overwrite=False, quiet=False, verbose=False, parent=None, read=False, stdin=None, getErrorMsg=False, kwargs)
Run GRASS command.
Definition: gcmd.py:633
Default GUI settings.
tuple range
Definition: tools.py:1406
def _createCmdPage(self, notebook)
Create notebook page for commad dialog settings.
def _createAppearancePage(self, notebook)
Create notebook page for display settings.
def GetMapsets(self)
Get list of checked mapsets.
def OnSetEpsgCode(self, event)
EPSG code selected.
def LoadData(self)
Load data into list.
def OnCancel(self, event)
Button 'Cancel' pressed.