2 @package gui_core.preferences
4 @brief User preferences dialog
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.
12 - preferences::PreferencesBaseDialog
13 - preferences::PreferencesDialog
14 - preferences::DefaultFontDialog
15 - preferences::MapsetAccess
16 - preferences::CheckListMapset
18 (C) 2007-2012 by the GRASS Development Team
20 This program is free software under the GNU General Public License
21 (>=v2). Read the file COPYING that comes with GRASS for details.
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)
40 import wx.lib.colourselect
as csel
41 import wx.lib.mixins.listctrl
as listmix
42 import wx.lib.scrolledpanel
as SP
44 from wx.lib.newevent
import NewEvent
48 from core
import globalvar
50 from core.utils import ListOfMapsets, GetColorTables, ReadEpsgCodes, GetSettingsPath
54 wxSettingsChanged, EVT_SETTINGS_CHANGED = NewEvent()
57 """!Base preferences dialog"""
58 def __init__(self, parent, settings, title = _(
"User settings"),
60 style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
66 wx.Dialog.__init__(self, parent = parent, id = wx.ID_ANY, title = title,
70 self.
notebook = wx.Notebook(parent = self, id = wx.ID_ANY, style = wx.BK_DEFAULT)
78 self.
btnDefault = wx.Button(self, wx.ID_ANY, _(
"Set to default"))
79 self.
btnSave = wx.Button(self, wx.ID_SAVE)
82 self.btnSave.SetDefault()
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"))
102 btnSizer = wx.BoxSizer(wx.HORIZONTAL)
103 btnSizer.Add(item = self.
btnDefault, proportion = 1,
104 flag = wx.ALL, border = 5)
105 btnStdSizer = wx.StdDialogButtonSizer()
107 btnStdSizer.AddButton(self.
btnSave)
108 btnStdSizer.AddButton(self.
btnApply)
109 btnStdSizer.Realize()
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)
118 self.SetSizer(mainSizer)
122 """!Button 'Set to default' pressed"""
123 self.settings.userSettings = copy.deepcopy(self.settings.defaultSettings)
126 for gks
in self.winId.keys():
128 group, key, subkey = gks.split(
':')
129 value = self.settings.Get(group, key, subkey)
131 group, key, subkey, subkey1 = gks.split(
':')
132 value = self.settings.Get(group, key, [subkey, subkey1])
133 win = self.FindWindowById(self.
winId[gks])
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)
142 value = win.SetValue(value)
145 """!Button 'Apply' pressed
146 Posts event EVT_SETTINGS_CHANGED.
149 self.parent.goutput.WriteLog(_(
'Settings applied to current session but not saved'))
150 event = wxSettingsChanged()
151 wx.PostEvent(self, event)
158 """!Button 'Cancel' pressed"""
162 """!Button 'Save' pressed
163 Posts event EVT_SETTINGS_CHANGED.
166 lang = self.settings.Get(group =
'language', key =
'locale', subkey =
'lc_all')
169 self.settings.Set(group =
'language', key =
'locale', subkey =
'lc_all', value =
None)
173 self.settings.Set(group =
'language', key =
'locale', subkey =
'lc_all', value =
'C')
175 self.settings.SaveToFile()
176 self.parent.goutput.WriteLog(_(
'Settings saved to file \'%s\'.') % self.settings.filePath)
178 RunCommand(
'g.gisenv', set =
'LANG=%s' % lang)
181 event = wxSettingsChanged()
182 wx.PostEvent(self, event)
185 def _updateSettings(self):
186 """!Update user settings"""
187 for item
in self.winId.keys():
189 group, key, subkey = item.split(
':')
192 group, key, subkey, subkey1 = item.split(
':')
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())
207 value = win.GetValue()
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'))
217 self.settings.Set(group, value, key, [subkey, subkey1])
219 self.settings.Set(group, value, key, subkey)
221 if self.parent.GetName() ==
'Modeler':
227 if self.settings.Get(group =
'general', key =
'defWindowPos', subkey =
'enabled')
is True:
230 pos = self.parent.GetPosition()
231 size = self.parent.GetSize()
232 dim =
'%d,%d,%d,%d' % (pos[0], pos[1], size[0], size[1])
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()
239 dim +=
',%d,%d,%d,%d' % (pos[0], pos[1], size[0], size[1])
241 self.settings.Set(group =
'general', key =
'defWindowPos', subkey =
'dim', value = dim)
243 self.settings.Set(group =
'general', key =
'defWindowPos', subkey =
'dim', value =
'')
248 """!User preferences dialog"""
249 def __init__(self, parent, title = _(
"GUI Settings"),
250 settings = UserSettings):
252 PreferencesBaseDialog.__init__(self, parent = parent, title = title,
263 self.SetMinSize(self.GetBestSize())
264 self.SetSize(self.
size)
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"))
272 border = wx.BoxSizer(wx.VERTICAL)
276 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Layer Manager settings"))
277 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
279 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
285 askOnRemoveLayer = wx.CheckBox(parent = panel, id = wx.ID_ANY,
286 label = _(
"Ask when removing map layer from layer tree"),
288 askOnRemoveLayer.SetValue(self.settings.Get(group =
'manager', key =
'askOnRemoveLayer', subkey =
'enabled'))
289 self.
winId[
'manager:askOnRemoveLayer:enabled'] = askOnRemoveLayer.GetId()
291 gridSizer.Add(item = askOnRemoveLayer,
292 pos = (row, 0), span = (1, 2))
295 askOnQuit = wx.CheckBox(parent = panel, id = wx.ID_ANY,
296 label = _(
"Ask when quiting wxGUI or closing display"),
298 askOnQuit.SetValue(self.settings.Get(group =
'manager', key =
'askOnQuit', subkey =
'enabled'))
299 self.
winId[
'manager:askOnQuit:enabled'] = askOnQuit.GetId()
301 gridSizer.Add(item = askOnQuit,
302 pos = (row, 0), span = (1, 2))
305 hideSearch = wx.CheckBox(parent = panel, id = wx.ID_ANY,
306 label = _(
"Hide '%s' tab (requires GUI restart)") % _(
"Search module"),
308 hideSearch.SetValue(self.settings.Get(group =
'manager', key =
'hideTabs', subkey =
'search'))
309 self.
winId[
'manager:hideTabs:search'] = hideSearch.GetId()
311 gridSizer.Add(item = hideSearch,
312 pos = (row, 0), span = (1, 2))
315 hidePyShell = wx.CheckBox(parent = panel, id = wx.ID_ANY,
316 label = _(
"Hide '%s' tab (requires GUI restart)") % _(
"Python shell"),
318 hidePyShell.SetValue(self.settings.Get(group =
'manager', key =
'hideTabs', subkey =
'pyshell'))
319 self.
winId[
'manager:hideTabs:pyshell'] = hidePyShell.GetId()
321 gridSizer.Add(item = hidePyShell,
322 pos = (row, 0), span = (1, 2))
328 copySelectedTextToClipboard = wx.CheckBox(parent = panel, id = wx.ID_ANY,
329 label = _(
"Automatically copy selected text to clipboard (in Command console)"),
331 copySelectedTextToClipboard.SetValue(self.settings.Get(group =
'manager', key =
'copySelectedTextToClipboard', subkey =
'enabled'))
332 self.
winId[
'manager:copySelectedTextToClipboard:enabled'] = copySelectedTextToClipboard.GetId()
334 gridSizer.Add(item = copySelectedTextToClipboard,
335 pos = (row, 0), span = (1, 2))
336 gridSizer.AddGrowableCol(0)
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)
344 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Workspace settings"))
345 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
347 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
350 posDisplay = wx.CheckBox(parent = panel, id = wx.ID_ANY,
351 label = _(
"Suppress positioning Map Display Window(s)"),
353 posDisplay.SetValue(self.settings.Get(group =
'general', key =
'workspace',
354 subkey = [
'posDisplay',
'enabled']))
355 self.
winId[
'general:workspace:posDisplay:enabled'] = posDisplay.GetId()
357 gridSizer.Add(item = posDisplay,
358 pos = (row, 0), span = (1, 2))
362 posManager = wx.CheckBox(parent = panel, id = wx.ID_ANY,
363 label = _(
"Suppress positioning Layer Manager window"),
365 posManager.SetValue(self.settings.Get(group =
'general', key =
'workspace',
366 subkey = [
'posManager',
'enabled']))
367 self.
winId[
'general:workspace:posManager:enabled'] = posManager.GetId()
369 gridSizer.Add(item = posManager,
370 pos = (row, 0), span = (1, 2))
373 defaultPos = wx.CheckBox(parent = panel, id = wx.ID_ANY,
374 label = _(
"Save current window layout as default"),
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()
381 gridSizer.Add(item = defaultPos,
382 pos = (row, 0), span = (1, 2))
383 gridSizer.AddGrowableCol(0)
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)
388 panel.SetSizer(border)
393 panel.SetSizer(border)
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"))
403 border = wx.BoxSizer(wx.VERTICAL)
405 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Font settings"))
406 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
408 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
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)
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,
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,
427 gridSizer.AddGrowableCol(0)
432 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Language settings"))
433 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
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)
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,
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")
451 elementList.SetStringSelection(loc)
452 self.
winId[
'language:locale:lc_all'] = elementList.GetId()
454 gridSizer.Add(item = elementList,
455 flag = wx.ALIGN_RIGHT |
456 wx.ALIGN_CENTER_VERTICAL,
458 gridSizer.AddGrowableCol(0)
462 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Appearance settings"))
463 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
465 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
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,
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()
484 gridSizer.Add(item = elementList,
485 flag = wx.ALIGN_RIGHT |
486 wx.ALIGN_CENTER_VERTICAL,
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,
498 listOfStyles = self.settings.Get(group =
'appearance', key =
'menustyle',
499 subkey =
'choices', internal =
True)
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'))
506 self.
winId[
'appearance:menustyle:selection'] = menuItemText.GetId()
508 gridSizer.Add(item = menuItemText,
509 flag = wx.ALIGN_RIGHT,
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,
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')
526 popupHeightSpin = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (100, -1))
527 popupHeightSpin.SetRange(min,max)
528 popupHeightSpin.SetValue(value)
530 self.
winId[
'appearance:gSelectPopupHeight:value'] = popupHeightSpin.GetId()
532 gridSizer.Add(item = popupHeightSpin,
533 flag = wx.ALIGN_RIGHT,
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,
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()
553 gridSizer.Add(item = iconTheme,
554 flag = wx.ALIGN_RIGHT |
555 wx.ALIGN_CENTER_VERTICAL,
557 gridSizer.AddGrowableCol(0)
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)
562 panel.SetSizer(border)
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"))
575 border = wx.BoxSizer(wx.VERTICAL)
577 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Font settings"))
578 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
580 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
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,
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,
597 gridSizer.AddGrowableCol(0)
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)
605 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Default display settings"))
606 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
608 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
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,
620 listOfDrivers = self.settings.Get(group=
'display', key=
'driver', subkey=
'choices', internal=
True)
622 if 'cairo' not in listOfDrivers:
625 read =
True).splitlines():
627 listOfDrivers.append(
'cairo')
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()
636 gridSizer.Add(item = driver,
637 flag = wx.ALIGN_RIGHT,
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,
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()
656 gridSizer.Add(item = statusbarMode,
657 flag = wx.ALIGN_RIGHT,
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,
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()
675 gridSizer.Add(item = bgColor,
676 flag = wx.ALIGN_RIGHT,
683 alignExtent = wx.CheckBox(parent = panel, id = wx.ID_ANY,
684 label = _(
"Align region extent based on display size"),
686 alignExtent.SetValue(self.settings.Get(group =
'display', key =
'alignExtent', subkey =
'enabled'))
687 self.
winId[
'display:alignExtent:enabled'] = alignExtent.GetId()
689 gridSizer.Add(item = alignExtent,
690 pos = (row, 0), span = (1, 2))
696 compResolution = wx.CheckBox(parent = panel, id = wx.ID_ANY,
697 label = _(
"Constrain display resolution to computational settings"),
699 compResolution.SetValue(self.settings.Get(group =
'display', key =
'compResolution', subkey =
'enabled'))
700 self.
winId[
'display:compResolution:enabled'] = compResolution.GetId()
702 gridSizer.Add(item = compResolution,
703 pos = (row, 0), span = (1, 2))
709 autoRendering = wx.CheckBox(parent = panel, id = wx.ID_ANY,
710 label = _(
"Enable auto-rendering"),
712 autoRendering.SetValue(self.settings.Get(group =
'display', key =
'autoRendering', subkey =
'enabled'))
713 self.
winId[
'display:autoRendering:enabled'] = autoRendering.GetId()
715 gridSizer.Add(item = autoRendering,
716 pos = (row, 0), span = (1, 2))
722 autoZooming = wx.CheckBox(parent = panel, id = wx.ID_ANY,
723 label = _(
"Enable auto-zooming to selected map layer"),
725 autoZooming.SetValue(self.settings.Get(group =
'display', key =
'autoZooming', subkey =
'enabled'))
726 self.
winId[
'display:autoZooming:enabled'] = autoZooming.GetId()
728 gridSizer.Add(item = autoZooming,
729 pos = (row, 0), span = (1, 2))
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,
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,
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,
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,
764 gridSizer.AddGrowableCol(0)
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)
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)
780 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
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,
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,
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)
799 panel.SetSizer(border)
802 fontButton.Bind(wx.EVT_BUTTON, self.
OnSetFont)
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"))
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)
820 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
827 overwrite = wx.CheckBox(parent = panel, id = wx.ID_ANY,
828 label = _(
"Allow output files to overwrite existing files"),
830 overwrite.SetValue(self.settings.Get(group =
'cmd', key =
'overwrite', subkey =
'enabled'))
831 self.
winId[
'cmd:overwrite:enabled'] = overwrite.GetId()
833 gridSizer.Add(item = overwrite,
834 pos = (row, 0), span = (1, 2))
837 close = wx.CheckBox(parent = panel, id = wx.ID_ANY,
838 label = _(
"Close dialog when command is successfully finished"),
840 close.SetValue(self.settings.Get(group =
'cmd', key =
'closeDlg', subkey =
'enabled'))
841 self.
winId[
'cmd:closeDlg:enabled'] = close.GetId()
843 gridSizer.Add(item = close,
844 pos = (row, 0), span = (1, 2))
847 add = wx.CheckBox(parent = panel, id = wx.ID_ANY,
848 label = _(
"Add created map into layer tree"),
850 add.SetValue(self.settings.Get(group =
'cmd', key =
'addNewLayer', subkey =
'enabled'))
851 self.
winId[
'cmd:addNewLayer:enabled'] = add.GetId()
853 gridSizer.Add(item = add,
854 pos = (row, 0), span = (1, 2))
858 interactive = wx.CheckBox(parent = panel, id = wx.ID_ANY,
859 label = _(
"Allow interactive input"),
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))
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,
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()
879 gridSizer.Add(item = verbosity,
880 pos = (row, 1), flag = wx.ALIGN_RIGHT)
881 gridSizer.AddGrowableCol(0)
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)
889 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Raster settings"))
890 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
892 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
898 rasterOverlay = wx.CheckBox(parent=panel, id=wx.ID_ANY,
899 label=_(
"Overlay raster maps"),
901 rasterOverlay.SetValue(self.settings.Get(group=
'cmd', key=
'rasterOverlay', subkey=
'enabled'))
902 self.
winId[
'cmd:rasterOverlay:enabled'] = rasterOverlay.GetId()
904 gridSizer.Add(item=rasterOverlay,
905 pos=(row, 0), span=(1, 2))
909 rasterCTCheck = wx.CheckBox(parent = panel, id = wx.ID_ANY,
910 label = _(
"Default color table"),
912 rasterCTCheck.SetValue(self.settings.Get(group =
'cmd', key =
'rasterColorTable', subkey =
'enabled'))
913 self.
winId[
'cmd:rasterColorTable:enabled'] = rasterCTCheck.GetId()
916 gridSizer.Add(item = rasterCTCheck, flag = wx.ALIGN_CENTER_VERTICAL,
919 rasterCTName = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
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)
927 gridSizer.Add(item = rasterCTName,
929 gridSizer.AddGrowableCol(0)
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)
937 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Vector settings"))
938 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
940 gridSizer = wx.FlexGridSizer (cols = 7, hgap = 3, vgap = 3)
942 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
943 label = _(
"Display:")),
944 flag = wx.ALIGN_CENTER_VERTICAL)
946 for type
in (
'point',
'line',
'centroid',
'boundary',
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)
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)
958 panel.SetSizer(border)
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"))
968 pageSizer = wx.BoxSizer(wx.VERTICAL)
973 highlightBox = wx.StaticBox(parent = panel, id = wx.ID_ANY,
974 label =
" %s " % _(
"Highlighting"))
975 highlightSizer = wx.StaticBoxSizer(highlightBox, wx.VERTICAL)
977 flexSizer = wx.FlexGridSizer (cols = 2, hgap = 5, vgap = 5)
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()
986 flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
987 flexSizer.Add(hlColor, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
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'),
993 self.
winId[
'atm:highlight:width'] = hlWidth.GetId()
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)
999 highlightSizer.Add(item = flexSizer,
1001 flag = wx.ALL | wx.EXPAND,
1004 pageSizer.Add(item = highlightSizer,
1006 flag = wx.ALL | wx.EXPAND,
1012 dataBrowserBox = wx.StaticBox(parent = panel, id = wx.ID_ANY,
1013 label =
" %s " % _(
"Data browser"))
1014 dataBrowserSizer = wx.StaticBoxSizer(dataBrowserBox, wx.VERTICAL)
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()
1024 flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
1025 flexSizer.Add(leftDbClick, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
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()
1035 flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
1036 flexSizer.Add(encoding, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
1039 askOnDeleteRec = wx.CheckBox(parent = panel, id = wx.ID_ANY,
1040 label = _(
"Ask when deleting data record(s) from table"),
1042 askOnDeleteRec.SetValue(self.settings.Get(group =
'atm', key =
'askOnDeleteRec', subkey =
'enabled'))
1043 self.
winId[
'atm:askOnDeleteRec:enabled'] = askOnDeleteRec.GetId()
1045 flexSizer.Add(askOnDeleteRec, proportion = 0)
1046 flexSizer.AddGrowableCol(0)
1048 dataBrowserSizer.Add(item = flexSizer,
1050 flag = wx.ALL | wx.EXPAND,
1053 pageSizer.Add(item = dataBrowserSizer,
1055 flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND,
1061 createTableBox = wx.StaticBox(parent = panel, id = wx.ID_ANY,
1062 label =
" %s " % _(
"Create table"))
1063 createTableSizer = wx.StaticBoxSizer(createTableBox, wx.VERTICAL)
1065 flexSizer = wx.FlexGridSizer (cols = 2, hgap = 5, vgap = 5)
1067 label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1068 label = _(
"Key column:"))
1069 keyColumn = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
1071 keyColumn.SetValue(self.settings.Get(group =
'atm', key =
'keycolumn', subkey =
'value'))
1072 self.
winId[
'atm:keycolumn:value'] = keyColumn.GetId()
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)
1078 createTableSizer.Add(item = flexSizer,
1080 flag = wx.ALL | wx.EXPAND,
1083 pageSizer.Add(item = createTableSizer,
1085 flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND,
1088 panel.SetSizer(pageSizer)
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"))
1098 border = wx.BoxSizer(wx.VERTICAL)
1103 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Projection statusbar settings"))
1104 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
1106 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
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,
1125 label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1126 label = _(
"EPSG code:"))
1127 epsgCode = wx.ComboBox(parent = panel, id = wx.ID_ANY,
1131 epsgCode.SetValue(str(self.settings.Get(group =
'projection', key =
'statusbar', subkey =
'epsg')))
1132 self.
winId[
'projection:statusbar:epsg'] = epsgCode.GetId()
1134 gridSizer.Add(item = label,
1136 flag = wx.ALIGN_CENTER_VERTICAL)
1137 gridSizer.Add(item = epsgCode,
1138 pos = (row, 1), span = (1, 2))
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()
1149 gridSizer.Add(item = label,
1151 flag = wx.ALIGN_CENTER_VERTICAL)
1152 gridSizer.Add(item = projString,
1153 pos = (row, 1), span = (1, 2),
1154 flag = wx.ALIGN_CENTER_VERTICAL)
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,
1166 flag = wx.ALIGN_CENTER_VERTICAL)
1167 gridSizer.Add(item = projFile,
1169 flag = wx.ALIGN_CENTER_VERTICAL)
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,
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,
1186 gridSizer.AddGrowableCol(1)
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)
1194 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Coordinates format"))
1195 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
1197 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
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':
1212 precision = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
1215 precision.SetValue(int(self.settings.Get(group =
'projection', key =
'format', subkey =
'precision')))
1216 self.
winId[
'projection:format:precision'] = precision.GetId()
1218 gridSizer.Add(item = ll,
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,
1225 gridSizer.Add(item = precision,
1226 flag = wx.ALIGN_CENTER_VERTICAL,
1228 gridSizer.AddGrowableCol(2)
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)
1234 panel.SetSizer(border)
1244 """!Set/unset default color table"""
1245 win = self.FindWindowById(self.
winId[
'cmd:rasterColorTable:selection'])
1246 if event.IsChecked():
1252 """!Load EPSG codes from the file"""
1253 win = self.FindWindowById(self.
winId[
'projection:statusbar:projFile'])
1254 path = win.GetValue()
1255 wx.BeginBusyCursor()
1258 epsgCombo = self.FindWindowById(self.
winId[
'projection:statusbar:epsg'])
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)
1264 epsgCombo.SetItems([])
1265 epsgCombo.SetValue(
'')
1266 self.FindWindowById(self.
winId[
'projection:statusbar:proj4']).
SetValue(
'')
1270 choices = map(str, sorted(self.epsgCodeDict.keys()))
1272 epsgCombo.SetItems(choices)
1275 win = self.FindWindowById(self.
winId[
'projection:statusbar:proj4'])
1277 epsgCombo.SetStringSelection(str(code))
1278 win.SetValue(self.
epsgCodeDict[code][1].replace(
'<>',
'').strip())
1280 epsgCombo.SetSelection(0)
1281 code = int(epsgCombo.GetStringSelection())
1282 win.SetValue(self.
epsgCodeDict[code][1].replace(
'<>',
'').strip())
1285 """!EPSG code selected"""
1286 winCode = self.FindWindowById(event.GetId())
1287 win = self.FindWindowById(self.
winId[
'projection:statusbar:proj4'])
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(
'')
1296 code = int(event.GetString())
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(
'')
1305 win.SetValue(self.
epsgCodeDict[code][1].replace(
'<>',
'').strip())
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(
'')
1314 """'Set font' button pressed"""
1316 title = _(
'Select default display font'),
1317 style = wx.DEFAULT_DIALOG_STYLE,
1320 if dlg.ShowModal() == wx.ID_OK:
1323 os.environ[
"GRASS_FONT"] = dlg.font
1324 self.settings.Set(group =
'display', value = dlg.font,
1325 key =
'font', subkey =
'type')
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')
1338 """'Set output font' button pressed
1341 title = _(
'Select output font'),
1342 style = wx.DEFAULT_DIALOG_STYLE,
1343 type =
'outputfont')
1345 if dlg.ShowModal() == wx.ID_OK:
1348 self.settings.Set(group =
'appearance', value = dlg.font,
1349 key =
'outputfont', subkey =
'type')
1351 self.settings.Set(group =
'appearance', value = dlg.fontsize,
1352 key =
'outputfont', subkey =
'size')
1381 """!Enable/disable wheel zoom mode control"""
1382 choiceId = self.
winId[
'display:mouseWheelZoom:selection']
1383 choice = self.FindWindowById(choiceId)
1384 if choice.GetSelection() == 2:
1388 scrollId = self.
winId[
'display:scrollDirection:selection']
1389 self.FindWindowById(scrollId).Enable(enable)
1393 Opens a file selection dialog to select default font
1394 to use in all GRASS displays
1396 def __init__(self, parent, title, id = wx.ID_ANY,
1397 style = wx.DEFAULT_DIALOG_STYLE |
1399 settings = UserSettings,
1405 wx.Dialog.__init__(self, parent, id, title, style = style)
1407 panel = wx.Panel(parent = self, id = wx.ID_ANY)
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)
1415 gridSizer = wx.GridBagSizer (hgap = 5, vgap = 5)
1417 label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1418 label = _(
"Select font:"))
1419 gridSizer.Add(item = label,
1420 flag = wx.ALIGN_TOP,
1423 self.
fontlb = wx.ListBox(parent = panel, id = wx.ID_ANY, pos = wx.DefaultPosition,
1425 style = wx.LB_SINGLE|wx.LB_SORT)
1429 gridSizer.Add(item = self.
fontlb,
1430 flag = wx.EXPAND, pos = (1, 0))
1432 if self.
type ==
'font':
1433 if "GRASS_FONT" in os.environ:
1434 self.
font = os.environ[
"GRASS_FONT"]
1436 self.
font = self.settings.Get(group =
'display',
1437 key =
'font', subkey =
'type')
1439 key =
'font', subkey =
'encoding')
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,
1447 self.
textentry = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
1450 flag = wx.EXPAND, pos = (3, 0))
1452 self.textentry.Bind(wx.EVT_TEXT, self.
OnEncoding)
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,
1465 self.
spin = wx.SpinCtrl(parent = panel, id = wx.ID_ANY)
1467 self.spin.SetValue(int(self.
fontsize))
1468 self.spin.Bind(wx.EVT_SPINCTRL, self.
OnSizeSpin)
1470 gridSizer.Add(item = self.
spin,
1471 flag = wx.ALIGN_CENTER_VERTICAL,
1478 self.fontlb.SetStringSelection(self.
font,
True)
1480 gridSizer.AddGrowableCol(0)
1481 sizer.Add(item = gridSizer, proportion = 1,
1482 flag = wx.EXPAND | wx.ALL,
1485 border.Add(item = sizer, proportion = 1,
1486 flag = wx.ALL | wx.EXPAND, border = 3)
1488 btnsizer = wx.StdDialogButtonSizer()
1490 btn = wx.Button(parent = panel, id = wx.ID_OK)
1492 btnsizer.AddButton(btn)
1494 btn = wx.Button(parent = panel, id = wx.ID_CANCEL)
1495 btnsizer.AddButton(btn)
1498 border.Add(item = btnsizer, proportion = 0,
1499 flag = wx.EXPAND | wx.ALIGN_RIGHT | wx.ALL, border = 5)
1501 panel.SetAutoLayout(
True)
1502 panel.SetSizer(border)
1508 if event.GetInt() == 0:
1510 elif event.GetInt() == 1:
1514 self.fontlb.SetItems(self.
fontlist)
1520 self.
font = event.GetString()
1524 self.
font = event.GetString()
1528 self.
fontsize = self.spin.GetValue()
1533 parses fonts directory or fretypecap file to get a list of fonts for the listbox
1544 dfonts = ret.splitlines()
1545 dfonts.sort(
lambda x,y: cmp(x.lower(), y.lower()))
1546 for item
in range(len(dfonts)):
1548 if not dfonts[item].startswith(
'#')
and \
1549 dfonts[item] != dfonts[item-1]:
1550 fontlist.append(dfonts[item])
1555 """!Controls setting options and displaying/hiding map overlay
1558 def __init__(self, parent, id = wx.ID_ANY,
1559 title = _(
'Manage access to mapsets'),
1561 style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, **kwargs):
1562 wx.Dialog.__init__(self, parent, id, title, size = size, style = style, **kwargs)
1569 sizer = wx.BoxSizer(wx.VERTICAL)
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"
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."))
1578 sizer.Add(item = label, proportion = 0,
1579 flag = wx.ALL, border = 5)
1582 self.mapsetlb.LoadData()
1584 sizer.Add(item = self.
mapsetlb, proportion = 1,
1585 flag = wx.ALL | wx.EXPAND, border = 5)
1589 self.mapsetlb.CheckItem(self.all_mapsets_ordered.index(mset),
True)
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)
1600 btnsizer = wx.StdDialogButtonSizer()
1601 okbtn = wx.Button(self, wx.ID_OK)
1603 btnsizer.AddButton(okbtn)
1605 cancelbtn = wx.Button(self, wx.ID_CANCEL)
1606 btnsizer.AddButton(cancelbtn)
1609 sizer.Add(item = btnsizer, proportion = 0,
1610 flag = wx.EXPAND | wx.ALIGN_RIGHT | wx.ALL, border = 5)
1614 self.SetSizer(sizer)
1617 self.SetMinSize(size)
1620 """!Get list of checked mapsets"""
1624 if self.mapsetlb.IsChecked(i):
1630 class CheckListMapset(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.CheckListCtrlMixin):
1631 """!List of mapset/owner/group"""
1632 def __init__(self, parent, pos = wx.DefaultPosition,
1636 wx.ListCtrl.__init__(self, parent, wx.ID_ANY,
1637 style = wx.LC_REPORT)
1638 listmix.CheckListCtrlMixin.__init__(self)
1642 listmix.ListCtrlAutoWidthMixin.__init__(self)
1645 """!Load data into list"""
1646 self.InsertColumn(0, _(
'Mapset'))
1647 self.InsertColumn(1, _(
'Owner'))
1649 gisenv = grass.gisenv()
1650 locationPath = os.path.join(gisenv[
'GISDBASE'], gisenv[
'LOCATION_NAME'])
1652 for mapset
in self.parent.all_mapsets_ordered:
1653 index = self.InsertStringItem(sys.maxint, mapset)
1654 mapsetPath = os.path.join(locationPath,
1656 stat_info = os.stat(mapsetPath)
1658 self.SetStringItem(index, 1,
"%s" % pwd.getpwuid(stat_info.st_uid)[0])
1663 self.SetStringItem(index, 1,
"%-8s" % stat_info.st_uid)
1666 self.SetColumnWidth(col = 0, width = wx.LIST_AUTOSIZE)
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.
Controls setting options and displaying/hiding map overlay decorations.
def OnCancel
Button 'Cancel' pressed.
def CheckWxVersion
Check wx version.
def GetMapsets
Get list of checked mapsets.
def _updateSettings
Update user settings.
def OnDefault
Button 'Set to default' pressed.
def OnEnableWheelZoom
Enable/disable wheel zoom mode control.
def _createCmdPage
Create notebook page for commad dialog settings.
def ListOfMapsets
Get list of available/accessible mapsets.
def OnApply
Button 'Apply' 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.
def _createDisplayPage
Create notebook page for display settings.
def _layout
Layout window.
def GetColorTables
Get list of color tables.
Misc utilities for wxGUI.
def OnSetEpsgCode
EPSG code selected.
def _createAppearancePage
Create notebook page for display settings.
def OnSave
Button 'Save' pressed Posts event EVT_SETTINGS_CHANGED.
def OnCheckColorTable
Set/unset default color table.
def _createProjectionPage
Create notebook page for workspace settings.
def RunCommand
Run GRASS command.
def _createAttributeManagerPage
Create notebook page for 'Attribute Table Manager' settings.