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.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()
238 dim +=
',%d,%d,%d,%d' % (pos[0], pos[1], size[0], size[1])
240 self.settings.Set(group =
'general', key =
'defWindowPos', subkey =
'dim', value = dim)
242 self.settings.Set(group =
'general', key =
'defWindowPos', subkey =
'dim', value =
'')
247 """!User preferences dialog"""
248 def __init__(self, parent, title = _(
"GUI Settings"),
249 settings = UserSettings):
251 PreferencesBaseDialog.__init__(self, parent = parent, title = title,
262 self.SetMinSize(self.GetBestSize())
263 self.SetSize(self.
size)
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"))
271 border = wx.BoxSizer(wx.VERTICAL)
275 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Layer Manager settings"))
276 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
278 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
284 askOnRemoveLayer = wx.CheckBox(parent = panel, id = wx.ID_ANY,
285 label = _(
"Ask when removing map layer from layer tree"),
287 askOnRemoveLayer.SetValue(self.settings.Get(group =
'manager', key =
'askOnRemoveLayer', subkey =
'enabled'))
288 self.
winId[
'manager:askOnRemoveLayer:enabled'] = askOnRemoveLayer.GetId()
290 gridSizer.Add(item = askOnRemoveLayer,
291 pos = (row, 0), span = (1, 2))
294 askOnQuit = wx.CheckBox(parent = panel, id = wx.ID_ANY,
295 label = _(
"Ask when quiting wxGUI or closing display"),
297 askOnQuit.SetValue(self.settings.Get(group =
'manager', key =
'askOnQuit', subkey =
'enabled'))
298 self.
winId[
'manager:askOnQuit:enabled'] = askOnQuit.GetId()
300 gridSizer.Add(item = askOnQuit,
301 pos = (row, 0), span = (1, 2))
304 hideSearch = wx.CheckBox(parent = panel, id = wx.ID_ANY,
305 label = _(
"Hide '%s' tab (requires GUI restart)") % _(
"Search module"),
307 hideSearch.SetValue(self.settings.Get(group =
'manager', key =
'hideTabs', subkey =
'search'))
308 self.
winId[
'manager:hideTabs:search'] = hideSearch.GetId()
310 gridSizer.Add(item = hideSearch,
311 pos = (row, 0), span = (1, 2))
314 hidePyShell = wx.CheckBox(parent = panel, id = wx.ID_ANY,
315 label = _(
"Hide '%s' tab (requires GUI restart)") % _(
"Python shell"),
317 hidePyShell.SetValue(self.settings.Get(group =
'manager', key =
'hideTabs', subkey =
'pyshell'))
318 self.
winId[
'manager:hideTabs:pyshell'] = hidePyShell.GetId()
320 gridSizer.Add(item = hidePyShell,
321 pos = (row, 0), span = (1, 2))
327 copySelectedTextToClipboard = wx.CheckBox(parent = panel, id = wx.ID_ANY,
328 label = _(
"Automatically copy selected text to clipboard (in Command console)"),
330 copySelectedTextToClipboard.SetValue(self.settings.Get(group =
'manager', key =
'copySelectedTextToClipboard', subkey =
'enabled'))
331 self.
winId[
'manager:copySelectedTextToClipboard:enabled'] = copySelectedTextToClipboard.GetId()
333 gridSizer.Add(item = copySelectedTextToClipboard,
334 pos = (row, 0), span = (1, 2))
335 gridSizer.AddGrowableCol(0)
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)
343 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Workspace settings"))
344 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
346 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
349 posDisplay = wx.CheckBox(parent = panel, id = wx.ID_ANY,
350 label = _(
"Suppress positioning Map Display Window(s)"),
352 posDisplay.SetValue(self.settings.Get(group =
'general', key =
'workspace',
353 subkey = [
'posDisplay',
'enabled']))
354 self.
winId[
'general:workspace:posDisplay:enabled'] = posDisplay.GetId()
356 gridSizer.Add(item = posDisplay,
357 pos = (row, 0), span = (1, 2))
361 posManager = wx.CheckBox(parent = panel, id = wx.ID_ANY,
362 label = _(
"Suppress positioning Layer Manager window"),
364 posManager.SetValue(self.settings.Get(group =
'general', key =
'workspace',
365 subkey = [
'posManager',
'enabled']))
366 self.
winId[
'general:workspace:posManager:enabled'] = posManager.GetId()
368 gridSizer.Add(item = posManager,
369 pos = (row, 0), span = (1, 2))
372 defaultPos = wx.CheckBox(parent = panel, id = wx.ID_ANY,
373 label = _(
"Save current window layout as default"),
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()
380 gridSizer.Add(item = defaultPos,
381 pos = (row, 0), span = (1, 2))
382 gridSizer.AddGrowableCol(0)
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)
387 panel.SetSizer(border)
392 panel.SetSizer(border)
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"))
402 border = wx.BoxSizer(wx.VERTICAL)
404 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Font settings"))
405 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
407 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
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)
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,
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,
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)
453 elementList.SetStringSelection(
'en')
454 self.
winId[
'language:locale:lc_all'] = elementList.GetId()
456 gridSizer.Add(item = elementList,
457 flag = wx.ALIGN_RIGHT |
458 wx.ALIGN_CENTER_VERTICAL,
460 gridSizer.AddGrowableCol(0)
464 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Appearance settings"))
465 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
467 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
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,
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()
486 gridSizer.Add(item = elementList,
487 flag = wx.ALIGN_RIGHT |
488 wx.ALIGN_CENTER_VERTICAL,
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,
500 listOfStyles = self.settings.Get(group =
'appearance', key =
'menustyle',
501 subkey =
'choices', internal =
True)
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'))
508 self.
winId[
'appearance:menustyle:selection'] = menuItemText.GetId()
510 gridSizer.Add(item = menuItemText,
511 flag = wx.ALIGN_RIGHT,
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,
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')
528 popupHeightSpin = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (100, -1))
529 popupHeightSpin.SetRange(min,max)
530 popupHeightSpin.SetValue(value)
532 self.
winId[
'appearance:gSelectPopupHeight:value'] = popupHeightSpin.GetId()
534 gridSizer.Add(item = popupHeightSpin,
535 flag = wx.ALIGN_RIGHT,
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,
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()
555 gridSizer.Add(item = iconTheme,
556 flag = wx.ALIGN_RIGHT |
557 wx.ALIGN_CENTER_VERTICAL,
559 gridSizer.AddGrowableCol(0)
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)
564 panel.SetSizer(border)
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"))
577 border = wx.BoxSizer(wx.VERTICAL)
579 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Font settings"))
580 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
582 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
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,
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,
599 gridSizer.AddGrowableCol(0)
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)
607 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Default display settings"))
608 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
610 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
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,
622 listOfDrivers = self.settings.Get(group=
'display', key=
'driver', subkey=
'choices', internal=
True)
624 if 'cairo' not in listOfDrivers:
627 read =
True).splitlines():
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()
639 gridSizer.Add(item = driver,
640 flag = wx.ALIGN_RIGHT,
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,
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()
659 gridSizer.Add(item = statusbarMode,
660 flag = wx.ALIGN_RIGHT,
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,
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()
678 gridSizer.Add(item = bgColor,
679 flag = wx.ALIGN_RIGHT,
686 alignExtent = wx.CheckBox(parent = panel, id = wx.ID_ANY,
687 label = _(
"Align region extent based on display size"),
689 alignExtent.SetValue(self.settings.Get(group =
'display', key =
'alignExtent', subkey =
'enabled'))
690 self.
winId[
'display:alignExtent:enabled'] = alignExtent.GetId()
692 gridSizer.Add(item = alignExtent,
693 pos = (row, 0), span = (1, 2))
699 compResolution = wx.CheckBox(parent = panel, id = wx.ID_ANY,
700 label = _(
"Constrain display resolution to computational settings"),
702 compResolution.SetValue(self.settings.Get(group =
'display', key =
'compResolution', subkey =
'enabled'))
703 self.
winId[
'display:compResolution:enabled'] = compResolution.GetId()
705 gridSizer.Add(item = compResolution,
706 pos = (row, 0), span = (1, 2))
712 autoRendering = wx.CheckBox(parent = panel, id = wx.ID_ANY,
713 label = _(
"Enable auto-rendering"),
715 autoRendering.SetValue(self.settings.Get(group =
'display', key =
'autoRendering', subkey =
'enabled'))
716 self.
winId[
'display:autoRendering:enabled'] = autoRendering.GetId()
718 gridSizer.Add(item = autoRendering,
719 pos = (row, 0), span = (1, 2))
725 autoZooming = wx.CheckBox(parent = panel, id = wx.ID_ANY,
726 label = _(
"Enable auto-zooming to selected map layer"),
728 autoZooming.SetValue(self.settings.Get(group =
'display', key =
'autoZooming', subkey =
'enabled'))
729 self.
winId[
'display:autoZooming:enabled'] = autoZooming.GetId()
731 gridSizer.Add(item = autoZooming,
732 pos = (row, 0), span = (1, 2))
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,
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,
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,
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,
767 gridSizer.AddGrowableCol(0)
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)
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)
783 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
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,
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,
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)
802 panel.SetSizer(border)
805 fontButton.Bind(wx.EVT_BUTTON, self.
OnSetFont)
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"))
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)
823 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
830 overwrite = wx.CheckBox(parent = panel, id = wx.ID_ANY,
831 label = _(
"Allow output files to overwrite existing files"),
833 overwrite.SetValue(self.settings.Get(group =
'cmd', key =
'overwrite', subkey =
'enabled'))
834 self.
winId[
'cmd:overwrite:enabled'] = overwrite.GetId()
836 gridSizer.Add(item = overwrite,
837 pos = (row, 0), span = (1, 2))
840 close = wx.CheckBox(parent = panel, id = wx.ID_ANY,
841 label = _(
"Close dialog when command is successfully finished"),
843 close.SetValue(self.settings.Get(group =
'cmd', key =
'closeDlg', subkey =
'enabled'))
844 self.
winId[
'cmd:closeDlg:enabled'] = close.GetId()
846 gridSizer.Add(item = close,
847 pos = (row, 0), span = (1, 2))
850 add = wx.CheckBox(parent = panel, id = wx.ID_ANY,
851 label = _(
"Add created map into layer tree"),
853 add.SetValue(self.settings.Get(group =
'cmd', key =
'addNewLayer', subkey =
'enabled'))
854 self.
winId[
'cmd:addNewLayer:enabled'] = add.GetId()
856 gridSizer.Add(item = add,
857 pos = (row, 0), span = (1, 2))
861 interactive = wx.CheckBox(parent = panel, id = wx.ID_ANY,
862 label = _(
"Allow interactive input"),
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))
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,
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()
882 gridSizer.Add(item = verbosity,
883 pos = (row, 1), flag = wx.ALIGN_RIGHT)
884 gridSizer.AddGrowableCol(0)
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)
892 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Raster settings"))
893 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
895 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
901 rasterOverlay = wx.CheckBox(parent=panel, id=wx.ID_ANY,
902 label=_(
"Overlay raster maps"),
904 rasterOverlay.SetValue(self.settings.Get(group=
'cmd', key=
'rasterOverlay', subkey=
'enabled'))
905 self.
winId[
'cmd:rasterOverlay:enabled'] = rasterOverlay.GetId()
907 gridSizer.Add(item=rasterOverlay,
908 pos=(row, 0), span=(1, 2))
912 rasterCTCheck = wx.CheckBox(parent = panel, id = wx.ID_ANY,
913 label = _(
"Default color table"),
915 rasterCTCheck.SetValue(self.settings.Get(group =
'cmd', key =
'rasterColorTable', subkey =
'enabled'))
916 self.
winId[
'cmd:rasterColorTable:enabled'] = rasterCTCheck.GetId()
919 gridSizer.Add(item = rasterCTCheck, flag = wx.ALIGN_CENTER_VERTICAL,
922 rasterCTName = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
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)
930 gridSizer.Add(item = rasterCTName,
932 gridSizer.AddGrowableCol(0)
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)
940 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Vector settings"))
941 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
943 gridSizer = wx.FlexGridSizer (cols = 7, hgap = 3, vgap = 3)
945 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
946 label = _(
"Display:")),
947 flag = wx.ALIGN_CENTER_VERTICAL)
949 for type
in (
'point',
'line',
'centroid',
'boundary',
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)
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)
961 panel.SetSizer(border)
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"))
971 pageSizer = wx.BoxSizer(wx.VERTICAL)
976 highlightBox = wx.StaticBox(parent = panel, id = wx.ID_ANY,
977 label =
" %s " % _(
"Highlighting"))
978 highlightSizer = wx.StaticBoxSizer(highlightBox, wx.VERTICAL)
980 flexSizer = wx.FlexGridSizer (cols = 2, hgap = 5, vgap = 5)
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()
989 flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
990 flexSizer.Add(hlColor, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
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'),
996 self.
winId[
'atm:highlight:width'] = hlWidth.GetId()
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)
1002 highlightSizer.Add(item = flexSizer,
1004 flag = wx.ALL | wx.EXPAND,
1007 pageSizer.Add(item = highlightSizer,
1009 flag = wx.ALL | wx.EXPAND,
1015 dataBrowserBox = wx.StaticBox(parent = panel, id = wx.ID_ANY,
1016 label =
" %s " % _(
"Data browser"))
1017 dataBrowserSizer = wx.StaticBoxSizer(dataBrowserBox, wx.VERTICAL)
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()
1027 flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
1028 flexSizer.Add(leftDbClick, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
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()
1038 flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
1039 flexSizer.Add(encoding, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
1042 askOnDeleteRec = wx.CheckBox(parent = panel, id = wx.ID_ANY,
1043 label = _(
"Ask when deleting data record(s) from table"),
1045 askOnDeleteRec.SetValue(self.settings.Get(group =
'atm', key =
'askOnDeleteRec', subkey =
'enabled'))
1046 self.
winId[
'atm:askOnDeleteRec:enabled'] = askOnDeleteRec.GetId()
1048 flexSizer.Add(askOnDeleteRec, proportion = 0)
1049 flexSizer.AddGrowableCol(0)
1051 dataBrowserSizer.Add(item = flexSizer,
1053 flag = wx.ALL | wx.EXPAND,
1056 pageSizer.Add(item = dataBrowserSizer,
1058 flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND,
1064 createTableBox = wx.StaticBox(parent = panel, id = wx.ID_ANY,
1065 label =
" %s " % _(
"Create table"))
1066 createTableSizer = wx.StaticBoxSizer(createTableBox, wx.VERTICAL)
1068 flexSizer = wx.FlexGridSizer (cols = 2, hgap = 5, vgap = 5)
1070 label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1071 label = _(
"Key column:"))
1072 keyColumn = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
1074 keyColumn.SetValue(self.settings.Get(group =
'atm', key =
'keycolumn', subkey =
'value'))
1075 self.
winId[
'atm:keycolumn:value'] = keyColumn.GetId()
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)
1081 createTableSizer.Add(item = flexSizer,
1083 flag = wx.ALL | wx.EXPAND,
1086 pageSizer.Add(item = createTableSizer,
1088 flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND,
1091 panel.SetSizer(pageSizer)
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"))
1101 border = wx.BoxSizer(wx.VERTICAL)
1106 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Projection statusbar settings"))
1107 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
1109 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
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,
1128 label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1129 label = _(
"EPSG code:"))
1130 epsgCode = wx.ComboBox(parent = panel, id = wx.ID_ANY,
1134 epsgCode.SetValue(str(self.settings.Get(group =
'projection', key =
'statusbar', subkey =
'epsg')))
1135 self.
winId[
'projection:statusbar:epsg'] = epsgCode.GetId()
1137 gridSizer.Add(item = label,
1139 flag = wx.ALIGN_CENTER_VERTICAL)
1140 gridSizer.Add(item = epsgCode,
1141 pos = (row, 1), span = (1, 2))
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()
1152 gridSizer.Add(item = label,
1154 flag = wx.ALIGN_CENTER_VERTICAL)
1155 gridSizer.Add(item = projString,
1156 pos = (row, 1), span = (1, 2),
1157 flag = wx.ALIGN_CENTER_VERTICAL)
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,
1169 flag = wx.ALIGN_CENTER_VERTICAL)
1170 gridSizer.Add(item = projFile,
1172 flag = wx.ALIGN_CENTER_VERTICAL)
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,
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,
1189 gridSizer.AddGrowableCol(1)
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)
1197 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Coordinates format"))
1198 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
1200 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
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':
1215 precision = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
1218 precision.SetValue(int(self.settings.Get(group =
'projection', key =
'format', subkey =
'precision')))
1219 self.
winId[
'projection:format:precision'] = precision.GetId()
1221 gridSizer.Add(item = ll,
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,
1228 gridSizer.Add(item = precision,
1229 flag = wx.ALIGN_CENTER_VERTICAL,
1231 gridSizer.AddGrowableCol(2)
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)
1237 panel.SetSizer(border)
1247 """!Set/unset default color table"""
1248 win = self.FindWindowById(self.
winId[
'cmd:rasterColorTable:selection'])
1249 if event.IsChecked():
1255 """!Load EPSG codes from the file"""
1256 win = self.FindWindowById(self.
winId[
'projection:statusbar:projFile'])
1257 path = win.GetValue()
1258 wx.BeginBusyCursor()
1261 epsgCombo = self.FindWindowById(self.
winId[
'projection:statusbar:epsg'])
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)
1267 epsgCombo.SetItems([])
1268 epsgCombo.SetValue(
'')
1269 self.FindWindowById(self.
winId[
'projection:statusbar:proj4']).
SetValue(
'')
1273 choices = map(str, sorted(self.epsgCodeDict.keys()))
1275 epsgCombo.SetItems(choices)
1278 win = self.FindWindowById(self.
winId[
'projection:statusbar:proj4'])
1280 epsgCombo.SetStringSelection(str(code))
1281 win.SetValue(self.
epsgCodeDict[code][1].replace(
'<>',
'').strip())
1283 epsgCombo.SetSelection(0)
1284 code = int(epsgCombo.GetStringSelection())
1285 win.SetValue(self.
epsgCodeDict[code][1].replace(
'<>',
'').strip())
1288 """!EPSG code selected"""
1289 winCode = self.FindWindowById(event.GetId())
1290 win = self.FindWindowById(self.
winId[
'projection:statusbar:proj4'])
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(
'')
1299 code = int(event.GetString())
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(
'')
1308 win.SetValue(self.
epsgCodeDict[code][1].replace(
'<>',
'').strip())
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(
'')
1317 """'Set font' button pressed"""
1319 title = _(
'Select default display font'),
1320 style = wx.DEFAULT_DIALOG_STYLE,
1323 if dlg.ShowModal() == wx.ID_OK:
1326 os.environ[
"GRASS_FONT"] = dlg.font
1327 self.settings.Set(group =
'display', value = dlg.font,
1328 key =
'font', subkey =
'type')
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')
1341 """'Set output font' button pressed
1344 title = _(
'Select output font'),
1345 style = wx.DEFAULT_DIALOG_STYLE,
1346 type =
'outputfont')
1348 if dlg.ShowModal() == wx.ID_OK:
1351 self.settings.Set(group =
'appearance', value = dlg.font,
1352 key =
'outputfont', subkey =
'type')
1354 self.settings.Set(group =
'appearance', value = dlg.fontsize,
1355 key =
'outputfont', subkey =
'size')
1384 """!Enable/disable wheel zoom mode control"""
1385 choiceId = self.
winId[
'display:mouseWheelZoom:selection']
1386 choice = self.FindWindowById(choiceId)
1387 if choice.GetSelection() == 2:
1391 scrollId = self.
winId[
'display:scrollDirection:selection']
1392 self.FindWindowById(scrollId).Enable(enable)
1396 Opens a file selection dialog to select default font
1397 to use in all GRASS displays
1399 def __init__(self, parent, title, id = wx.ID_ANY,
1400 style = wx.DEFAULT_DIALOG_STYLE |
1402 settings = UserSettings,
1408 wx.Dialog.__init__(self, parent, id, title, style = style)
1410 panel = wx.Panel(parent = self, id = wx.ID_ANY)
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)
1418 gridSizer = wx.GridBagSizer (hgap = 5, vgap = 5)
1420 label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1421 label = _(
"Select font:"))
1422 gridSizer.Add(item = label,
1423 flag = wx.ALIGN_TOP,
1426 self.
fontlb = wx.ListBox(parent = panel, id = wx.ID_ANY, pos = wx.DefaultPosition,
1428 style = wx.LB_SINGLE|wx.LB_SORT)
1432 gridSizer.Add(item = self.
fontlb,
1433 flag = wx.EXPAND, pos = (1, 0))
1435 if self.
type ==
'font':
1436 if "GRASS_FONT" in os.environ:
1437 self.
font = os.environ[
"GRASS_FONT"]
1439 self.
font = self.settings.Get(group =
'display',
1440 key =
'font', subkey =
'type')
1442 key =
'font', subkey =
'encoding')
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,
1450 self.
textentry = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
1453 flag = wx.EXPAND, pos = (3, 0))
1455 self.textentry.Bind(wx.EVT_TEXT, self.
OnEncoding)
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,
1468 self.
spin = wx.SpinCtrl(parent = panel, id = wx.ID_ANY)
1470 self.spin.SetValue(int(self.
fontsize))
1471 self.spin.Bind(wx.EVT_SPINCTRL, self.
OnSizeSpin)
1473 gridSizer.Add(item = self.
spin,
1474 flag = wx.ALIGN_CENTER_VERTICAL,
1481 self.fontlb.SetStringSelection(self.
font,
True)
1483 gridSizer.AddGrowableCol(0)
1484 sizer.Add(item = gridSizer, proportion = 1,
1485 flag = wx.EXPAND | wx.ALL,
1488 border.Add(item = sizer, proportion = 1,
1489 flag = wx.ALL | wx.EXPAND, border = 3)
1491 btnsizer = wx.StdDialogButtonSizer()
1493 btn = wx.Button(parent = panel, id = wx.ID_OK)
1495 btnsizer.AddButton(btn)
1497 btn = wx.Button(parent = panel, id = wx.ID_CANCEL)
1498 btnsizer.AddButton(btn)
1501 border.Add(item = btnsizer, proportion = 0,
1502 flag = wx.EXPAND | wx.ALIGN_RIGHT | wx.ALL, border = 5)
1504 panel.SetAutoLayout(
True)
1505 panel.SetSizer(border)
1511 if event.GetInt() == 0:
1513 elif event.GetInt() == 1:
1517 self.fontlb.SetItems(self.
fontlist)
1523 self.
font = event.GetString()
1527 self.
font = event.GetString()
1531 self.
fontsize = self.spin.GetValue()
1536 parses fonts directory or fretypecap file to get a list of fonts for the listbox
1547 dfonts = ret.splitlines()
1548 dfonts.sort(
lambda x,y: cmp(x.lower(), y.lower()))
1549 for item
in range(len(dfonts)):
1551 if not dfonts[item].startswith(
'#')
and \
1552 dfonts[item] != dfonts[item-1]:
1553 fontlist.append(dfonts[item])
1558 """!Controls setting options and displaying/hiding map overlay
1561 def __init__(self, parent, id = wx.ID_ANY,
1562 title = _(
'Manage access to mapsets'),
1564 style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, **kwargs):
1565 wx.Dialog.__init__(self, parent, id, title, size = size, style = style, **kwargs)
1572 sizer = wx.BoxSizer(wx.VERTICAL)
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"
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."))
1581 sizer.Add(item = label, proportion = 0,
1582 flag = wx.ALL, border = 5)
1585 self.mapsetlb.LoadData()
1587 sizer.Add(item = self.
mapsetlb, proportion = 1,
1588 flag = wx.ALL | wx.EXPAND, border = 5)
1592 self.mapsetlb.CheckItem(self.all_mapsets_ordered.index(mset),
True)
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)
1603 btnsizer = wx.StdDialogButtonSizer()
1604 okbtn = wx.Button(self, wx.ID_OK)
1606 btnsizer.AddButton(okbtn)
1608 cancelbtn = wx.Button(self, wx.ID_CANCEL)
1609 btnsizer.AddButton(cancelbtn)
1612 sizer.Add(item = btnsizer, proportion = 0,
1613 flag = wx.EXPAND | wx.ALIGN_RIGHT | wx.ALL, border = 5)
1617 self.SetSizer(sizer)
1620 self.SetMinSize(size)
1623 """!Get list of checked mapsets"""
1627 if self.mapsetlb.IsChecked(i):
1633 class CheckListMapset(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.CheckListCtrlMixin):
1634 """!List of mapset/owner/group"""
1635 def __init__(self, parent, pos = wx.DefaultPosition,
1639 wx.ListCtrl.__init__(self, parent, wx.ID_ANY,
1640 style = wx.LC_REPORT)
1641 listmix.CheckListCtrlMixin.__init__(self)
1645 listmix.ListCtrlAutoWidthMixin.__init__(self)
1648 """!Load data into list"""
1649 self.InsertColumn(0, _(
'Mapset'))
1650 self.InsertColumn(1, _(
'Owner'))
1652 gisenv = grass.gisenv()
1653 locationPath = os.path.join(gisenv[
'GISDBASE'], gisenv[
'LOCATION_NAME'])
1655 for mapset
in self.parent.all_mapsets_ordered:
1656 index = self.InsertStringItem(sys.maxint, mapset)
1657 mapsetPath = os.path.join(locationPath,
1659 stat_info = os.stat(mapsetPath)
1661 self.SetStringItem(index, 1,
"%s" % pwd.getpwuid(stat_info.st_uid)[0])
1666 self.SetStringItem(index, 1,
"%-8s" % stat_info.st_uid)
1669 self.SetColumnWidth(col = 0, width = wx.LIST_AUTOSIZE)
1673 """!Mapset checked/unchecked"""
1674 mapset = self.parent.all_mapsets_ordered[index]
1675 if mapset == self.parent.curr_mapset:
1676 self.CheckItem(index,
True)
List of mapset/owner/group.
def OnCheckItem
Mapset checked/unchecked.
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.