4 @brief User preferences dialog
6 Sets default display font, etc.
7 If you want to add some value to settings you have to add default value
8 to defaultSettings and set constraints in internalSettings in Settings class.
9 Everything can be used in PreferencesDialog.
13 - PreferencesBaseDialog
17 - NvizPreferencesDialog
19 (C) 2007-2011 by the GRASS Development Team
20 This program is free software under the GNU General Public
21 License (>=v2). Read the file COPYING that comes with GRASS
24 @author Michael Barton (Arizona State University)
25 @author Martin Landa <landa.martin gmail.com>
26 @author Vaclav Petras <wenzeslaus gmail.com> (menu customization)
42 gettext.install(
'grasswxpy', os.path.join(os.getenv(
"GISBASE"),
'locale'), unicode =
True)
45 import wx.lib.filebrowsebutton
as filebrowse
46 import wx.lib.colourselect
as csel
47 import wx.lib.mixins.listctrl
as listmix
54 from debug
import Debug
as Debug
56 from wx.lib.newevent
import NewEvent
58 wxSettingsChanged, EVT_SETTINGS_CHANGED = NewEvent()
61 """!Generic class where to store settings"""
64 self.
filePath = os.path.join(utils.GetSettingsPath(),
'wx')
70 projFile = utils.PathJoin(os.environ[
"GRASS_PROJSHARE"],
'epsg')
85 'dim' :
'0,0,%d,%d,%d,0,%d,%d' % \
86 (globalvar.GM_WINDOW_SIZE[0],
87 globalvar.GM_WINDOW_SIZE[1],
88 globalvar.GM_WINDOW_SIZE[0],
89 globalvar.MAP_WINDOW_SIZE[0],
90 globalvar.MAP_WINDOW_SIZE[1])
104 'changeOpacityLevel' : {
108 'askOnRemoveLayer' : {
120 'copySelectedTextToClipboard' : {
129 'type' :
'Courier New',
133 'elementListExpand' : {
139 'gSelectPopupHeight' : {
152 'encoding':
'ISO-8859-1',
170 'color' : (255, 255, 255, 255),
180 'projFile' : projFile,
192 'color' : (255, 255, 0, 255),
219 'selection' :
'grassenv'
225 'rasterColorTable' : {
227 'selection' :
'rainbow',
253 'interactiveInput' : {
265 'color' : (255, 255, 0, 255)
269 'color' : (255, 72, 0, 255)
273 'color' : (0, 0, 0, 255)
277 'color' : (0, 0, 0, 255)
281 'color' : (126, 126, 126, 255)
285 'color' : (0, 255, 0, 255)
289 'color' : (255, 135, 0, 255)
293 'color' : (0, 0, 255, 255)
297 'color' : (165, 42, 42, 255)
301 'color' : (156, 62, 206, 255)
305 'color' : (255, 0, 0, 255)
309 'color' : (0, 86, 45, 255)
313 'color' : (255, 20, 147, 255)
317 'color' : (217, 255, 217, 255)
321 'color' : (255, 0, 0, 255)
327 'units' :
'screen pixels'
332 'units' :
'screen pixels'
360 'than-selection' : 0,
364 'than-selection' : 0,
384 'units' :
'screen pixels'
403 'pcolor' : (0, 0, 255, 255),
408 'pcolor' : (255, 0, 0, 255),
413 'pcolor' : (0, 255, 0, 255),
423 'color' : (0, 0, 0, 255),
424 'fill' :
'transparent',
427 'legend' : _(
'Segment break'),
430 'color' : (200, 200, 200, 255),
451 'highestonly' :
True,
455 'color' : (0, 0, 255, 255),
456 'hcolor' : (255, 0, 0, 255),
457 'scolor' : (0, 255, 0, 255),
458 'ucolor' : (255, 165, 0, 255),
466 'color' : (0, 0, 255, 255),
491 'color' : (255, 255, 255, 255),
501 'value' : (0, 0, 0, 255),
504 'wire-color' : (136, 136, 136, 255),
521 'color' : (0, 0, 255, 255),
530 'color' : (0, 0, 255, 255),
537 'value' : (0, 0, 0, 255),
556 'color' : (255, 255, 255, 255),
561 'color' : (128, 128, 128, 255),
566 'color': (211, 211, 211, 255),
570 'valid' : (180, 234, 154, 255),
571 'invalid' : (255, 255, 255, 255),
572 'running' : (255, 0, 0, 255),
585 'raster' : (215, 215, 248, 255),
586 'raster3d' : (215, 248, 215, 255),
587 'vector' : (248, 215, 215, 255),
596 'valid' : (234, 226, 154, 255),
614 if sys.platform ==
'darwin':
624 print >> sys.stderr, e.value
630 for group
in self.userSettings.keys():
637 (_(
"Collapse all except PERMANENT and current"),
638 _(
"Collapse all except PERMANENT"),
639 _(
"Collapse all except current"),
642 self.
internalSettings[
'atm'][
'leftDbClick'][
'choices'] = (_(
'Edit selected record'),
643 _(
'Display selected'))
653 (_(
"Classic (labels only)"),
654 _(
"Combined (labels and module names)"),
655 _(
"Professional (module names only)"))
661 self.
internalSettings[
'display'][
'statusbarMode'][
'choices'] = globalvar.MAP_DISPLAY_STATUSBAR_MODE
688 """!Reads settings file (mapset, location, gisdbase)"""
695 font = self.
Get(group =
'display', key =
'font', subkey =
'type')
696 enc = self.
Get(group =
'display', key =
'font', subkey =
'encoding')
698 os.environ[
"GRASS_FONT"] = font
700 os.environ[
"GRASS_ENCODING"] = enc
702 def _readFile(self, filename, settings = None):
703 """!Read settings from file to dict
705 @param filename settings file path
706 @param settings dict where to store settings (None for self.userSettings)
711 if not os.path.exists(filename):
713 filename = os.path.join(os.path.expanduser(
"~"),
'.grasswx6')
714 if not os.path.exists(filename):
718 fd = open(filename,
"r")
720 sys.stderr.write(_(
"Unable to read settings file <%s>\n") % filename)
725 for line
in fd.readlines():
726 line = line.rstrip(
'%s' % os.linesep)
727 group, key = line.split(self.
sep)[0:2]
728 kv = line.split(self.
sep)[2:]
736 subkey = [subkeyMaster, kv[idx]]
741 self.
Append(settings, group, key, subkey, value)
743 except ValueError, e:
744 print >> sys.stderr, _(
"Error: Reading settings from file <%(file)s> failed.\n"
745 "\t\tDetails: %(detail)s\n"
746 "\t\tLine: '%(line)s'\n") % {
'file' : filename,
754 """!Save settings to the file"""
758 dirPath = utils.GetSettingsPath()
759 if not os.path.exists(dirPath):
763 gcmd.GError(_(
'Unable to create settings directory'))
768 for group
in settings.keys():
769 for key
in settings[group].keys():
770 subkeys = settings[group][key].keys()
771 file.write(
'%s%s%s%s' % (group, self.
sep, key, self.
sep))
772 for idx
in range(len(subkeys)):
773 value = settings[group][key][subkeys[idx]]
774 if type(value) == types.DictType:
776 file.write(
'%s%s%s%s%s' % (os.linesep, group, self.
sep, key, self.
sep))
777 file.write(
'%s%s' % (subkeys[idx], self.
sep))
778 kvalues = settings[group][key][subkeys[idx]].keys()
779 srange = range(len(kvalues))
781 svalue = self.
_parseValue(settings[group][key][subkeys[idx]][kvalues[sidx]])
782 file.write(
'%s%s%s' % (kvalues[sidx], self.
sep,
784 if sidx < len(kvalues) - 1:
785 file.write(
'%s' % self.
sep)
788 type(settings[group][key][subkeys[idx - 1]]) == types.DictType:
789 file.write(
'%s%s%s%s%s' % (os.linesep, group, self.
sep, key, self.
sep))
790 value = self.
_parseValue(settings[group][key][subkeys[idx]])
791 file.write(
'%s%s%s' % (subkeys[idx], self.
sep, value))
792 if idx < len(subkeys) - 1
and \
793 type(settings[group][key][subkeys[idx + 1]]) != types.DictType:
794 file.write(
'%s' % self.
sep)
795 file.write(os.linesep)
798 except StandardError, e:
800 '\n\nDetails: %(detail)s') % {
'file' : self.
filePath,
805 def _parseValue(self, value, read = False):
806 """!Parse value to be store in settings file"""
810 elif value ==
'False':
812 elif value ==
'None':
816 value = tuple(
map(int, value.split(
':')))
829 value = str(value[0]) +
':' +\
830 str(value[1]) +
':' + \
835 def Get(self, group, key = None, subkey = None, internal = False):
836 """!Get value by key/subkey
838 Raise KeyError if key is not found
840 @param group settings group
841 @param key (value, None)
842 @param subkey (value, list or None)
843 @param internal use internal settings instead
855 return settings[group]
857 return settings[group][key]
859 if type(subkey) ==
type(tuple())
or \
861 return settings[group][key][subkey[0]][subkey[1]]
863 return settings[group][key][subkey]
866 print >> sys.stderr,
"Settings: unable to get value '%s:%s:%s'\n" % \
869 def Set(self, group, value, key = None, subkey = None, internal = False):
870 """!Set value of key/subkey
872 Raise KeyError if group/key is not found
874 @param group settings group
875 @param key key (value, None)
876 @param subkey subkey (value, list or None)
878 @param internal use internal settings instead
888 settings[group] = value
890 settings[group][key] = value
892 if type(subkey) ==
type(tuple())
or \
894 settings[group][key][subkey[0]][subkey[1]] = value
896 settings[group][key][subkey] = value
898 raise gcmd.GException(
"%s '%s:%s:%s'" % (_(
"Unable to set "), group, key, subkey))
900 def Append(self, dict, group, key, subkey, value):
901 """!Set value of key/subkey
903 Create group/key/subkey if not exists
905 @param dict settings dictionary to use
906 @param group settings group
908 @param subkey subkey (value or list)
911 if group
not in dict:
914 if key
not in dict[group]:
915 dict[group][key] = {}
917 if type(subkey) == types.ListType:
919 if subkey[0]
not in dict[group][key]:
920 dict[group][key][subkey[0]] = {}
922 dict[group][key][subkey[0]][subkey[1]] = value
924 print >> sys.stderr, _(
"Unable to parse settings '%s'") % value + \
925 ' (' + group +
':' + key +
':' + subkey[0] +
':' + subkey[1] +
')'
928 dict[group][key][subkey] = value
930 print >> sys.stderr, _(
"Unable to parse settings '%s'") % value + \
931 ' (' + group +
':' + key +
':' + subkey +
')'
934 """!Get default user settings"""
940 """!Base preferences dialog"""
941 def __init__(self, parent, settings, title = _(
"User settings"),
943 style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
949 wx.Dialog.__init__(self, parent = parent, id = wx.ID_ANY, title = title,
953 self.
notebook = wx.Notebook(parent = self, id = wx.ID_ANY, style = wx.BK_DEFAULT)
961 self.
btnDefault = wx.Button(self, wx.ID_ANY, _(
"Set to default"))
965 self.btnSave.SetDefault()
968 self.btnDefault.Bind(wx.EVT_BUTTON, self.
OnDefault)
969 self.btnDefault.SetToolTipString(_(
"Revert settings to default and apply changes"))
970 self.btnApply.Bind(wx.EVT_BUTTON, self.
OnApply)
971 self.btnApply.SetToolTipString(_(
"Apply changes for the current session"))
972 self.btnSave.Bind(wx.EVT_BUTTON, self.
OnSave)
973 self.btnSave.SetToolTipString(_(
"Apply and save changes to user settings file (default for next sessions)"))
974 self.btnSave.SetDefault()
975 self.btnCancel.Bind(wx.EVT_BUTTON, self.
OnCancel)
976 self.btnCancel.SetToolTipString(_(
"Close dialog and ignore changes"))
985 btnSizer = wx.BoxSizer(wx.HORIZONTAL)
986 btnSizer.Add(item = self.
btnDefault, proportion = 1,
987 flag = wx.ALL, border = 5)
988 btnStdSizer = wx.StdDialogButtonSizer()
990 btnStdSizer.AddButton(self.
btnSave)
991 btnStdSizer.AddButton(self.
btnApply)
992 btnStdSizer.Realize()
994 mainSizer = wx.BoxSizer(wx.VERTICAL)
995 mainSizer.Add(item = self.
notebook, proportion = 1, flag = wx.EXPAND | wx.ALL, border = 5)
996 mainSizer.Add(item = btnSizer, proportion = 0,
997 flag = wx.EXPAND, border = 0)
998 mainSizer.Add(item = btnStdSizer, proportion = 0,
999 flag = wx.EXPAND | wx.ALL | wx.ALIGN_RIGHT, border = 5)
1001 self.SetSizer(mainSizer)
1005 """!Button 'Set to default' pressed"""
1006 self.settings.userSettings = copy.deepcopy(self.settings.defaultSettings)
1009 for gks
in self.winId.keys():
1011 group, key, subkey = gks.split(
':')
1012 value = self.settings.Get(group, key, subkey)
1014 group, key, subkey, subkey1 = gks.split(
':')
1015 value = self.settings.Get(group, key, [subkey, subkey1])
1016 win = self.FindWindowById(self.
winId[gks])
1017 if win.GetName()
in (
'GetValue',
'IsChecked'):
1018 value = win.SetValue(value)
1019 elif win.GetName() ==
'GetSelection':
1020 value = win.SetSelection(value)
1021 elif win.GetName() ==
'GetStringSelection':
1022 value = win.SetStringSelection(value)
1024 value = win.SetValue(value)
1027 """!Button 'Apply' pressed
1028 Posts event EVT_SETTINGS_CHANGED.
1031 self.parent.goutput.WriteLog(_(
'Settings applied to current session but not saved'))
1032 event = wxSettingsChanged()
1033 wx.PostEvent(self, event)
1040 """!Button 'Cancel' pressed"""
1044 """!Button 'Save' pressed
1045 Posts event EVT_SETTINGS_CHANGED.
1048 self.settings.SaveToFile()
1049 self.parent.goutput.WriteLog(_(
'Settings saved to file \'%s\'.') % self.settings.filePath)
1050 event = wxSettingsChanged()
1051 wx.PostEvent(self, event)
1054 def _updateSettings(self):
1055 """!Update user settings"""
1056 for item
in self.winId.keys():
1058 group, key, subkey = item.split(
':')
1061 group, key, subkey, subkey1 = item.split(
':')
1063 id = self.
winId[item]
1064 win = self.FindWindowById(id)
1065 if win.GetName() ==
'GetValue':
1066 value = win.GetValue()
1067 elif win.GetName() ==
'GetSelection':
1068 value = win.GetSelection()
1069 elif win.GetName() ==
'IsChecked':
1070 value = win.IsChecked()
1071 elif win.GetName() ==
'GetStringSelection':
1072 value = win.GetStringSelection()
1073 elif win.GetName() ==
'GetColour':
1074 value = tuple(win.GetValue())
1076 value = win.GetValue()
1078 if key ==
'keycolumn' and value ==
'':
1079 wx.MessageBox(parent = self,
1080 message = _(
"Key column cannot be empty string."),
1081 caption = _(
"Error"), style = wx.OK | wx.ICON_ERROR)
1082 win.SetValue(self.settings.Get(group =
'atm', key =
'keycolumn', subkey =
'value'))
1086 self.settings.Set(group, value, key, [subkey, subkey1])
1088 self.settings.Set(group, value, key, subkey)
1090 if self.parent.GetName() ==
'Modeler':
1096 if self.settings.Get(group =
'general', key =
'defWindowPos', subkey =
'enabled')
is True:
1099 pos = self.parent.GetPosition()
1100 size = self.parent.GetSize()
1101 dim =
'%d,%d,%d,%d' % (pos[0], pos[1], size[0], size[1])
1103 for page
in range(0, self.parent.gm_cb.GetPageCount()):
1104 pos = self.parent.gm_cb.GetPage(page).maptree.mapdisplay.GetPosition()
1105 size = self.parent.gm_cb.GetPage(page).maptree.mapdisplay.GetSize()
1107 dim +=
',%d,%d,%d,%d' % (pos[0], pos[1], size[0], size[1])
1109 self.settings.Set(group =
'general', key =
'defWindowPos', subkey =
'dim', value = dim)
1111 self.settings.Set(group =
'general', key =
'defWindowPos', subkey =
'dim', value =
'')
1116 """!User preferences dialog"""
1117 def __init__(self, parent, title = _(
"GUI Settings"),
1118 settings = globalSettings):
1120 PreferencesBaseDialog.__init__(self, parent = parent, title = title,
1121 settings = settings)
1131 self.SetMinSize(self.GetBestSize())
1132 self.SetSize(self.
size)
1134 def _createGeneralPage(self, notebook):
1135 """!Create notebook page for general settings"""
1136 panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
1137 notebook.AddPage(page = panel, text = _(
"General"))
1139 border = wx.BoxSizer(wx.VERTICAL)
1143 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Layer Manager settings"))
1144 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
1146 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
1147 gridSizer.AddGrowableCol(0)
1153 askOnRemoveLayer = wx.CheckBox(parent = panel, id = wx.ID_ANY,
1154 label = _(
"Ask when removing map layer from layer tree"),
1156 askOnRemoveLayer.SetValue(self.settings.Get(group =
'manager', key =
'askOnRemoveLayer', subkey =
'enabled'))
1157 self.
winId[
'manager:askOnRemoveLayer:enabled'] = askOnRemoveLayer.GetId()
1159 gridSizer.Add(item = askOnRemoveLayer,
1160 pos = (row, 0), span = (1, 2))
1163 askOnQuit = wx.CheckBox(parent = panel, id = wx.ID_ANY,
1164 label = _(
"Ask when quiting wxGUI or closing display"),
1166 askOnQuit.SetValue(self.settings.Get(group =
'manager', key =
'askOnQuit', subkey =
'enabled'))
1167 self.
winId[
'manager:askOnQuit:enabled'] = askOnQuit.GetId()
1169 gridSizer.Add(item = askOnQuit,
1170 pos = (row, 0), span = (1, 2))
1173 hideSearch = wx.CheckBox(parent = panel, id = wx.ID_ANY,
1174 label = _(
"Hide '%s' tab (requires GUI restart)") % _(
"Search module"),
1176 hideSearch.SetValue(self.settings.Get(group =
'manager', key =
'hideTabs', subkey =
'search'))
1177 self.
winId[
'manager:hideTabs:search'] = hideSearch.GetId()
1179 gridSizer.Add(item = hideSearch,
1180 pos = (row, 0), span = (1, 2))
1183 hidePyShell = wx.CheckBox(parent = panel, id = wx.ID_ANY,
1184 label = _(
"Hide '%s' tab (requires GUI restart)") % _(
"Python shell"),
1186 hidePyShell.SetValue(self.settings.Get(group =
'manager', key =
'hideTabs', subkey =
'pyshell'))
1187 self.
winId[
'manager:hideTabs:pyshell'] = hidePyShell.GetId()
1189 gridSizer.Add(item = hidePyShell,
1190 pos = (row, 0), span = (1, 2))
1196 copySelectedTextToClipboard = wx.CheckBox(parent = panel, id = wx.ID_ANY,
1197 label = _(
"Automatically copy selected text to clipboard (in Command console)"),
1199 copySelectedTextToClipboard.SetValue(self.settings.Get(group =
'manager', key =
'copySelectedTextToClipboard', subkey =
'enabled'))
1200 self.
winId[
'manager:copySelectedTextToClipboard:enabled'] = copySelectedTextToClipboard.GetId()
1202 gridSizer.Add(item = copySelectedTextToClipboard,
1203 pos = (row, 0), span = (1, 2))
1205 sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
1206 border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
1211 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Workspace settings"))
1212 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
1214 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
1215 gridSizer.AddGrowableCol(0)
1218 posDisplay = wx.CheckBox(parent = panel, id = wx.ID_ANY,
1219 label = _(
"Suppress positioning Map Display Window(s)"),
1221 posDisplay.SetValue(self.settings.Get(group =
'general', key =
'workspace',
1222 subkey = [
'posDisplay',
'enabled']))
1223 self.
winId[
'general:workspace:posDisplay:enabled'] = posDisplay.GetId()
1225 gridSizer.Add(item = posDisplay,
1226 pos = (row, 0), span = (1, 2))
1230 posManager = wx.CheckBox(parent = panel, id = wx.ID_ANY,
1231 label = _(
"Suppress positioning Layer Manager window"),
1233 posManager.SetValue(self.settings.Get(group =
'general', key =
'workspace',
1234 subkey = [
'posManager',
'enabled']))
1235 self.
winId[
'general:workspace:posManager:enabled'] = posManager.GetId()
1237 gridSizer.Add(item = posManager,
1238 pos = (row, 0), span = (1, 2))
1241 defaultPos = wx.CheckBox(parent = panel, id = wx.ID_ANY,
1242 label = _(
"Save current window layout as default"),
1244 defaultPos.SetValue(self.settings.Get(group =
'general', key =
'defWindowPos', subkey =
'enabled'))
1245 defaultPos.SetToolTip(wx.ToolTip (_(
"Save current position and size of Layer Manager window and opened "
1246 "Map Display window(s) and use as default for next sessions.")))
1247 self.
winId[
'general:defWindowPos:enabled'] = defaultPos.GetId()
1249 gridSizer.Add(item = defaultPos,
1250 pos = (row, 0), span = (1, 2))
1252 sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
1253 border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
1255 panel.SetSizer(border)
1260 panel.SetSizer(border)
1264 def _createAppearancePage(self, notebook):
1265 """!Create notebook page for display settings"""
1267 panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
1268 notebook.AddPage(page = panel, text = _(
"Appearance"))
1270 border = wx.BoxSizer(wx.VERTICAL)
1272 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Font settings"))
1273 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
1275 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
1276 gridSizer.AddGrowableCol(0)
1281 sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
1282 border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
1285 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
1286 label = _(
"Font for command output:")),
1287 flag = wx.ALIGN_LEFT |
1288 wx.ALIGN_CENTER_VERTICAL,
1290 outfontButton = wx.Button(parent = panel, id = wx.ID_ANY,
1291 label = _(
"Set font"), size = (100, -1))
1292 gridSizer.Add(item = outfontButton,
1293 flag = wx.ALIGN_RIGHT |
1294 wx.ALIGN_CENTER_VERTICAL,
1300 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Appearance settings"))
1301 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
1303 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
1304 gridSizer.AddGrowableCol(0)
1310 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
1311 label = _(
"Element list:")),
1312 flag = wx.ALIGN_LEFT |
1313 wx.ALIGN_CENTER_VERTICAL,
1315 elementList = wx.Choice(parent = panel, id = wx.ID_ANY, size = (325, -1),
1316 choices = self.settings.Get(group =
'appearance', key =
'elementListExpand',
1317 subkey =
'choices', internal =
True),
1318 name =
"GetSelection")
1319 elementList.SetSelection(self.settings.Get(group =
'appearance', key =
'elementListExpand',
1320 subkey =
'selection'))
1321 self.
winId[
'appearance:elementListExpand:selection'] = elementList.GetId()
1323 gridSizer.Add(item = elementList,
1324 flag = wx.ALIGN_RIGHT |
1325 wx.ALIGN_CENTER_VERTICAL,
1332 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
1333 label = _(
"Menu style (requires GUI restart):")),
1334 flag = wx.ALIGN_LEFT |
1335 wx.ALIGN_CENTER_VERTICAL,
1337 listOfStyles = self.settings.Get(group =
'appearance', key =
'menustyle',
1338 subkey =
'choices', internal =
True)
1340 menuItemText = wx.Choice(parent = panel, id = wx.ID_ANY, size = (325, -1),
1341 choices = listOfStyles,
1342 name =
"GetSelection")
1343 menuItemText.SetSelection(self.settings.Get(group =
'appearance', key =
'menustyle', subkey =
'selection'))
1345 self.
winId[
'appearance:menustyle:selection'] = menuItemText.GetId()
1347 gridSizer.Add(item = menuItemText,
1348 flag = wx.ALIGN_RIGHT,
1356 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
1357 label = _(
"Height of map selection popup window (in pixels):")),
1358 flag = wx.ALIGN_LEFT |
1359 wx.ALIGN_CENTER_VERTICAL,
1361 min = self.settings.Get(group =
'appearance', key =
'gSelectPopupHeight', subkey =
'min', internal =
True)
1362 max = self.settings.Get(group =
'appearance', key =
'gSelectPopupHeight', subkey =
'max', internal =
True)
1363 value = self.settings.Get(group =
'appearance', key =
'gSelectPopupHeight', subkey =
'value')
1365 popupHeightSpin = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (100, -1))
1366 popupHeightSpin.SetRange(min,max)
1367 popupHeightSpin.SetValue(value)
1369 self.
winId[
'appearance:gSelectPopupHeight:value'] = popupHeightSpin.GetId()
1371 gridSizer.Add(item = popupHeightSpin,
1372 flag = wx.ALIGN_RIGHT,
1380 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
1381 label = _(
"Icon theme (requires GUI restart):")),
1382 flag = wx.ALIGN_LEFT |
1383 wx.ALIGN_CENTER_VERTICAL,
1385 iconTheme = wx.Choice(parent = panel, id = wx.ID_ANY, size = (100, -1),
1386 choices = self.settings.Get(group =
'appearance', key =
'iconTheme',
1387 subkey =
'choices', internal =
True),
1388 name =
"GetStringSelection")
1389 iconTheme.SetStringSelection(self.settings.Get(group =
'appearance', key =
'iconTheme', subkey =
'type'))
1390 self.
winId[
'appearance:iconTheme:type'] = iconTheme.GetId()
1392 gridSizer.Add(item = iconTheme,
1393 flag = wx.ALIGN_RIGHT |
1394 wx.ALIGN_CENTER_VERTICAL,
1397 sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
1398 border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
1400 panel.SetSizer(border)
1407 def _createDisplayPage(self, notebook):
1408 """!Create notebook page for display settings"""
1410 panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
1411 notebook.AddPage(page = panel, text = _(
"Map Display"))
1413 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 = 3, vgap = 3)
1419 gridSizer.AddGrowableCol(0)
1425 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
1426 label = _(
"Default font for GRASS displays:")),
1427 flag = wx.ALIGN_LEFT |
1428 wx.ALIGN_CENTER_VERTICAL,
1430 fontButton = wx.Button(parent = panel, id = wx.ID_ANY,
1431 label = _(
"Set font"), size = (100, -1))
1432 gridSizer.Add(item = fontButton,
1433 flag = wx.ALIGN_RIGHT |
1434 wx.ALIGN_CENTER_VERTICAL,
1437 sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
1438 border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
1443 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Default display settings"))
1444 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
1446 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
1447 gridSizer.AddGrowableCol(0)
1454 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
1455 label = _(
"Display driver:")),
1456 flag = wx.ALIGN_LEFT |
1457 wx.ALIGN_CENTER_VERTICAL,
1459 listOfDrivers = self.settings.Get(group=
'display', key=
'driver', subkey=
'choices', internal=
True)
1461 if 'cairo' not in listOfDrivers:
1462 for line
in gcmd.RunCommand(
'd.mon',
1464 read =
True).splitlines():
1466 listOfDrivers.append(
'cairo')
1469 driver = wx.Choice(parent=panel, id=wx.ID_ANY, size=(150, -1),
1470 choices=listOfDrivers,
1471 name=
"GetStringSelection")
1472 driver.SetStringSelection(self.settings.Get(group=
'display', key=
'driver', subkey=
'type'))
1473 self.
winId[
'display:driver:type'] = driver.GetId()
1475 gridSizer.Add(item = driver,
1476 flag = wx.ALIGN_RIGHT,
1484 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
1485 label = _(
"Statusbar mode:")),
1486 flag = wx.ALIGN_LEFT |
1487 wx.ALIGN_CENTER_VERTICAL,
1489 listOfModes = self.settings.Get(group =
'display', key =
'statusbarMode', subkey =
'choices', internal =
True)
1490 statusbarMode = wx.Choice(parent = panel, id = wx.ID_ANY, size = (150, -1),
1491 choices = listOfModes,
1492 name =
"GetSelection")
1493 statusbarMode.SetSelection(self.settings.Get(group =
'display', key =
'statusbarMode', subkey =
'selection'))
1494 self.
winId[
'display:statusbarMode:selection'] = statusbarMode.GetId()
1496 gridSizer.Add(item = statusbarMode,
1497 flag = wx.ALIGN_RIGHT,
1504 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
1505 label = _(
"Background color:")),
1506 flag = wx.ALIGN_LEFT |
1507 wx.ALIGN_CENTER_VERTICAL,
1509 bgColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
1510 colour = self.settings.Get(group =
'display', key =
'bgcolor', subkey =
'color'),
1511 size = globalvar.DIALOG_COLOR_SIZE)
1512 bgColor.SetName(
'GetColour')
1513 self.
winId[
'display:bgcolor:color'] = bgColor.GetId()
1515 gridSizer.Add(item = bgColor,
1516 flag = wx.ALIGN_RIGHT,
1523 compResolution = wx.CheckBox(parent = panel, id = wx.ID_ANY,
1524 label = _(
"Constrain display resolution to computational settings"),
1526 compResolution.SetValue(self.settings.Get(group =
'display', key =
'compResolution', subkey =
'enabled'))
1527 self.
winId[
'display:compResolution:enabled'] = compResolution.GetId()
1529 gridSizer.Add(item = compResolution,
1530 pos = (row, 0), span = (1, 2))
1536 autoRendering = wx.CheckBox(parent = panel, id = wx.ID_ANY,
1537 label = _(
"Enable auto-rendering"),
1539 autoRendering.SetValue(self.settings.Get(group =
'display', key =
'autoRendering', subkey =
'enabled'))
1540 self.
winId[
'display:autoRendering:enabled'] = autoRendering.GetId()
1542 gridSizer.Add(item = autoRendering,
1543 pos = (row, 0), span = (1, 2))
1549 autoZooming = wx.CheckBox(parent = panel, id = wx.ID_ANY,
1550 label = _(
"Enable auto-zooming to selected map layer"),
1552 autoZooming.SetValue(self.settings.Get(group =
'display', key =
'autoZooming', subkey =
'enabled'))
1553 self.
winId[
'display:autoZooming:enabled'] = autoZooming.GetId()
1555 gridSizer.Add(item = autoZooming,
1556 pos = (row, 0), span = (1, 2))
1558 sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
1559 border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
1561 panel.SetSizer(border)
1564 fontButton.Bind(wx.EVT_BUTTON, self.
OnSetFont)
1568 def _createCmdPage(self, notebook):
1569 """!Create notebook page for commad dialog settings"""
1570 panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
1571 notebook.AddPage(page = panel, text = _(
"Command"))
1573 border = wx.BoxSizer(wx.VERTICAL)
1574 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Command dialog settings"))
1575 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
1577 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
1578 gridSizer.AddGrowableCol(0)
1585 overwrite = wx.CheckBox(parent = panel, id = wx.ID_ANY,
1586 label = _(
"Allow output files to overwrite existing files"),
1588 overwrite.SetValue(self.settings.Get(group =
'cmd', key =
'overwrite', subkey =
'enabled'))
1589 self.
winId[
'cmd:overwrite:enabled'] = overwrite.GetId()
1591 gridSizer.Add(item = overwrite,
1592 pos = (row, 0), span = (1, 2))
1595 close = wx.CheckBox(parent = panel, id = wx.ID_ANY,
1596 label = _(
"Close dialog when command is successfully finished"),
1598 close.SetValue(self.settings.Get(group =
'cmd', key =
'closeDlg', subkey =
'enabled'))
1599 self.
winId[
'cmd:closeDlg:enabled'] = close.GetId()
1601 gridSizer.Add(item = close,
1602 pos = (row, 0), span = (1, 2))
1605 add = wx.CheckBox(parent = panel, id = wx.ID_ANY,
1606 label = _(
"Add created map into layer tree"),
1608 add.SetValue(self.settings.Get(group =
'cmd', key =
'addNewLayer', subkey =
'enabled'))
1609 self.
winId[
'cmd:addNewLayer:enabled'] = add.GetId()
1611 gridSizer.Add(item = add,
1612 pos = (row, 0), span = (1, 2))
1616 interactive = wx.CheckBox(parent = panel, id = wx.ID_ANY,
1617 label = _(
"Allow interactive input"),
1619 interactive.SetValue(self.settings.Get(group =
'cmd', key =
'interactiveInput', subkey =
'enabled'))
1620 self.
winId[
'cmd:interactiveInput:enabled'] = interactive.GetId()
1621 gridSizer.Add(item = interactive,
1622 pos = (row, 0), span = (1, 2))
1626 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
1627 label = _(
"Verbosity level:")),
1628 flag = wx.ALIGN_LEFT |
1629 wx.ALIGN_CENTER_VERTICAL,
1631 verbosity = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
1632 choices = self.settings.Get(group =
'cmd', key =
'verbosity', subkey =
'choices', internal =
True),
1633 name =
"GetStringSelection")
1634 verbosity.SetStringSelection(self.settings.Get(group =
'cmd', key =
'verbosity', subkey =
'selection'))
1635 self.
winId[
'cmd:verbosity:selection'] = verbosity.GetId()
1637 gridSizer.Add(item = verbosity,
1640 sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
1641 border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
1646 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Raster settings"))
1647 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
1649 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
1650 gridSizer.AddGrowableCol(0)
1656 rasterOverlay = wx.CheckBox(parent=panel, id=wx.ID_ANY,
1657 label=_(
"Overlay raster maps"),
1659 rasterOverlay.SetValue(self.settings.Get(group=
'cmd', key=
'rasterOverlay', subkey=
'enabled'))
1660 self.
winId[
'cmd:rasterOverlay:enabled'] = rasterOverlay.GetId()
1662 gridSizer.Add(item=rasterOverlay,
1663 pos=(row, 0), span=(1, 2))
1667 rasterCTCheck = wx.CheckBox(parent = panel, id = wx.ID_ANY,
1668 label = _(
"Default color table"),
1670 rasterCTCheck.SetValue(self.settings.Get(group =
'cmd', key =
'rasterColorTable', subkey =
'enabled'))
1671 self.
winId[
'cmd:rasterColorTable:enabled'] = rasterCTCheck.GetId()
1674 gridSizer.Add(item = rasterCTCheck,
1677 rasterCTName = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
1678 choices = utils.GetColorTables(),
1679 name =
"GetStringSelection")
1680 rasterCTName.SetStringSelection(self.settings.Get(group =
'cmd', key =
'rasterColorTable', subkey =
'selection'))
1681 self.
winId[
'cmd:rasterColorTable:selection'] = rasterCTName.GetId()
1682 if not rasterCTCheck.IsChecked():
1683 rasterCTName.Enable(
False)
1685 gridSizer.Add(item = rasterCTName,
1688 sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
1689 border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
1694 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Vector settings"))
1695 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
1697 gridSizer = wx.FlexGridSizer (cols = 7, hgap = 3, vgap = 3)
1699 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
1700 label = _(
"Display:")),
1701 flag = wx.ALIGN_CENTER_VERTICAL)
1703 for type
in (
'point',
'line',
'centroid',
'boundary',
1705 chkbox = wx.CheckBox(parent = panel, label = type)
1706 checked = self.settings.Get(group =
'cmd', key =
'showType',
1707 subkey = [type,
'enabled'])
1708 chkbox.SetValue(checked)
1709 self.
winId[
'cmd:showType:%s:enabled' % type] = chkbox.GetId()
1710 gridSizer.Add(item = chkbox)
1712 sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
1713 border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
1715 panel.SetSizer(border)
1719 def _createAttributeManagerPage(self, notebook):
1720 """!Create notebook page for 'Attribute Table Manager' settings"""
1721 panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
1722 notebook.AddPage(page = panel, text = _(
"Attributes"))
1724 pageSizer = wx.BoxSizer(wx.VERTICAL)
1729 highlightBox = wx.StaticBox(parent = panel, id = wx.ID_ANY,
1730 label =
" %s " % _(
"Highlighting"))
1731 highlightSizer = wx.StaticBoxSizer(highlightBox, wx.VERTICAL)
1733 flexSizer = wx.FlexGridSizer (cols = 2, hgap = 5, vgap = 5)
1734 flexSizer.AddGrowableCol(0)
1736 label = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _(
"Color:"))
1737 hlColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
1738 colour = self.settings.Get(group =
'atm', key =
'highlight', subkey =
'color'),
1739 size = globalvar.DIALOG_COLOR_SIZE)
1740 hlColor.SetName(
'GetColour')
1741 self.
winId[
'atm:highlight:color'] = hlColor.GetId()
1743 flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
1744 flexSizer.Add(hlColor, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
1746 label = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _(
"Line width (in pixels):"))
1747 hlWidth = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (50, -1),
1748 initial = self.settings.Get(group =
'atm', key =
'highlight',subkey =
'width'),
1750 self.
winId[
'atm:highlight:width'] = hlWidth.GetId()
1752 flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
1753 flexSizer.Add(hlWidth, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
1755 highlightSizer.Add(item = flexSizer,
1757 flag = wx.ALL | wx.EXPAND,
1760 pageSizer.Add(item = highlightSizer,
1762 flag = wx.ALL | wx.EXPAND,
1768 dataBrowserBox = wx.StaticBox(parent = panel, id = wx.ID_ANY,
1769 label =
" %s " % _(
"Data browser"))
1770 dataBrowserSizer = wx.StaticBoxSizer(dataBrowserBox, wx.VERTICAL)
1772 flexSizer = wx.FlexGridSizer (cols = 2, hgap = 5, vgap = 5)
1773 flexSizer.AddGrowableCol(0)
1774 label = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _(
"Left mouse double click:"))
1775 leftDbClick = wx.Choice(parent = panel, id = wx.ID_ANY,
1776 choices = self.settings.Get(group =
'atm', key =
'leftDbClick', subkey =
'choices', internal =
True),
1777 name =
"GetSelection")
1778 leftDbClick.SetSelection(self.settings.Get(group =
'atm', key =
'leftDbClick', subkey =
'selection'))
1779 self.
winId[
'atm:leftDbClick:selection'] = leftDbClick.GetId()
1781 flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
1782 flexSizer.Add(leftDbClick, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
1785 label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1786 label = _(
"Encoding (e.g. utf-8, ascii, iso8859-1, koi8-r):"))
1787 encoding = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
1788 value = self.settings.Get(group =
'atm', key =
'encoding', subkey =
'value'),
1789 name =
"GetValue", size = (200, -1))
1790 self.
winId[
'atm:encoding:value'] = encoding.GetId()
1792 flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
1793 flexSizer.Add(encoding, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
1796 askOnDeleteRec = wx.CheckBox(parent = panel, id = wx.ID_ANY,
1797 label = _(
"Ask when deleting data record(s) from table"),
1799 askOnDeleteRec.SetValue(self.settings.Get(group =
'atm', key =
'askOnDeleteRec', subkey =
'enabled'))
1800 self.
winId[
'atm:askOnDeleteRec:enabled'] = askOnDeleteRec.GetId()
1802 flexSizer.Add(askOnDeleteRec, proportion = 0)
1804 dataBrowserSizer.Add(item = flexSizer,
1806 flag = wx.ALL | wx.EXPAND,
1809 pageSizer.Add(item = dataBrowserSizer,
1811 flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND,
1817 createTableBox = wx.StaticBox(parent = panel, id = wx.ID_ANY,
1818 label =
" %s " % _(
"Create table"))
1819 createTableSizer = wx.StaticBoxSizer(createTableBox, wx.VERTICAL)
1821 flexSizer = wx.FlexGridSizer (cols = 2, hgap = 5, vgap = 5)
1822 flexSizer.AddGrowableCol(0)
1824 label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1825 label = _(
"Key column:"))
1826 keyColumn = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
1828 keyColumn.SetValue(self.settings.Get(group =
'atm', key =
'keycolumn', subkey =
'value'))
1829 self.
winId[
'atm:keycolumn:value'] = keyColumn.GetId()
1831 flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
1832 flexSizer.Add(keyColumn, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
1834 createTableSizer.Add(item = flexSizer,
1836 flag = wx.ALL | wx.EXPAND,
1839 pageSizer.Add(item = createTableSizer,
1841 flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND,
1844 panel.SetSizer(pageSizer)
1848 def _createProjectionPage(self, notebook):
1849 """!Create notebook page for workspace settings"""
1850 panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
1851 notebook.AddPage(page = panel, text = _(
"Projection"))
1853 border = wx.BoxSizer(wx.VERTICAL)
1858 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Projection statusbar settings"))
1859 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
1861 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
1862 gridSizer.AddGrowableCol(1)
1866 label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1867 label = _(
"EPSG code:"))
1868 epsgCode = wx.ComboBox(parent = panel, id = wx.ID_ANY,
1872 epsgCode.SetValue(str(self.settings.Get(group =
'projection', key =
'statusbar', subkey =
'epsg')))
1873 self.
winId[
'projection:statusbar:epsg'] = epsgCode.GetId()
1875 gridSizer.Add(item = label,
1877 flag = wx.ALIGN_CENTER_VERTICAL)
1878 gridSizer.Add(item = epsgCode,
1879 pos = (row, 1), span = (1, 2))
1883 label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1884 label = _(
"Proj.4 string (required):"))
1885 projString = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
1886 value = self.settings.Get(group =
'projection', key =
'statusbar', subkey =
'proj4'),
1887 name =
"GetValue", size = (400, -1))
1888 self.
winId[
'projection:statusbar:proj4'] = projString.GetId()
1890 gridSizer.Add(item = label,
1892 flag = wx.ALIGN_CENTER_VERTICAL)
1893 gridSizer.Add(item = projString,
1894 pos = (row, 1), span = (1, 2),
1895 flag = wx.ALIGN_CENTER_VERTICAL)
1899 label = wx.StaticText(parent = panel, id = wx.ID_ANY,
1900 label = _(
"EPSG file:"))
1901 projFile = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
1902 value = self.settings.Get(group =
'projection', key =
'statusbar', subkey =
'projFile'),
1903 name =
"GetValue", size = (400, -1))
1904 self.
winId[
'projection:statusbar:projFile'] = projFile.GetId()
1905 gridSizer.Add(item = label,
1907 flag = wx.ALIGN_CENTER_VERTICAL)
1908 gridSizer.Add(item = projFile,
1910 flag = wx.ALIGN_CENTER_VERTICAL)
1914 note = wx.StaticText(parent = panel, id = wx.ID_ANY,
1915 label = _(
"Load EPSG codes (be patient), enter EPSG code or "
1916 "insert Proj.4 string directly."))
1917 gridSizer.Add(item = note,
1922 epsgLoad = wx.Button(parent = panel, id = wx.ID_ANY,
1923 label = _(
"&Load EPSG codes"))
1924 gridSizer.Add(item = epsgLoad,
1925 flag = wx.ALIGN_RIGHT,
1928 sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
1929 border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
1934 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Coordinates format"))
1935 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
1937 gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
1938 gridSizer.AddGrowableCol(2)
1942 ll = wx.RadioBox(parent = panel, id = wx.ID_ANY,
1943 label =
" %s " % _(
"LL projections"),
1944 choices = [
"DMS",
"DEG"],
1945 name =
"GetStringSelection")
1946 self.
winId[
'projection:format:ll'] = ll.GetId()
1947 if self.settings.Get(group =
'projection', key =
'format', subkey =
'll') ==
'DMS':
1953 precision = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
1956 precision.SetValue(int(self.settings.Get(group =
'projection', key =
'format', subkey =
'precision')))
1957 self.
winId[
'projection:format:precision'] = precision.GetId()
1959 gridSizer.Add(item = ll,
1961 gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
1962 label = _(
"Precision:")),
1963 flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.LEFT,
1966 gridSizer.Add(item = precision,
1967 flag = wx.ALIGN_CENTER_VERTICAL,
1971 sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
1972 border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
1974 panel.SetSizer(border)
1984 """!Set/unset default color table"""
1985 win = self.FindWindowById(self.
winId[
'cmd:rasterColorTable:selection'])
1986 if event.IsChecked():
1992 """!Load EPSG codes from the file"""
1993 win = self.FindWindowById(self.
winId[
'projection:statusbar:projFile'])
1994 path = win.GetValue()
1997 list = self.FindWindowById(self.
winId[
'projection:statusbar:epsg'])
1999 wx.MessageBox(parent = self,
2000 message = _(
"Unable to read EPSG codes: %s") % self.
epsgCodeDict,
2001 caption = _(
"Error"), style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
2005 self.FindWindowById(self.
winId[
'projection:statusbar:proj4']).SetValue(
'')
2008 choices =
map(str, self.epsgCodeDict.keys())
2010 list.SetItems(choices)
2012 code = int(list.GetValue())
2015 win = self.FindWindowById(self.
winId[
'projection:statusbar:proj4'])
2019 list.SetSelection(0)
2020 code = int(list.GetStringSelection())
2024 """!EPSG code selected"""
2025 winCode = self.FindWindowById(event.GetId())
2026 win = self.FindWindowById(self.
winId[
'projection:statusbar:proj4'])
2028 wx.MessageBox(parent = self,
2029 message = _(
"EPSG code %s not found") % event.GetString(),
2030 caption = _(
"Error"), style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
2031 winCode.SetValue(
'')
2035 code = int(event.GetString())
2037 wx.MessageBox(parent = self,
2038 message = _(
"EPSG code %s not found") % str(code),
2039 caption = _(
"Error"), style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
2040 winCode.SetValue(
'')
2045 win.SetValue(self.
epsgCodeDict[code][1].replace(
'<>',
'').strip())
2047 wx.MessageBox(parent = self,
2048 message = _(
"EPSG code %s not found") % str(code),
2049 caption = _(
"Error"), style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
2050 winCode.SetValue(
'')
2054 """'Set font' button pressed"""
2056 title = _(
'Select default display font'),
2057 style = wx.DEFAULT_DIALOG_STYLE,
2060 if dlg.ShowModal() == wx.ID_OK:
2063 os.environ[
"GRASS_FONT"] = dlg.font
2064 self.settings.Set(group =
'display', value = dlg.font,
2065 key =
'font', subkey =
'type')
2067 if dlg.encoding
and \
2068 dlg.encoding !=
"ISO-8859-1":
2069 os.environ[
"GRASS_ENCODING"] = dlg.encoding
2070 self.settings.Set(group =
'display', value = dlg.encoding,
2071 key =
'font', subkey =
'encoding')
2078 """'Set output font' button pressed
2081 title = _(
'Select output font'),
2082 style = wx.DEFAULT_DIALOG_STYLE,
2083 type =
'outputfont')
2085 if dlg.ShowModal() == wx.ID_OK:
2088 self.settings.Set(group =
'appearance', value = dlg.font,
2089 key =
'outputfont', subkey =
'type')
2091 self.settings.Set(group =
'appearance', value = dlg.fontsize,
2092 key =
'outputfont', subkey =
'size')
2122 Opens a file selection dialog to select default font
2123 to use in all GRASS displays
2125 def __init__(self, parent, title, id = wx.ID_ANY,
2126 style = wx.DEFAULT_DIALOG_STYLE |
2128 settings = globalSettings,
2134 wx.Dialog.__init__(self, parent, id, title, style = style)
2136 panel = wx.Panel(parent = self, id = wx.ID_ANY)
2140 border = wx.BoxSizer(wx.VERTICAL)
2141 box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label =
" %s " % _(
"Font settings"))
2142 sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
2144 gridSizer = wx.GridBagSizer (hgap = 5, vgap = 5)
2145 gridSizer.AddGrowableCol(0)
2147 label = wx.StaticText(parent = panel, id = wx.ID_ANY,
2148 label = _(
"Select font:"))
2149 gridSizer.Add(item = label,
2150 flag = wx.ALIGN_TOP,
2153 self.
fontlb = wx.ListBox(parent = panel, id = wx.ID_ANY, pos = wx.DefaultPosition,
2155 style = wx.LB_SINGLE|wx.LB_SORT)
2159 gridSizer.Add(item = self.
fontlb,
2160 flag = wx.EXPAND, pos = (1, 0))
2162 if self.
type ==
'font':
2163 if "GRASS_FONT" in os.environ:
2164 self.
font = os.environ[
"GRASS_FONT"]
2166 self.
font = self.settings.Get(group =
'display',
2167 key =
'font', subkey =
'type')
2169 key =
'font', subkey =
'encoding')
2171 label = wx.StaticText(parent = panel, id = wx.ID_ANY,
2172 label = _(
"Character encoding:"))
2173 gridSizer.Add(item = label,
2174 flag = wx.ALIGN_CENTER_VERTICAL,
2177 self.
textentry = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
2180 flag = wx.EXPAND, pos = (3, 0))
2182 self.textentry.Bind(wx.EVT_TEXT, self.
OnEncoding)
2184 elif self.
type ==
'outputfont':
2185 self.
font = self.settings.Get(group =
'appearance',
2186 key =
'outputfont', subkey =
'type')
2187 self.
fontsize = self.settings.Get(group =
'appearance',
2188 key =
'outputfont', subkey =
'size')
2189 label = wx.StaticText(parent = panel, id = wx.ID_ANY,
2190 label = _(
"Font size:"))
2191 gridSizer.Add(item = label,
2192 flag = wx.ALIGN_CENTER_VERTICAL,
2195 self.
spin = wx.SpinCtrl(parent = panel, id = wx.ID_ANY)
2197 self.spin.SetValue(int(self.
fontsize))
2198 self.spin.Bind(wx.EVT_SPINCTRL, self.
OnSizeSpin)
2200 gridSizer.Add(item = self.
spin,
2201 flag = wx.ALIGN_CENTER_VERTICAL,
2208 self.fontlb.SetStringSelection(self.
font,
True)
2210 sizer.Add(item = gridSizer, proportion = 1,
2211 flag = wx.EXPAND | wx.ALL,
2214 border.Add(item = sizer, proportion = 1,
2215 flag = wx.ALL | wx.EXPAND, border = 3)
2217 btnsizer = wx.StdDialogButtonSizer()
2219 btn = wx.Button(parent = panel, id = wx.ID_OK)
2221 btnsizer.AddButton(btn)
2223 btn = wx.Button(parent = panel, id = wx.ID_CANCEL)
2224 btnsizer.AddButton(btn)
2227 border.Add(item = btnsizer, proportion = 0,
2228 flag = wx.EXPAND | wx.ALIGN_RIGHT | wx.ALL, border = 5)
2230 panel.SetAutoLayout(
True)
2231 panel.SetSizer(border)
2237 if event.GetInt() == 0:
2239 elif event.GetInt() == 1:
2243 self.fontlb.SetItems(self.
fontlist)
2249 self.
font = event.GetString()
2253 self.
font = event.GetString()
2257 self.
fontsize = self.spin.GetValue()
2262 parses fonts directory or fretypecap file to get a list of fonts for the listbox
2266 cmd = [
"d.font",
"-l"]
2268 ret = gcmd.RunCommand(
'd.font',
2275 dfonts = ret.splitlines()
2276 dfonts.sort(
lambda x,y: cmp(x.lower(), y.lower()))
2277 for item
in range(len(dfonts)):
2279 if not dfonts[item].startswith(
'#')
and \
2280 dfonts[item] != dfonts[item-1]:
2281 fontlist.append(dfonts[item])
2286 """!Controls setting options and displaying/hiding map overlay
2289 def __init__(self, parent, id = wx.ID_ANY,
2290 title = _(
'Manage access to mapsets'),
2292 style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, **kwargs):
2294 wx.Dialog.__init__(self, parent, id, title, size = size, style = style, **kwargs)
2301 sizer = wx.BoxSizer(wx.VERTICAL)
2303 label = wx.StaticText(parent = self, id = wx.ID_ANY,
2304 label = _(
"Check a mapset to make it accessible, uncheck it to hide it.\n"
2306 " - The current mapset is always accessible.\n"
2307 " - You may only write to the current mapset.\n"
2308 " - You may only write to mapsets which you own."))
2310 sizer.Add(item = label, proportion = 0,
2311 flag = wx.ALL, border = 5)
2314 self.mapsetlb.LoadData()
2316 sizer.Add(item = self.
mapsetlb, proportion = 1,
2317 flag = wx.ALL | wx.EXPAND, border = 5)
2321 self.mapsetlb.CheckItem(self.all_mapsets_ordered.index(mset),
True)
2327 line = wx.StaticLine(parent = self, id = wx.ID_ANY,
2328 style = wx.LI_HORIZONTAL)
2329 sizer.Add(item = line, proportion = 0,
2330 flag = wx.EXPAND | wx.ALIGN_CENTRE | wx.ALL, border = 5)
2332 btnsizer = wx.StdDialogButtonSizer()
2333 okbtn = wx.Button(self, wx.ID_OK)
2335 btnsizer.AddButton(okbtn)
2337 cancelbtn = wx.Button(self, wx.ID_CANCEL)
2338 btnsizer.AddButton(cancelbtn)
2341 sizer.Add(item = btnsizer, proportion = 0,
2342 flag = wx.EXPAND | wx.ALIGN_RIGHT | wx.ALL, border = 5)
2346 self.SetSizer(sizer)
2349 self.SetMinSize(size)
2352 """!Get list of checked mapsets"""
2356 if self.mapsetlb.IsChecked(i):
2362 class CheckListMapset(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.CheckListCtrlMixin):
2363 """!List of mapset/owner/group"""
2364 def __init__(self, parent, pos = wx.DefaultPosition,
2368 wx.ListCtrl.__init__(self, parent, wx.ID_ANY,
2369 style = wx.LC_REPORT)
2370 listmix.CheckListCtrlMixin.__init__(self)
2374 listmix.ListCtrlAutoWidthMixin.__init__(self)
2377 """!Load data into list"""
2378 self.InsertColumn(0, _(
'Mapset'))
2379 self.InsertColumn(1, _(
'Owner'))
2381 gisenv = grass.gisenv()
2382 locationPath = os.path.join(gisenv[
'GISDBASE'], gisenv[
'LOCATION_NAME'])
2384 for mapset
in self.parent.all_mapsets_ordered:
2385 index = self.InsertStringItem(sys.maxint, mapset)
2386 mapsetPath = os.path.join(locationPath,
2388 stat_info = os.stat(mapsetPath)
2390 self.SetStringItem(index, 1,
"%s" % pwd.getpwuid(stat_info.st_uid)[0])
2395 self.SetStringItem(index, 1,
"%-8s" % stat_info.st_uid)
2398 self.SetColumnWidth(col = 0, width = wx.LIST_AUTOSIZE)
2402 """!Mapset checked/unchecked"""
2403 mapset = self.parent.all_mapsets_ordered[index]
2404 if mapset == self.parent.curr_mapset:
2405 self.CheckItem(index,
True)