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)
279 gridSizer.AddGrowableCol(0)
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))
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)
347 gridSizer.AddGrowableCol(0)
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))
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)
408 gridSizer.AddGrowableCol(0)
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"), size = (100, -1))
424 gridSizer.Add(item = outfontButton,
425 flag = wx.ALIGN_RIGHT |
426 wx.ALIGN_CENTER_VERTICAL,
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 gridSizer.AddGrowableCol(0)
437 sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
438 border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
441 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
442 label = _(
"Choose language (requires to save and GRASS restart):")),
443 flag = wx.ALIGN_LEFT |
444 wx.ALIGN_CENTER_VERTICAL,
446 locales = self.settings.Get(group =
'language', key =
'locale',
447 subkey =
'choices', internal =
True)
448 loc = self.settings.Get(group =
'language', key =
'locale', subkey =
'lc_all')
449 elementList = wx.Choice(parent = panel, id = wx.ID_ANY, size = (325, -1),
450 choices = locales, name =
"GetStringSelection")
452 elementList.SetStringSelection(loc)
454 elementList.SetStringSelection(
'en')
455 self.
winId[
'language:locale:lc_all'] = elementList.GetId()
457 gridSizer.Add(item = elementList,
458 flag = wx.ALIGN_RIGHT |
459 wx.ALIGN_CENTER_VERTICAL,
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)
468 gridSizer.AddGrowableCol(0)
474 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
475 label = _(
"Element list:")),
476 flag = wx.ALIGN_LEFT |
477 wx.ALIGN_CENTER_VERTICAL,
479 elementList = wx.Choice(parent = panel, id = wx.ID_ANY, size = (325, -1),
480 choices = self.settings.Get(group =
'appearance', key =
'elementListExpand',
481 subkey =
'choices', internal =
True),
482 name =
"GetSelection")
483 elementList.SetSelection(self.settings.Get(group =
'appearance', key =
'elementListExpand',
484 subkey =
'selection'))
485 self.
winId[
'appearance:elementListExpand:selection'] = elementList.GetId()
487 gridSizer.Add(item = elementList,
488 flag = wx.ALIGN_RIGHT |
489 wx.ALIGN_CENTER_VERTICAL,
496 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
497 label = _(
"Menu style (requires to save and GUI restart):")),
498 flag = wx.ALIGN_LEFT |
499 wx.ALIGN_CENTER_VERTICAL,
501 listOfStyles = self.settings.Get(group =
'appearance', key =
'menustyle',
502 subkey =
'choices', internal =
True)
504 menuItemText = wx.Choice(parent = panel, id = wx.ID_ANY, size = (325, -1),
505 choices = listOfStyles,
506 name =
"GetSelection")
507 menuItemText.SetSelection(self.settings.Get(group =
'appearance', key =
'menustyle', subkey =
'selection'))
509 self.
winId[
'appearance:menustyle:selection'] = menuItemText.GetId()
511 gridSizer.Add(item = menuItemText,
512 flag = wx.ALIGN_RIGHT,
520 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
521 label = _(
"Height of map selection popup window (in pixels):")),
522 flag = wx.ALIGN_LEFT |
523 wx.ALIGN_CENTER_VERTICAL,
525 min = self.settings.Get(group =
'appearance', key =
'gSelectPopupHeight', subkey =
'min', internal =
True)
526 max = self.settings.Get(group =
'appearance', key =
'gSelectPopupHeight', subkey =
'max', internal =
True)
527 value = self.settings.Get(group =
'appearance', key =
'gSelectPopupHeight', subkey =
'value')
529 popupHeightSpin = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (100, -1))
530 popupHeightSpin.SetRange(min,max)
531 popupHeightSpin.SetValue(value)
533 self.
winId[
'appearance:gSelectPopupHeight:value'] = popupHeightSpin.GetId()
535 gridSizer.Add(item = popupHeightSpin,
536 flag = wx.ALIGN_RIGHT,
544 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
545 label = _(
"Icon theme (requires GUI restart):")),
546 flag = wx.ALIGN_LEFT |
547 wx.ALIGN_CENTER_VERTICAL,
549 iconTheme = wx.Choice(parent = panel, id = wx.ID_ANY, size = (100, -1),
550 choices = self.settings.Get(group =
'appearance', key =
'iconTheme',
551 subkey =
'choices', internal =
True),
552 name =
"GetStringSelection")
553 iconTheme.SetStringSelection(self.settings.Get(group =
'appearance', key =
'iconTheme', subkey =
'type'))
554 self.
winId[
'appearance:iconTheme:type'] = iconTheme.GetId()
556 gridSizer.Add(item = iconTheme,
557 flag = wx.ALIGN_RIGHT |
558 wx.ALIGN_CENTER_VERTICAL,
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)
583 gridSizer.AddGrowableCol(0)
589 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
590 label = _(
"Default font for GRASS displays:")),
591 flag = wx.ALIGN_LEFT |
592 wx.ALIGN_CENTER_VERTICAL,
594 fontButton = wx.Button(parent = panel, id = wx.ID_ANY,
595 label = _(
"Set font"), size = (100, -1))
596 gridSizer.Add(item = fontButton,
597 flag = wx.ALIGN_RIGHT |
598 wx.ALIGN_CENTER_VERTICAL,
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)
611 gridSizer.AddGrowableCol(0)
618 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
619 label = _(
"Display driver:")),
620 flag = wx.ALIGN_LEFT |
621 wx.ALIGN_CENTER_VERTICAL,
623 listOfDrivers = self.settings.Get(group=
'display', key=
'driver', subkey=
'choices', internal=
True)
625 if 'cairo' not in listOfDrivers:
628 read =
True).splitlines():
634 driver = wx.Choice(parent=panel, id=wx.ID_ANY, size=(150, -1),
635 choices=listOfDrivers,
636 name=
"GetStringSelection")
637 driver.SetStringSelection(self.settings.Get(group=
'display', key=
'driver', subkey=
'type'))
638 self.
winId[
'display:driver:type'] = driver.GetId()
640 gridSizer.Add(item = driver,
641 flag = wx.ALIGN_RIGHT,
648 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
649 label = _(
"Statusbar mode:")),
650 flag = wx.ALIGN_LEFT |
651 wx.ALIGN_CENTER_VERTICAL,
653 listOfModes = self.settings.Get(group =
'display', key =
'statusbarMode', subkey =
'choices', internal =
True)
654 statusbarMode = wx.Choice(parent = panel, id = wx.ID_ANY, size = (150, -1),
655 choices = listOfModes,
656 name =
"GetSelection")
657 statusbarMode.SetSelection(self.settings.Get(group =
'display', key =
'statusbarMode', subkey =
'selection'))
658 self.
winId[
'display:statusbarMode:selection'] = statusbarMode.GetId()
660 gridSizer.Add(item = statusbarMode,
661 flag = wx.ALIGN_RIGHT,
668 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
669 label = _(
"Background color:")),
670 flag = wx.ALIGN_LEFT |
671 wx.ALIGN_CENTER_VERTICAL,
673 bgColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
674 colour = self.settings.Get(group =
'display', key =
'bgcolor', subkey =
'color'),
675 size = globalvar.DIALOG_COLOR_SIZE)
676 bgColor.SetName(
'GetColour')
677 self.
winId[
'display:bgcolor:color'] = bgColor.GetId()
679 gridSizer.Add(item = bgColor,
680 flag = wx.ALIGN_RIGHT,
687 alignExtent = wx.CheckBox(parent = panel, id = wx.ID_ANY,
688 label = _(
"Align region extent based on display size"),
690 alignExtent.SetValue(self.settings.Get(group =
'display', key =
'alignExtent', subkey =
'enabled'))
691 self.
winId[
'display:alignExtent:enabled'] = alignExtent.GetId()
693 gridSizer.Add(item = alignExtent,
694 pos = (row, 0), span = (1, 2))
700 compResolution = wx.CheckBox(parent = panel, id = wx.ID_ANY,
701 label = _(
"Constrain display resolution to computational settings"),
703 compResolution.SetValue(self.settings.Get(group =
'display', key =
'compResolution', subkey =
'enabled'))
704 self.
winId[
'display:compResolution:enabled'] = compResolution.GetId()
706 gridSizer.Add(item = compResolution,
707 pos = (row, 0), span = (1, 2))
713 autoRendering = wx.CheckBox(parent = panel, id = wx.ID_ANY,
714 label = _(
"Enable auto-rendering"),
716 autoRendering.SetValue(self.settings.Get(group =
'display', key =
'autoRendering', subkey =
'enabled'))
717 self.
winId[
'display:autoRendering:enabled'] = autoRendering.GetId()
719 gridSizer.Add(item = autoRendering,
720 pos = (row, 0), span = (1, 2))
726 autoZooming = wx.CheckBox(parent = panel, id = wx.ID_ANY,
727 label = _(
"Enable auto-zooming to selected map layer"),
729 autoZooming.SetValue(self.settings.Get(group =
'display', key =
'autoZooming', subkey =
'enabled'))
730 self.
winId[
'display:autoZooming:enabled'] = autoZooming.GetId()
732 gridSizer.Add(item = autoZooming,
733 pos = (row, 0), span = (1, 2))
739 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
740 label = _(
"Mouse wheel action:")),
741 flag = wx.ALIGN_LEFT |
742 wx.ALIGN_CENTER_VERTICAL,
744 listOfModes = self.settings.Get(group =
'display', key =
'mouseWheelZoom', subkey =
'choices', internal =
True)
745 zoomAction = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
746 choices = listOfModes,
747 name =
"GetSelection")
748 zoomAction.SetSelection(self.settings.Get(group =
'display', key =
'mouseWheelZoom', subkey =
'selection'))
749 self.
winId[
'display:mouseWheelZoom:selection'] = zoomAction.GetId()
750 gridSizer.Add(item = zoomAction,
751 flag = wx.ALIGN_RIGHT,
754 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
755 label = _(
"Mouse scrolling direction:")),
756 flag = wx.ALIGN_LEFT |
757 wx.ALIGN_CENTER_VERTICAL,
759 listOfModes = self.settings.Get(group =
'display', key =
'scrollDirection', subkey =
'choices', internal =
True)
760 scrollDir = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
761 choices = listOfModes,
762 name =
"GetSelection")
763 scrollDir.SetSelection(self.settings.Get(group =
'display', key =
'scrollDirection', subkey =
'selection'))
764 self.
winId[
'display:scrollDirection:selection'] = scrollDir.GetId()
765 gridSizer.Add(item = scrollDir,
766 flag = wx.ALIGN_RIGHT,
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)
824 gridSizer.AddGrowableCol(0)
831 overwrite = wx.CheckBox(parent = panel, id = wx.ID_ANY,
832 label = _(
"Allow output files to overwrite existing files"),
834 overwrite.SetValue(self.settings.Get(group =
'cmd', key =
'overwrite', subkey =
'enabled'))
835 self.
winId[
'cmd:overwrite:enabled'] = overwrite.GetId()
837 gridSizer.Add(item = overwrite,
838 pos = (row, 0), span = (1, 2))
841 close = wx.CheckBox(parent = panel, id = wx.ID_ANY,
842 label = _(
"Close dialog when command is successfully finished"),
844 close.SetValue(self.settings.Get(group =
'cmd', key =
'closeDlg', subkey =
'enabled'))
845 self.
winId[
'cmd:closeDlg:enabled'] = close.GetId()
847 gridSizer.Add(item = close,
848 pos = (row, 0), span = (1, 2))
851 add = wx.CheckBox(parent = panel, id = wx.ID_ANY,
852 label = _(
"Add created map into layer tree"),
854 add.SetValue(self.settings.Get(group =
'cmd', key =
'addNewLayer', subkey =
'enabled'))
855 self.
winId[
'cmd:addNewLayer:enabled'] = add.GetId()
857 gridSizer.Add(item = add,
858 pos = (row, 0), span = (1, 2))
862 interactive = wx.CheckBox(parent = panel, id = wx.ID_ANY,
863 label = _(
"Allow interactive input"),
865 interactive.SetValue(self.settings.Get(group =
'cmd', key =
'interactiveInput', subkey =
'enabled'))
866 self.
winId[
'cmd:interactiveInput:enabled'] = interactive.GetId()
867 gridSizer.Add(item = interactive,
868 pos = (row, 0), span = (1, 2))
872 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
873 label = _(
"Verbosity level:")),
874 flag = wx.ALIGN_LEFT |
875 wx.ALIGN_CENTER_VERTICAL,
877 verbosity = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
878 choices = self.settings.Get(group =
'cmd', key =
'verbosity', subkey =
'choices', internal =
True),
879 name =
"GetStringSelection")
880 verbosity.SetStringSelection(self.settings.Get(group =
'cmd', key =
'verbosity', subkey =
'selection'))
881 self.
winId[
'cmd:verbosity:selection'] = verbosity.GetId()
883 gridSizer.Add(item = verbosity,
884 pos = (row, 1), flag = wx.ALIGN_RIGHT)
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)
896 gridSizer.AddGrowableCol(0)
902 rasterOverlay = wx.CheckBox(parent=panel, id=wx.ID_ANY,
903 label=_(
"Overlay raster maps"),
905 rasterOverlay.SetValue(self.settings.Get(group=
'cmd', key=
'rasterOverlay', subkey=
'enabled'))
906 self.
winId[
'cmd:rasterOverlay:enabled'] = rasterOverlay.GetId()
908 gridSizer.Add(item=rasterOverlay,
909 pos=(row, 0), span=(1, 2))
913 rasterCTCheck = wx.CheckBox(parent = panel, id = wx.ID_ANY,
914 label = _(
"Default color table"),
916 rasterCTCheck.SetValue(self.settings.Get(group =
'cmd', key =
'rasterColorTable', subkey =
'enabled'))
917 self.
winId[
'cmd:rasterColorTable:enabled'] = rasterCTCheck.GetId()
920 gridSizer.Add(item = rasterCTCheck, flag = wx.ALIGN_CENTER_VERTICAL,
923 rasterCTName = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
925 name =
"GetStringSelection")
926 rasterCTName.SetStringSelection(self.settings.Get(group =
'cmd', key =
'rasterColorTable', subkey =
'selection'))
927 self.
winId[
'cmd:rasterColorTable:selection'] = rasterCTName.GetId()
928 if not rasterCTCheck.IsChecked():
929 rasterCTName.Enable(
False)
931 gridSizer.Add(item = rasterCTName,
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)
981 flexSizer.AddGrowableCol(0)
983 label = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _(
"Color:"))
984 hlColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
985 colour = self.settings.Get(group =
'atm', key =
'highlight', subkey =
'color'),
986 size = globalvar.DIALOG_COLOR_SIZE)
987 hlColor.SetName(
'GetColour')
988 self.
winId[
'atm:highlight:color'] = hlColor.GetId()
990 flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
991 flexSizer.Add(hlColor, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
993 label = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _(
"Line width (in pixels):"))
994 hlWidth = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (50, -1),
995 initial = self.settings.Get(group =
'atm', key =
'highlight',subkey =
'width'),
997 self.
winId[
'atm:highlight:width'] = hlWidth.GetId()
999 flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
1000 flexSizer.Add(hlWidth, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
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 flexSizer.AddGrowableCol(0)
1021 label = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _(
"Left mouse double click:"))
1022 leftDbClick = wx.Choice(parent = panel, id = wx.ID_ANY,
1023 choices = self.settings.Get(group =
'atm', key =
'leftDbClick', subkey =
'choices', internal =
True),
1024 name =
"GetSelection")
1025 leftDbClick.SetSelection(self.settings.Get(group =
'atm', key =
'leftDbClick', subkey =
'selection'))
1026 self.
winId[
'atm:leftDbClick:selection'] = leftDbClick.GetId()
1028 flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
1029 flexSizer.Add(leftDbClick, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
1032 label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1033 label = _(
"Encoding (e.g. utf-8, ascii, iso8859-1, koi8-r):"))
1034 encoding = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
1035 value = self.settings.Get(group =
'atm', key =
'encoding', subkey =
'value'),
1036 name =
"GetValue", size = (200, -1))
1037 self.
winId[
'atm:encoding:value'] = encoding.GetId()
1039 flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
1040 flexSizer.Add(encoding, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
1043 askOnDeleteRec = wx.CheckBox(parent = panel, id = wx.ID_ANY,
1044 label = _(
"Ask when deleting data record(s) from table"),
1046 askOnDeleteRec.SetValue(self.settings.Get(group =
'atm', key =
'askOnDeleteRec', subkey =
'enabled'))
1047 self.
winId[
'atm:askOnDeleteRec:enabled'] = askOnDeleteRec.GetId()
1049 flexSizer.Add(askOnDeleteRec, proportion = 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)
1069 flexSizer.AddGrowableCol(0)
1071 label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1072 label = _(
"Key column:"))
1073 keyColumn = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
1075 keyColumn.SetValue(self.settings.Get(group =
'atm', key =
'keycolumn', subkey =
'value'))
1076 self.
winId[
'atm:keycolumn:value'] = keyColumn.GetId()
1078 flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
1079 flexSizer.Add(keyColumn, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
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)
1110 gridSizer.AddGrowableCol(1)
1114 note0 = wx.StaticText(parent = panel, id = wx.ID_ANY,
1115 label = _(
"\nNote: This only controls the coordinates "
1116 "displayed in the lower-left of the Map "
1117 "Display\nwindow's status bar. It is purely "
1118 "cosmetic and does not affect the working "
1119 "location's\nprojection in any way. You will "
1120 "need to enable the Projection check box in "
1121 "the drop-down\nmenu located at the bottom "
1122 "of the Map Display window.\n"))
1123 gridSizer.Add(item = note0,
1129 label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1130 label = _(
"EPSG code:"))
1131 epsgCode = wx.ComboBox(parent = panel, id = wx.ID_ANY,
1135 epsgCode.SetValue(str(self.settings.Get(group =
'projection', key =
'statusbar', subkey =
'epsg')))
1136 self.
winId[
'projection:statusbar:epsg'] = epsgCode.GetId()
1138 gridSizer.Add(item = label,
1140 flag = wx.ALIGN_CENTER_VERTICAL)
1141 gridSizer.Add(item = epsgCode,
1142 pos = (row, 1), span = (1, 2))
1146 label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1147 label = _(
"Proj.4 string (required):"))
1148 projString = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
1149 value = self.settings.Get(group =
'projection', key =
'statusbar', subkey =
'proj4'),
1150 name =
"GetValue", size = (400, -1))
1151 self.
winId[
'projection:statusbar:proj4'] = projString.GetId()
1153 gridSizer.Add(item = label,
1155 flag = wx.ALIGN_CENTER_VERTICAL)
1156 gridSizer.Add(item = projString,
1157 pos = (row, 1), span = (1, 2),
1158 flag = wx.ALIGN_CENTER_VERTICAL)
1162 label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1163 label = _(
"EPSG file:"))
1164 projFile = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
1165 value = self.settings.Get(group =
'projection', key =
'statusbar', subkey =
'projFile'),
1166 name =
"GetValue", size = (400, -1))
1167 self.
winId[
'projection:statusbar:projFile'] = projFile.GetId()
1168 gridSizer.Add(item = label,
1170 flag = wx.ALIGN_CENTER_VERTICAL)
1171 gridSizer.Add(item = projFile,
1173 flag = wx.ALIGN_CENTER_VERTICAL)
1177 note = wx.StaticText(parent = panel, id = wx.ID_ANY,
1178 label = _(
"Load EPSG codes (be patient), enter EPSG code or "
1179 "insert Proj.4 string directly."))
1180 gridSizer.Add(item = note,
1185 epsgLoad = wx.Button(parent = panel, id = wx.ID_ANY,
1186 label = _(
"&Load EPSG codes"))
1187 gridSizer.Add(item = epsgLoad,
1188 flag = wx.ALIGN_RIGHT,
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)
1201 gridSizer.AddGrowableCol(2)
1205 ll = wx.RadioBox(parent = panel, id = wx.ID_ANY,
1206 label =
" %s " % _(
"LL projections"),
1207 choices = [
"DMS",
"DEG"],
1208 name =
"GetStringSelection")
1209 self.
winId[
'projection:format:ll'] = ll.GetId()
1210 if self.settings.Get(group =
'projection', key =
'format', subkey =
'll') ==
'DMS':
1216 precision = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
1219 precision.SetValue(int(self.settings.Get(group =
'projection', key =
'format', subkey =
'precision')))
1220 self.
winId[
'projection:format:precision'] = precision.GetId()
1222 gridSizer.Add(item = ll,
1224 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
1225 label = _(
"Precision:")),
1226 flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.LEFT,
1229 gridSizer.Add(item = precision,
1230 flag = wx.ALIGN_CENTER_VERTICAL,
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)
1419 gridSizer.AddGrowableCol(0)
1421 label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1422 label = _(
"Select font:"))
1423 gridSizer.Add(item = label,
1424 flag = wx.ALIGN_TOP,
1427 self.
fontlb = wx.ListBox(parent = panel, id = wx.ID_ANY, pos = wx.DefaultPosition,
1429 style = wx.LB_SINGLE|wx.LB_SORT)
1433 gridSizer.Add(item = self.
fontlb,
1434 flag = wx.EXPAND, pos = (1, 0))
1436 if self.
type ==
'font':
1437 if "GRASS_FONT" in os.environ:
1438 self.
font = os.environ[
"GRASS_FONT"]
1440 self.
font = self.settings.Get(group =
'display',
1441 key =
'font', subkey =
'type')
1443 key =
'font', subkey =
'encoding')
1445 label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1446 label = _(
"Character encoding:"))
1447 gridSizer.Add(item = label,
1448 flag = wx.ALIGN_CENTER_VERTICAL,
1451 self.
textentry = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
1454 flag = wx.EXPAND, pos = (3, 0))
1456 self.textentry.Bind(wx.EVT_TEXT, self.
OnEncoding)
1458 elif self.
type ==
'outputfont':
1459 self.
font = self.settings.Get(group =
'appearance',
1460 key =
'outputfont', subkey =
'type')
1461 self.
fontsize = self.settings.Get(group =
'appearance',
1462 key =
'outputfont', subkey =
'size')
1463 label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1464 label = _(
"Font size:"))
1465 gridSizer.Add(item = label,
1466 flag = wx.ALIGN_CENTER_VERTICAL,
1469 self.
spin = wx.SpinCtrl(parent = panel, id = wx.ID_ANY)
1471 self.spin.SetValue(int(self.
fontsize))
1472 self.spin.Bind(wx.EVT_SPINCTRL, self.
OnSizeSpin)
1474 gridSizer.Add(item = self.
spin,
1475 flag = wx.ALIGN_CENTER_VERTICAL,
1482 self.fontlb.SetStringSelection(self.
font,
True)
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)