preferences.py 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561
  1. """!
  2. @package gui_core.preferences
  3. @brief User preferences dialog
  4. Sets default display font, etc. If you want to add some value to
  5. settings you have to add default value to defaultSettings and set
  6. constraints in internalSettings in Settings class. Everything can be
  7. used in PreferencesDialog.
  8. Classes:
  9. - preferences::PreferencesBaseDialog
  10. - preferences::PreferencesDialog
  11. - preferences::DefaultFontDialog
  12. - preferences::MapsetAccess
  13. - preferences::CheckListMapset
  14. (C) 2007-2011 by the GRASS Development Team
  15. This program is free software under the GNU General Public License
  16. (>=v2). Read the file COPYING that comes with GRASS for details.
  17. @author Michael Barton (Arizona State University)
  18. @author Martin Landa <landa.martin gmail.com>
  19. @author Vaclav Petras <wenzeslaus gmail.com> (menu customization)
  20. @author Luca Delucchi <lucadeluge gmail.com> (language choice)
  21. """
  22. import os
  23. import sys
  24. import copy
  25. import locale
  26. try:
  27. import pwd
  28. havePwd = True
  29. except ImportError:
  30. havePwd = False
  31. import wx
  32. import wx.lib.colourselect as csel
  33. import wx.lib.mixins.listctrl as listmix
  34. from wx.lib.newevent import NewEvent
  35. from grass.script import core as grass
  36. from core import globalvar
  37. from core.gcmd import RunCommand
  38. from core.utils import ListOfMapsets, GetColorTables, ReadEpsgCodes, GetSettingsPath
  39. from core.settings import UserSettings
  40. wxSettingsChanged, EVT_SETTINGS_CHANGED = NewEvent()
  41. class PreferencesBaseDialog(wx.Dialog):
  42. """!Base preferences dialog"""
  43. def __init__(self, parent, settings, title = _("User settings"),
  44. size = (500, 375),
  45. style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
  46. self.parent = parent # ModelerFrame
  47. self.title = title
  48. self.size = size
  49. self.settings = settings
  50. wx.Dialog.__init__(self, parent = parent, id = wx.ID_ANY, title = title,
  51. style = style)
  52. # notebook
  53. self.notebook = wx.Notebook(parent = self, id = wx.ID_ANY, style = wx.BK_DEFAULT)
  54. # dict for window ids
  55. self.winId = {}
  56. # create notebook pages
  57. # buttons
  58. self.btnDefault = wx.Button(self, wx.ID_ANY, _("Set to default"))
  59. self.btnSave = wx.Button(self, wx.ID_SAVE)
  60. self.btnApply = wx.Button(self, wx.ID_APPLY)
  61. self.btnCancel = wx.Button(self, wx.ID_CANCEL)
  62. self.btnSave.SetDefault()
  63. # bindigs
  64. self.btnDefault.Bind(wx.EVT_BUTTON, self.OnDefault)
  65. self.btnDefault.SetToolTipString(_("Revert settings to default and apply changes"))
  66. self.btnApply.Bind(wx.EVT_BUTTON, self.OnApply)
  67. self.btnApply.SetToolTipString(_("Apply changes for the current session"))
  68. self.btnSave.Bind(wx.EVT_BUTTON, self.OnSave)
  69. self.btnSave.SetToolTipString(_("Apply and save changes to user settings file (default for next sessions)"))
  70. self.btnSave.SetDefault()
  71. self.btnCancel.Bind(wx.EVT_BUTTON, self.OnCancel)
  72. self.btnCancel.SetToolTipString(_("Close dialog and ignore changes"))
  73. self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
  74. self._layout()
  75. def _layout(self):
  76. """!Layout window"""
  77. # sizers
  78. btnSizer = wx.BoxSizer(wx.HORIZONTAL)
  79. btnSizer.Add(item = self.btnDefault, proportion = 1,
  80. flag = wx.ALL, border = 5)
  81. btnStdSizer = wx.StdDialogButtonSizer()
  82. btnStdSizer.AddButton(self.btnCancel)
  83. btnStdSizer.AddButton(self.btnSave)
  84. btnStdSizer.AddButton(self.btnApply)
  85. btnStdSizer.Realize()
  86. mainSizer = wx.BoxSizer(wx.VERTICAL)
  87. mainSizer.Add(item = self.notebook, proportion = 1, flag = wx.EXPAND | wx.ALL, border = 5)
  88. mainSizer.Add(item = btnSizer, proportion = 0,
  89. flag = wx.EXPAND, border = 0)
  90. mainSizer.Add(item = btnStdSizer, proportion = 0,
  91. flag = wx.EXPAND | wx.ALL | wx.ALIGN_RIGHT, border = 5)
  92. self.SetSizer(mainSizer)
  93. mainSizer.Fit(self)
  94. def OnDefault(self, event):
  95. """!Button 'Set to default' pressed"""
  96. self.settings.userSettings = copy.deepcopy(self.settings.defaultSettings)
  97. # update widgets
  98. for gks in self.winId.keys():
  99. try:
  100. group, key, subkey = gks.split(':')
  101. value = self.settings.Get(group, key, subkey)
  102. except ValueError:
  103. group, key, subkey, subkey1 = gks.split(':')
  104. value = self.settings.Get(group, key, [subkey, subkey1])
  105. win = self.FindWindowById(self.winId[gks])
  106. if win.GetName() in ('GetValue', 'IsChecked'):
  107. value = win.SetValue(value)
  108. elif win.GetName() == 'GetSelection':
  109. value = win.SetSelection(value)
  110. elif win.GetName() == 'GetStringSelection':
  111. value = win.SetStringSelection(value)
  112. else:
  113. value = win.SetValue(value)
  114. def OnApply(self, event):
  115. """!Button 'Apply' pressed
  116. Posts event EVT_SETTINGS_CHANGED.
  117. """
  118. if self._updateSettings():
  119. self.parent.goutput.WriteLog(_('Settings applied to current session but not saved'))
  120. event = wxSettingsChanged()
  121. wx.PostEvent(self, event)
  122. self.Close()
  123. def OnCloseWindow(self, event):
  124. self.Hide()
  125. def OnCancel(self, event):
  126. """!Button 'Cancel' pressed"""
  127. self.Close()
  128. def OnSave(self, event):
  129. """!Button 'Save' pressed
  130. Posts event EVT_SETTINGS_CHANGED.
  131. """
  132. if self._updateSettings():
  133. self.settings.SaveToFile()
  134. self.parent.goutput.WriteLog(_('Settings saved to file \'%s\'.') % self.settings.filePath)
  135. fileSettings = {}
  136. self.settings.ReadSettingsFile(settings = fileSettings)
  137. id_loc = fileSettings['language']['locale']['lc_all']
  138. rcfile = open(os.path.join(GetSettingsPath(), 'bashrc'),"r")
  139. rclines = rcfile.readlines()
  140. rcfile.close()
  141. rcfile = open(os.path.join(GetSettingsPath(), 'bashrc'),"w")
  142. grasslang = False
  143. for line in rclines:
  144. if 'GRASS_LANG' in line:
  145. rcfile.write('GRASS_LANG: %s\n' % self.locales[id_loc])
  146. grasslang = True
  147. else:
  148. rcfile.write('%s' % line)
  149. if not grasslang:
  150. rcfile.write('GRASS_LANG: %s\n' % self.locales[id_loc])
  151. rcfile.close()
  152. event = wxSettingsChanged()
  153. wx.PostEvent(self, event)
  154. self.Close()
  155. def _updateSettings(self):
  156. """!Update user settings"""
  157. for item in self.winId.keys():
  158. try:
  159. group, key, subkey = item.split(':')
  160. subkey1 = None
  161. except ValueError:
  162. group, key, subkey, subkey1 = item.split(':')
  163. id = self.winId[item]
  164. win = self.FindWindowById(id)
  165. if win.GetName() == 'GetValue':
  166. value = win.GetValue()
  167. elif win.GetName() == 'GetSelection':
  168. value = win.GetSelection()
  169. elif win.GetName() == 'IsChecked':
  170. value = win.IsChecked()
  171. elif win.GetName() == 'GetStringSelection':
  172. value = win.GetStringSelection()
  173. elif win.GetName() == 'GetColour':
  174. value = tuple(win.GetValue())
  175. else:
  176. value = win.GetValue()
  177. if key == 'keycolumn' and value == '':
  178. wx.MessageBox(parent = self,
  179. message = _("Key column cannot be empty string."),
  180. caption = _("Error"), style = wx.OK | wx.ICON_ERROR)
  181. win.SetValue(self.settings.Get(group = 'atm', key = 'keycolumn', subkey = 'value'))
  182. return False
  183. if subkey1:
  184. self.settings.Set(group, value, key, [subkey, subkey1])
  185. else:
  186. self.settings.Set(group, value, key, subkey)
  187. if self.parent.GetName() == 'Modeler':
  188. return True
  189. #
  190. # update default window dimension
  191. #
  192. if self.settings.Get(group = 'general', key = 'defWindowPos', subkey = 'enabled') is True:
  193. dim = ''
  194. # layer manager
  195. pos = self.parent.GetPosition()
  196. size = self.parent.GetSize()
  197. dim = '%d,%d,%d,%d' % (pos[0], pos[1], size[0], size[1])
  198. # opened displays
  199. for page in range(0, self.parent.gm_cb.GetPageCount()):
  200. pos = self.parent.gm_cb.GetPage(page).maptree.mapdisplay.GetPosition()
  201. size = self.parent.gm_cb.GetPage(page).maptree.mapdisplay.GetSize()
  202. dim += ',%d,%d,%d,%d' % (pos[0], pos[1], size[0], size[1])
  203. self.settings.Set(group = 'general', key = 'defWindowPos', subkey = 'dim', value = dim)
  204. else:
  205. self.settings.Set(group = 'general', key = 'defWindowPos', subkey = 'dim', value = '')
  206. return True
  207. class PreferencesDialog(PreferencesBaseDialog):
  208. """!User preferences dialog"""
  209. def __init__(self, parent, title = _("GUI Settings"),
  210. settings = UserSettings):
  211. PreferencesBaseDialog.__init__(self, parent = parent, title = title,
  212. settings = settings)
  213. # create notebook pages
  214. self._createGeneralPage(self.notebook)
  215. self._createAppearancePage(self.notebook)
  216. self._createDisplayPage(self.notebook)
  217. self._createCmdPage(self.notebook)
  218. self._createAttributeManagerPage(self.notebook)
  219. self._createProjectionPage(self.notebook)
  220. self.SetMinSize(self.GetBestSize())
  221. self.SetSize(self.size)
  222. def _createGeneralPage(self, notebook):
  223. """!Create notebook page for general settings"""
  224. panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
  225. notebook.AddPage(page = panel, text = _("General"))
  226. border = wx.BoxSizer(wx.VERTICAL)
  227. #
  228. # Layer Manager settings
  229. #
  230. box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Layer Manager settings"))
  231. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  232. gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
  233. gridSizer.AddGrowableCol(0)
  234. #
  235. # ask when removing map layer from layer tree
  236. #
  237. row = 0
  238. askOnRemoveLayer = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  239. label = _("Ask when removing map layer from layer tree"),
  240. name = 'IsChecked')
  241. askOnRemoveLayer.SetValue(self.settings.Get(group = 'manager', key = 'askOnRemoveLayer', subkey = 'enabled'))
  242. self.winId['manager:askOnRemoveLayer:enabled'] = askOnRemoveLayer.GetId()
  243. gridSizer.Add(item = askOnRemoveLayer,
  244. pos = (row, 0), span = (1, 2))
  245. row += 1
  246. askOnQuit = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  247. label = _("Ask when quiting wxGUI or closing display"),
  248. name = 'IsChecked')
  249. askOnQuit.SetValue(self.settings.Get(group = 'manager', key = 'askOnQuit', subkey = 'enabled'))
  250. self.winId['manager:askOnQuit:enabled'] = askOnQuit.GetId()
  251. gridSizer.Add(item = askOnQuit,
  252. pos = (row, 0), span = (1, 2))
  253. row += 1
  254. hideSearch = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  255. label = _("Hide '%s' tab (requires GUI restart)") % _("Search module"),
  256. name = 'IsChecked')
  257. hideSearch.SetValue(self.settings.Get(group = 'manager', key = 'hideTabs', subkey = 'search'))
  258. self.winId['manager:hideTabs:search'] = hideSearch.GetId()
  259. gridSizer.Add(item = hideSearch,
  260. pos = (row, 0), span = (1, 2))
  261. row += 1
  262. hidePyShell = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  263. label = _("Hide '%s' tab (requires GUI restart)") % _("Python shell"),
  264. name = 'IsChecked')
  265. hidePyShell.SetValue(self.settings.Get(group = 'manager', key = 'hideTabs', subkey = 'pyshell'))
  266. self.winId['manager:hideTabs:pyshell'] = hidePyShell.GetId()
  267. gridSizer.Add(item = hidePyShell,
  268. pos = (row, 0), span = (1, 2))
  269. #
  270. # Selected text is copied to clipboard
  271. #
  272. row += 1
  273. copySelectedTextToClipboard = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  274. label = _("Automatically copy selected text to clipboard (in Command console)"),
  275. name = 'IsChecked')
  276. copySelectedTextToClipboard.SetValue(self.settings.Get(group = 'manager', key = 'copySelectedTextToClipboard', subkey = 'enabled'))
  277. self.winId['manager:copySelectedTextToClipboard:enabled'] = copySelectedTextToClipboard.GetId()
  278. gridSizer.Add(item = copySelectedTextToClipboard,
  279. pos = (row, 0), span = (1, 2))
  280. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  281. border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
  282. #
  283. # workspace
  284. #
  285. box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Workspace settings"))
  286. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  287. gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
  288. gridSizer.AddGrowableCol(0)
  289. row = 0
  290. posDisplay = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  291. label = _("Suppress positioning Map Display Window(s)"),
  292. name = 'IsChecked')
  293. posDisplay.SetValue(self.settings.Get(group = 'general', key = 'workspace',
  294. subkey = ['posDisplay', 'enabled']))
  295. self.winId['general:workspace:posDisplay:enabled'] = posDisplay.GetId()
  296. gridSizer.Add(item = posDisplay,
  297. pos = (row, 0), span = (1, 2))
  298. row += 1
  299. posManager = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  300. label = _("Suppress positioning Layer Manager window"),
  301. name = 'IsChecked')
  302. posManager.SetValue(self.settings.Get(group = 'general', key = 'workspace',
  303. subkey = ['posManager', 'enabled']))
  304. self.winId['general:workspace:posManager:enabled'] = posManager.GetId()
  305. gridSizer.Add(item = posManager,
  306. pos = (row, 0), span = (1, 2))
  307. row += 1
  308. defaultPos = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  309. label = _("Save current window layout as default"),
  310. name = 'IsChecked')
  311. defaultPos.SetValue(self.settings.Get(group = 'general', key = 'defWindowPos', subkey = 'enabled'))
  312. defaultPos.SetToolTip(wx.ToolTip (_("Save current position and size of Layer Manager window and opened "
  313. "Map Display window(s) and use as default for next sessions.")))
  314. self.winId['general:defWindowPos:enabled'] = defaultPos.GetId()
  315. gridSizer.Add(item = defaultPos,
  316. pos = (row, 0), span = (1, 2))
  317. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  318. border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
  319. panel.SetSizer(border)
  320. return panel
  321. panel.SetSizer(border)
  322. return panel
  323. def _createAppearancePage(self, notebook):
  324. """!Create notebook page for display settings"""
  325. panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
  326. notebook.AddPage(page = panel, text = _("Appearance"))
  327. border = wx.BoxSizer(wx.VERTICAL)
  328. box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Font settings"))
  329. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  330. gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
  331. gridSizer.AddGrowableCol(0)
  332. #
  333. # font settings
  334. #
  335. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  336. border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
  337. row = 0
  338. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  339. label = _("Font for command output:")),
  340. flag = wx.ALIGN_LEFT |
  341. wx.ALIGN_CENTER_VERTICAL,
  342. pos = (row, 0))
  343. outfontButton = wx.Button(parent = panel, id = wx.ID_ANY,
  344. label = _("Set font"), size = (100, -1))
  345. gridSizer.Add(item = outfontButton,
  346. flag = wx.ALIGN_RIGHT |
  347. wx.ALIGN_CENTER_VERTICAL,
  348. pos = (row, 1))
  349. #
  350. # languages
  351. #
  352. box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Set language)"))
  353. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  354. gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
  355. gridSizer.AddGrowableCol(0)
  356. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  357. border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
  358. row = 0
  359. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  360. label = _("Choose language (requires to save and GRASS restart)::")),
  361. flag = wx.ALIGN_LEFT |
  362. wx.ALIGN_CENTER_VERTICAL,
  363. pos = (row, 0))
  364. self.locales = self.settings.Get(group = 'language', key = 'locale',
  365. subkey = 'choices', internal = True)
  366. elementList = wx.Choice(parent = panel, id = wx.ID_ANY, size = (325, -1),
  367. choices = self.locales, name = "GetSelection")
  368. if self.settings.Get(group = 'language', key = 'locale',
  369. subkey = 'lc_all'):
  370. elementList.SetSelection(self.settings.Get(group = 'language',
  371. key = 'locale', subkey = 'lc_all'))
  372. self.winId['language:locale:lc_all'] = elementList.GetId()
  373. gridSizer.Add(item = elementList,
  374. flag = wx.ALIGN_RIGHT |
  375. wx.ALIGN_CENTER_VERTICAL,
  376. pos = (row, 1))
  377. #
  378. # appearence
  379. #
  380. box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Appearance settings"))
  381. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  382. gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
  383. gridSizer.AddGrowableCol(0)
  384. #
  385. # element list
  386. #
  387. row = 0
  388. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  389. label = _("Element list:")),
  390. flag = wx.ALIGN_LEFT |
  391. wx.ALIGN_CENTER_VERTICAL,
  392. pos = (row, 0))
  393. elementList = wx.Choice(parent = panel, id = wx.ID_ANY, size = (325, -1),
  394. choices = self.settings.Get(group = 'appearance', key = 'elementListExpand',
  395. subkey = 'choices', internal = True),
  396. name = "GetSelection")
  397. elementList.SetSelection(self.settings.Get(group = 'appearance', key = 'elementListExpand',
  398. subkey = 'selection'))
  399. self.winId['appearance:elementListExpand:selection'] = elementList.GetId()
  400. gridSizer.Add(item = elementList,
  401. flag = wx.ALIGN_RIGHT |
  402. wx.ALIGN_CENTER_VERTICAL,
  403. pos = (row, 1))
  404. #
  405. # menu style
  406. #
  407. row += 1
  408. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  409. label = _("Menu style (requires to save and GUI restart):")),
  410. flag = wx.ALIGN_LEFT |
  411. wx.ALIGN_CENTER_VERTICAL,
  412. pos = (row, 0))
  413. listOfStyles = self.settings.Get(group = 'appearance', key = 'menustyle',
  414. subkey = 'choices', internal = True)
  415. menuItemText = wx.Choice(parent = panel, id = wx.ID_ANY, size = (325, -1),
  416. choices = listOfStyles,
  417. name = "GetSelection")
  418. menuItemText.SetSelection(self.settings.Get(group = 'appearance', key = 'menustyle', subkey = 'selection'))
  419. self.winId['appearance:menustyle:selection'] = menuItemText.GetId()
  420. gridSizer.Add(item = menuItemText,
  421. flag = wx.ALIGN_RIGHT,
  422. pos = (row, 1))
  423. #
  424. # gselect.TreeCtrlComboPopup height
  425. #
  426. row += 1
  427. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  428. label = _("Height of map selection popup window (in pixels):")),
  429. flag = wx.ALIGN_LEFT |
  430. wx.ALIGN_CENTER_VERTICAL,
  431. pos = (row, 0))
  432. min = self.settings.Get(group = 'appearance', key = 'gSelectPopupHeight', subkey = 'min', internal = True)
  433. max = self.settings.Get(group = 'appearance', key = 'gSelectPopupHeight', subkey = 'max', internal = True)
  434. value = self.settings.Get(group = 'appearance', key = 'gSelectPopupHeight', subkey = 'value')
  435. popupHeightSpin = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (100, -1))
  436. popupHeightSpin.SetRange(min,max)
  437. popupHeightSpin.SetValue(value)
  438. self.winId['appearance:gSelectPopupHeight:value'] = popupHeightSpin.GetId()
  439. gridSizer.Add(item = popupHeightSpin,
  440. flag = wx.ALIGN_RIGHT,
  441. pos = (row, 1))
  442. #
  443. # icon theme
  444. #
  445. row += 1
  446. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  447. label = _("Icon theme (requires GUI restart):")),
  448. flag = wx.ALIGN_LEFT |
  449. wx.ALIGN_CENTER_VERTICAL,
  450. pos = (row, 0))
  451. iconTheme = wx.Choice(parent = panel, id = wx.ID_ANY, size = (100, -1),
  452. choices = self.settings.Get(group = 'appearance', key = 'iconTheme',
  453. subkey = 'choices', internal = True),
  454. name = "GetStringSelection")
  455. iconTheme.SetStringSelection(self.settings.Get(group = 'appearance', key = 'iconTheme', subkey = 'type'))
  456. self.winId['appearance:iconTheme:type'] = iconTheme.GetId()
  457. gridSizer.Add(item = iconTheme,
  458. flag = wx.ALIGN_RIGHT |
  459. wx.ALIGN_CENTER_VERTICAL,
  460. pos = (row, 1))
  461. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  462. border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
  463. panel.SetSizer(border)
  464. # bindings
  465. outfontButton.Bind(wx.EVT_BUTTON, self.OnSetOutputFont)
  466. return panel
  467. def _createDisplayPage(self, notebook):
  468. """!Create notebook page for display settings"""
  469. panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
  470. notebook.AddPage(page = panel, text = _("Map Display"))
  471. border = wx.BoxSizer(wx.VERTICAL)
  472. box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Font settings"))
  473. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  474. gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
  475. gridSizer.AddGrowableCol(0)
  476. #
  477. # font settings
  478. #
  479. row = 0
  480. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  481. label = _("Default font for GRASS displays:")),
  482. flag = wx.ALIGN_LEFT |
  483. wx.ALIGN_CENTER_VERTICAL,
  484. pos = (row, 0))
  485. fontButton = wx.Button(parent = panel, id = wx.ID_ANY,
  486. label = _("Set font"), size = (100, -1))
  487. gridSizer.Add(item = fontButton,
  488. flag = wx.ALIGN_RIGHT |
  489. wx.ALIGN_CENTER_VERTICAL,
  490. pos = (row, 1))
  491. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  492. border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
  493. #
  494. # display settings
  495. #
  496. box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Default display settings"))
  497. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  498. gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
  499. gridSizer.AddGrowableCol(0)
  500. #
  501. # display driver
  502. #
  503. row = 0
  504. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  505. label = _("Display driver:")),
  506. flag = wx.ALIGN_LEFT |
  507. wx.ALIGN_CENTER_VERTICAL,
  508. pos = (row, 0))
  509. listOfDrivers = self.settings.Get(group = 'display', key = 'driver', subkey = 'choices', internal = True)
  510. driver = wx.Choice(parent = panel, id = wx.ID_ANY, size = (150, -1),
  511. choices = listOfDrivers,
  512. name = "GetStringSelection")
  513. driver.SetStringSelection(self.settings.Get(group = 'display', key = 'driver', subkey = 'type'))
  514. self.winId['display:driver:type'] = driver.GetId()
  515. gridSizer.Add(item = driver,
  516. flag = wx.ALIGN_RIGHT,
  517. pos = (row, 1))
  518. #
  519. # Statusbar mode
  520. #
  521. row += 1
  522. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  523. label = _("Statusbar mode:")),
  524. flag = wx.ALIGN_LEFT |
  525. wx.ALIGN_CENTER_VERTICAL,
  526. pos = (row, 0))
  527. listOfModes = self.settings.Get(group = 'display', key = 'statusbarMode', subkey = 'choices', internal = True)
  528. statusbarMode = wx.Choice(parent = panel, id = wx.ID_ANY, size = (150, -1),
  529. choices = listOfModes,
  530. name = "GetSelection")
  531. statusbarMode.SetSelection(self.settings.Get(group = 'display', key = 'statusbarMode', subkey = 'selection'))
  532. self.winId['display:statusbarMode:selection'] = statusbarMode.GetId()
  533. gridSizer.Add(item = statusbarMode,
  534. flag = wx.ALIGN_RIGHT,
  535. pos = (row, 1))
  536. #
  537. # Background color
  538. #
  539. row += 1
  540. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  541. label = _("Background color:")),
  542. flag = wx.ALIGN_LEFT |
  543. wx.ALIGN_CENTER_VERTICAL,
  544. pos = (row, 0))
  545. bgColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
  546. colour = self.settings.Get(group = 'display', key = 'bgcolor', subkey = 'color'),
  547. size = globalvar.DIALOG_COLOR_SIZE)
  548. bgColor.SetName('GetColour')
  549. self.winId['display:bgcolor:color'] = bgColor.GetId()
  550. gridSizer.Add(item = bgColor,
  551. flag = wx.ALIGN_RIGHT,
  552. pos = (row, 1))
  553. #
  554. # Align extent to display size
  555. #
  556. row += 1
  557. alignExtent = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  558. label = _("Align region extent based on display size"),
  559. name = "IsChecked")
  560. alignExtent.SetValue(self.settings.Get(group = 'display', key = 'alignExtent', subkey = 'enabled'))
  561. self.winId['display:alignExtent:enabled'] = alignExtent.GetId()
  562. gridSizer.Add(item = alignExtent,
  563. pos = (row, 0), span = (1, 2))
  564. #
  565. # Use computation resolution
  566. #
  567. row += 1
  568. compResolution = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  569. label = _("Constrain display resolution to computational settings"),
  570. name = "IsChecked")
  571. compResolution.SetValue(self.settings.Get(group = 'display', key = 'compResolution', subkey = 'enabled'))
  572. self.winId['display:compResolution:enabled'] = compResolution.GetId()
  573. gridSizer.Add(item = compResolution,
  574. pos = (row, 0), span = (1, 2))
  575. #
  576. # auto-rendering
  577. #
  578. row += 1
  579. autoRendering = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  580. label = _("Enable auto-rendering"),
  581. name = "IsChecked")
  582. autoRendering.SetValue(self.settings.Get(group = 'display', key = 'autoRendering', subkey = 'enabled'))
  583. self.winId['display:autoRendering:enabled'] = autoRendering.GetId()
  584. gridSizer.Add(item = autoRendering,
  585. pos = (row, 0), span = (1, 2))
  586. #
  587. # auto-zoom
  588. #
  589. row += 1
  590. autoZooming = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  591. label = _("Enable auto-zooming to selected map layer"),
  592. name = "IsChecked")
  593. autoZooming.SetValue(self.settings.Get(group = 'display', key = 'autoZooming', subkey = 'enabled'))
  594. self.winId['display:autoZooming:enabled'] = autoZooming.GetId()
  595. gridSizer.Add(item = autoZooming,
  596. pos = (row, 0), span = (1, 2))
  597. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  598. border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
  599. panel.SetSizer(border)
  600. # bindings
  601. fontButton.Bind(wx.EVT_BUTTON, self.OnSetFont)
  602. return panel
  603. def _createCmdPage(self, notebook):
  604. """!Create notebook page for commad dialog settings"""
  605. panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
  606. notebook.AddPage(page = panel, text = _("Command"))
  607. border = wx.BoxSizer(wx.VERTICAL)
  608. box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Command dialog settings"))
  609. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  610. gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
  611. gridSizer.AddGrowableCol(0)
  612. #
  613. # command dialog settings
  614. #
  615. row = 0
  616. # overwrite
  617. overwrite = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  618. label = _("Allow output files to overwrite existing files"),
  619. name = "IsChecked")
  620. overwrite.SetValue(self.settings.Get(group = 'cmd', key = 'overwrite', subkey = 'enabled'))
  621. self.winId['cmd:overwrite:enabled'] = overwrite.GetId()
  622. gridSizer.Add(item = overwrite,
  623. pos = (row, 0), span = (1, 2))
  624. row += 1
  625. # close
  626. close = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  627. label = _("Close dialog when command is successfully finished"),
  628. name = "IsChecked")
  629. close.SetValue(self.settings.Get(group = 'cmd', key = 'closeDlg', subkey = 'enabled'))
  630. self.winId['cmd:closeDlg:enabled'] = close.GetId()
  631. gridSizer.Add(item = close,
  632. pos = (row, 0), span = (1, 2))
  633. row += 1
  634. # add layer
  635. add = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  636. label = _("Add created map into layer tree"),
  637. name = "IsChecked")
  638. add.SetValue(self.settings.Get(group = 'cmd', key = 'addNewLayer', subkey = 'enabled'))
  639. self.winId['cmd:addNewLayer:enabled'] = add.GetId()
  640. gridSizer.Add(item = add,
  641. pos = (row, 0), span = (1, 2))
  642. row += 1
  643. # interactive input
  644. interactive = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  645. label = _("Allow interactive input"),
  646. name = "IsChecked")
  647. interactive.SetValue(self.settings.Get(group = 'cmd', key = 'interactiveInput', subkey = 'enabled'))
  648. self.winId['cmd:interactiveInput:enabled'] = interactive.GetId()
  649. gridSizer.Add(item = interactive,
  650. pos = (row, 0), span = (1, 2))
  651. row += 1
  652. # verbosity
  653. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  654. label = _("Verbosity level:")),
  655. flag = wx.ALIGN_LEFT |
  656. wx.ALIGN_CENTER_VERTICAL,
  657. pos = (row, 0))
  658. verbosity = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
  659. choices = self.settings.Get(group = 'cmd', key = 'verbosity', subkey = 'choices', internal = True),
  660. name = "GetStringSelection")
  661. verbosity.SetStringSelection(self.settings.Get(group = 'cmd', key = 'verbosity', subkey = 'selection'))
  662. self.winId['cmd:verbosity:selection'] = verbosity.GetId()
  663. gridSizer.Add(item = verbosity,
  664. pos = (row, 1))
  665. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  666. border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
  667. #
  668. # raster settings
  669. #
  670. box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Raster settings"))
  671. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  672. gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
  673. gridSizer.AddGrowableCol(0)
  674. #
  675. # raster overlay
  676. #
  677. row = 0
  678. rasterOpaque = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  679. label = _("Make null cells opaque"),
  680. name = 'IsChecked')
  681. rasterOpaque.SetValue(self.settings.Get(group = 'cmd', key = 'rasterOpaque', subkey = 'enabled'))
  682. self.winId['cmd:rasterOpaque:enabled'] = rasterOpaque.GetId()
  683. gridSizer.Add(item = rasterOpaque,
  684. pos = (row, 0), span = (1, 2))
  685. # default color table
  686. row += 1
  687. rasterCTCheck = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  688. label = _("Default color table"),
  689. name = 'IsChecked')
  690. rasterCTCheck.SetValue(self.settings.Get(group = 'cmd', key = 'rasterColorTable', subkey = 'enabled'))
  691. self.winId['cmd:rasterColorTable:enabled'] = rasterCTCheck.GetId()
  692. rasterCTCheck.Bind(wx.EVT_CHECKBOX, self.OnCheckColorTable)
  693. gridSizer.Add(item = rasterCTCheck,
  694. pos = (row, 0))
  695. rasterCTName = wx.Choice(parent = panel, id = wx.ID_ANY, size = (200, -1),
  696. choices = GetColorTables(),
  697. name = "GetStringSelection")
  698. rasterCTName.SetStringSelection(self.settings.Get(group = 'cmd', key = 'rasterColorTable', subkey = 'selection'))
  699. self.winId['cmd:rasterColorTable:selection'] = rasterCTName.GetId()
  700. if not rasterCTCheck.IsChecked():
  701. rasterCTName.Enable(False)
  702. gridSizer.Add(item = rasterCTName,
  703. pos = (row, 1))
  704. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  705. border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
  706. #
  707. # vector settings
  708. #
  709. box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Vector settings"))
  710. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  711. gridSizer = wx.FlexGridSizer (cols = 7, hgap = 3, vgap = 3)
  712. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  713. label = _("Display:")),
  714. flag = wx.ALIGN_CENTER_VERTICAL)
  715. for type in ('point', 'line', 'centroid', 'boundary',
  716. 'area', 'face'):
  717. chkbox = wx.CheckBox(parent = panel, label = type)
  718. checked = self.settings.Get(group = 'cmd', key = 'showType',
  719. subkey = [type, 'enabled'])
  720. chkbox.SetValue(checked)
  721. self.winId['cmd:showType:%s:enabled' % type] = chkbox.GetId()
  722. gridSizer.Add(item = chkbox)
  723. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  724. border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
  725. panel.SetSizer(border)
  726. return panel
  727. def _createAttributeManagerPage(self, notebook):
  728. """!Create notebook page for 'Attribute Table Manager' settings"""
  729. panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
  730. notebook.AddPage(page = panel, text = _("Attributes"))
  731. pageSizer = wx.BoxSizer(wx.VERTICAL)
  732. #
  733. # highlighting
  734. #
  735. highlightBox = wx.StaticBox(parent = panel, id = wx.ID_ANY,
  736. label = " %s " % _("Highlighting"))
  737. highlightSizer = wx.StaticBoxSizer(highlightBox, wx.VERTICAL)
  738. flexSizer = wx.FlexGridSizer (cols = 2, hgap = 5, vgap = 5)
  739. flexSizer.AddGrowableCol(0)
  740. label = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _("Color:"))
  741. hlColor = csel.ColourSelect(parent = panel, id = wx.ID_ANY,
  742. colour = self.settings.Get(group = 'atm', key = 'highlight', subkey = 'color'),
  743. size = globalvar.DIALOG_COLOR_SIZE)
  744. hlColor.SetName('GetColour')
  745. self.winId['atm:highlight:color'] = hlColor.GetId()
  746. flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
  747. flexSizer.Add(hlColor, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
  748. label = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _("Line width (in pixels):"))
  749. hlWidth = wx.SpinCtrl(parent = panel, id = wx.ID_ANY, size = (50, -1),
  750. initial = self.settings.Get(group = 'atm', key = 'highlight',subkey = 'width'),
  751. min = 1, max = 1e6)
  752. self.winId['atm:highlight:width'] = hlWidth.GetId()
  753. flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
  754. flexSizer.Add(hlWidth, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
  755. highlightSizer.Add(item = flexSizer,
  756. proportion = 0,
  757. flag = wx.ALL | wx.EXPAND,
  758. border = 5)
  759. pageSizer.Add(item = highlightSizer,
  760. proportion = 0,
  761. flag = wx.ALL | wx.EXPAND,
  762. border = 5)
  763. #
  764. # data browser related settings
  765. #
  766. dataBrowserBox = wx.StaticBox(parent = panel, id = wx.ID_ANY,
  767. label = " %s " % _("Data browser"))
  768. dataBrowserSizer = wx.StaticBoxSizer(dataBrowserBox, wx.VERTICAL)
  769. flexSizer = wx.FlexGridSizer (cols = 2, hgap = 5, vgap = 5)
  770. flexSizer.AddGrowableCol(0)
  771. label = wx.StaticText(parent = panel, id = wx.ID_ANY, label = _("Left mouse double click:"))
  772. leftDbClick = wx.Choice(parent = panel, id = wx.ID_ANY,
  773. choices = self.settings.Get(group = 'atm', key = 'leftDbClick', subkey = 'choices', internal = True),
  774. name = "GetSelection")
  775. leftDbClick.SetSelection(self.settings.Get(group = 'atm', key = 'leftDbClick', subkey = 'selection'))
  776. self.winId['atm:leftDbClick:selection'] = leftDbClick.GetId()
  777. flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
  778. flexSizer.Add(leftDbClick, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
  779. # encoding
  780. label = wx.StaticText(parent = panel, id = wx.ID_ANY,
  781. label = _("Encoding (e.g. utf-8, ascii, iso8859-1, koi8-r):"))
  782. encoding = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
  783. value = self.settings.Get(group = 'atm', key = 'encoding', subkey = 'value'),
  784. name = "GetValue", size = (200, -1))
  785. self.winId['atm:encoding:value'] = encoding.GetId()
  786. flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
  787. flexSizer.Add(encoding, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
  788. # ask on delete record
  789. askOnDeleteRec = wx.CheckBox(parent = panel, id = wx.ID_ANY,
  790. label = _("Ask when deleting data record(s) from table"),
  791. name = 'IsChecked')
  792. askOnDeleteRec.SetValue(self.settings.Get(group = 'atm', key = 'askOnDeleteRec', subkey = 'enabled'))
  793. self.winId['atm:askOnDeleteRec:enabled'] = askOnDeleteRec.GetId()
  794. flexSizer.Add(askOnDeleteRec, proportion = 0)
  795. dataBrowserSizer.Add(item = flexSizer,
  796. proportion = 0,
  797. flag = wx.ALL | wx.EXPAND,
  798. border = 5)
  799. pageSizer.Add(item = dataBrowserSizer,
  800. proportion = 0,
  801. flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND,
  802. border = 3)
  803. #
  804. # create table
  805. #
  806. createTableBox = wx.StaticBox(parent = panel, id = wx.ID_ANY,
  807. label = " %s " % _("Create table"))
  808. createTableSizer = wx.StaticBoxSizer(createTableBox, wx.VERTICAL)
  809. flexSizer = wx.FlexGridSizer (cols = 2, hgap = 5, vgap = 5)
  810. flexSizer.AddGrowableCol(0)
  811. label = wx.StaticText(parent = panel, id = wx.ID_ANY,
  812. label = _("Key column:"))
  813. keyColumn = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
  814. size = (250, -1))
  815. keyColumn.SetValue(self.settings.Get(group = 'atm', key = 'keycolumn', subkey = 'value'))
  816. self.winId['atm:keycolumn:value'] = keyColumn.GetId()
  817. flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
  818. flexSizer.Add(keyColumn, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
  819. createTableSizer.Add(item = flexSizer,
  820. proportion = 0,
  821. flag = wx.ALL | wx.EXPAND,
  822. border = 5)
  823. pageSizer.Add(item = createTableSizer,
  824. proportion = 0,
  825. flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND,
  826. border = 3)
  827. panel.SetSizer(pageSizer)
  828. return panel
  829. def _createProjectionPage(self, notebook):
  830. """!Create notebook page for workspace settings"""
  831. panel = wx.Panel(parent = notebook, id = wx.ID_ANY)
  832. notebook.AddPage(page = panel, text = _("Projection"))
  833. border = wx.BoxSizer(wx.VERTICAL)
  834. #
  835. # projections statusbar settings
  836. #
  837. box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Projection statusbar settings"))
  838. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  839. gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
  840. gridSizer.AddGrowableCol(1)
  841. # epsg
  842. row = 0
  843. label = wx.StaticText(parent = panel, id = wx.ID_ANY,
  844. label = _("EPSG code:"))
  845. epsgCode = wx.ComboBox(parent = panel, id = wx.ID_ANY,
  846. name = "GetValue",
  847. size = (150, -1))
  848. self.epsgCodeDict = dict()
  849. epsgCode.SetValue(str(self.settings.Get(group = 'projection', key = 'statusbar', subkey = 'epsg')))
  850. self.winId['projection:statusbar:epsg'] = epsgCode.GetId()
  851. gridSizer.Add(item = label,
  852. pos = (row, 0),
  853. flag = wx.ALIGN_CENTER_VERTICAL)
  854. gridSizer.Add(item = epsgCode,
  855. pos = (row, 1), span = (1, 2))
  856. # proj
  857. row += 1
  858. label = wx.StaticText(parent = panel, id = wx.ID_ANY,
  859. label = _("Proj.4 string (required):"))
  860. projString = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
  861. value = self.settings.Get(group = 'projection', key = 'statusbar', subkey = 'proj4'),
  862. name = "GetValue", size = (400, -1))
  863. self.winId['projection:statusbar:proj4'] = projString.GetId()
  864. gridSizer.Add(item = label,
  865. pos = (row, 0),
  866. flag = wx.ALIGN_CENTER_VERTICAL)
  867. gridSizer.Add(item = projString,
  868. pos = (row, 1), span = (1, 2),
  869. flag = wx.ALIGN_CENTER_VERTICAL)
  870. # epsg file
  871. row += 1
  872. label = wx.StaticText(parent = panel, id = wx.ID_ANY,
  873. label = _("EPSG file:"))
  874. projFile = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
  875. value = self.settings.Get(group = 'projection', key = 'statusbar', subkey = 'projFile'),
  876. name = "GetValue", size = (400, -1))
  877. self.winId['projection:statusbar:projFile'] = projFile.GetId()
  878. gridSizer.Add(item = label,
  879. pos = (row, 0),
  880. flag = wx.ALIGN_CENTER_VERTICAL)
  881. gridSizer.Add(item = projFile,
  882. pos = (row, 1),
  883. flag = wx.ALIGN_CENTER_VERTICAL)
  884. # note + button
  885. row += 1
  886. note = wx.StaticText(parent = panel, id = wx.ID_ANY,
  887. label = _("Load EPSG codes (be patient), enter EPSG code or "
  888. "insert Proj.4 string directly."))
  889. gridSizer.Add(item = note,
  890. span = (1, 2),
  891. pos = (row, 0))
  892. row += 1
  893. epsgLoad = wx.Button(parent = panel, id = wx.ID_ANY,
  894. label = _("&Load EPSG codes"))
  895. gridSizer.Add(item = epsgLoad,
  896. flag = wx.ALIGN_RIGHT,
  897. pos = (row, 1))
  898. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  899. border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
  900. #
  901. # format
  902. #
  903. box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Coordinates format"))
  904. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  905. gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
  906. gridSizer.AddGrowableCol(2)
  907. row = 0
  908. # ll format
  909. ll = wx.RadioBox(parent = panel, id = wx.ID_ANY,
  910. label = " %s " % _("LL projections"),
  911. choices = ["DMS", "DEG"],
  912. name = "GetStringSelection")
  913. self.winId['projection:format:ll'] = ll.GetId()
  914. if self.settings.Get(group = 'projection', key = 'format', subkey = 'll') == 'DMS':
  915. ll.SetSelection(0)
  916. else:
  917. ll.SetSelection(1)
  918. # precision
  919. precision = wx.SpinCtrl(parent = panel, id = wx.ID_ANY,
  920. min = 0, max = 12,
  921. name = "GetValue")
  922. precision.SetValue(int(self.settings.Get(group = 'projection', key = 'format', subkey = 'precision')))
  923. self.winId['projection:format:precision'] = precision.GetId()
  924. gridSizer.Add(item = ll,
  925. pos = (row, 0))
  926. gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
  927. label = _("Precision:")),
  928. flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.LEFT,
  929. border = 20,
  930. pos = (row, 1))
  931. gridSizer.Add(item = precision,
  932. flag = wx.ALIGN_CENTER_VERTICAL,
  933. pos = (row, 2))
  934. sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
  935. border.Add(item = sizer, proportion = 0, flag = wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border = 3)
  936. panel.SetSizer(border)
  937. # bindings
  938. epsgLoad.Bind(wx.EVT_BUTTON, self.OnLoadEpsgCodes)
  939. epsgCode.Bind(wx.EVT_COMBOBOX, self.OnSetEpsgCode)
  940. epsgCode.Bind(wx.EVT_TEXT_ENTER, self.OnSetEpsgCode)
  941. return panel
  942. def OnCheckColorTable(self, event):
  943. """!Set/unset default color table"""
  944. win = self.FindWindowById(self.winId['cmd:rasterColorTable:selection'])
  945. if event.IsChecked():
  946. win.Enable()
  947. else:
  948. win.Enable(False)
  949. def OnLoadEpsgCodes(self, event):
  950. """!Load EPSG codes from the file"""
  951. win = self.FindWindowById(self.winId['projection:statusbar:projFile'])
  952. path = win.GetValue()
  953. self.epsgCodeDict = ReadEpsgCodes(path)
  954. list = self.FindWindowById(self.winId['projection:statusbar:epsg'])
  955. if type(self.epsgCodeDict) == type(''):
  956. wx.MessageBox(parent = self,
  957. message = _("Unable to read EPSG codes: %s") % self.epsgCodeDict,
  958. caption = _("Error"), style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
  959. self.epsgCodeDict = dict()
  960. list.SetItems([])
  961. list.SetValue('')
  962. self.FindWindowById(self.winId['projection:statusbar:proj4']).SetValue('')
  963. return
  964. choices = map(str, self.epsgCodeDict.keys())
  965. list.SetItems(choices)
  966. try:
  967. code = int(list.GetValue())
  968. except ValueError:
  969. code = -1
  970. win = self.FindWindowById(self.winId['projection:statusbar:proj4'])
  971. if code in self.epsgCodeDict:
  972. win.SetValue(self.epsgCodeDict[code][1])
  973. else:
  974. list.SetSelection(0)
  975. code = int(list.GetStringSelection())
  976. win.SetValue(self.epsgCodeDict[code][1])
  977. def OnSetEpsgCode(self, event):
  978. """!EPSG code selected"""
  979. winCode = self.FindWindowById(event.GetId())
  980. win = self.FindWindowById(self.winId['projection:statusbar:proj4'])
  981. if not self.epsgCodeDict:
  982. wx.MessageBox(parent = self,
  983. message = _("EPSG code %s not found") % event.GetString(),
  984. caption = _("Error"), style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
  985. winCode.SetValue('')
  986. win.SetValue('')
  987. try:
  988. code = int(event.GetString())
  989. except ValueError:
  990. wx.MessageBox(parent = self,
  991. message = _("EPSG code %s not found") % str(code),
  992. caption = _("Error"), style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
  993. winCode.SetValue('')
  994. win.SetValue('')
  995. try:
  996. win.SetValue(self.epsgCodeDict[code][1].replace('<>', '').strip())
  997. except KeyError:
  998. wx.MessageBox(parent = self,
  999. message = _("EPSG code %s not found") % str(code),
  1000. caption = _("Error"), style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
  1001. winCode.SetValue('')
  1002. win.SetValue('')
  1003. def OnSetFont(self, event):
  1004. """'Set font' button pressed"""
  1005. dlg = DefaultFontDialog(parent = self,
  1006. title = _('Select default display font'),
  1007. style = wx.DEFAULT_DIALOG_STYLE,
  1008. type = 'font')
  1009. if dlg.ShowModal() == wx.ID_OK:
  1010. # set default font and encoding environmental variables
  1011. if dlg.font:
  1012. os.environ["GRASS_FONT"] = dlg.font
  1013. self.settings.Set(group = 'display', value = dlg.font,
  1014. key = 'font', subkey = 'type')
  1015. if dlg.encoding and \
  1016. dlg.encoding != "ISO-8859-1":
  1017. os.environ["GRASS_ENCODING"] = dlg.encoding
  1018. self.settings.Set(group = 'display', value = dlg.encoding,
  1019. key = 'font', subkey = 'encoding')
  1020. dlg.Destroy()
  1021. event.Skip()
  1022. def OnSetOutputFont(self, event):
  1023. """'Set output font' button pressed
  1024. """
  1025. type = self.settings.Get(group = 'appearance', key = 'outputfont', subkey = 'type')
  1026. size = self.settings.Get(group = 'appearance', key = 'outputfont', subkey = 'size')
  1027. if size == None or size == 0: size = 11
  1028. size = float(size)
  1029. if type == None or type == '': type = 'Courier'
  1030. outfont = wx.Font(size, wx.FONTFAMILY_MODERN, wx.NORMAL, 0, faceName = type)
  1031. fontdata = wx.FontData()
  1032. fontdata.EnableEffects(True)
  1033. fontdata.SetColour('black')
  1034. fontdata.SetInitialFont(outfont)
  1035. dlg = wx.FontDialog(self, fontdata)
  1036. 'FIXME: native font dialog does not initialize with current font'
  1037. if dlg.ShowModal() == wx.ID_OK:
  1038. outdata = dlg.GetFontData()
  1039. font = outdata.GetChosenFont()
  1040. self.settings.Set(group = 'appearance', value = font.GetFaceName(),
  1041. key = 'outputfont', subkey = 'type')
  1042. self.settings.Set(group = 'appearance', value = font.GetPointSize(),
  1043. key = 'outputfont', subkey = 'size')
  1044. dlg.Destroy()
  1045. event.Skip()
  1046. class DefaultFontDialog(wx.Dialog):
  1047. """
  1048. Opens a file selection dialog to select default font
  1049. to use in all GRASS displays
  1050. """
  1051. def __init__(self, parent, title, id = wx.ID_ANY,
  1052. style = wx.DEFAULT_DIALOG_STYLE |
  1053. wx.RESIZE_BORDER,
  1054. settings = UserSettings,
  1055. type = 'font'):
  1056. self.settings = settings
  1057. self.type = type
  1058. wx.Dialog.__init__(self, parent, id, title, style = style)
  1059. panel = wx.Panel(parent = self, id = wx.ID_ANY)
  1060. self.fontlist = self.GetFonts()
  1061. border = wx.BoxSizer(wx.VERTICAL)
  1062. box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Font settings"))
  1063. sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
  1064. gridSizer = wx.GridBagSizer (hgap = 5, vgap = 5)
  1065. gridSizer.AddGrowableCol(0)
  1066. label = wx.StaticText(parent = panel, id = wx.ID_ANY,
  1067. label = _("Select font:"))
  1068. gridSizer.Add(item = label,
  1069. flag = wx.ALIGN_TOP,
  1070. pos = (0,0))
  1071. self.fontlb = wx.ListBox(parent = panel, id = wx.ID_ANY, pos = wx.DefaultPosition,
  1072. choices = self.fontlist,
  1073. style = wx.LB_SINGLE|wx.LB_SORT)
  1074. self.Bind(wx.EVT_LISTBOX, self.EvtListBox, self.fontlb)
  1075. self.Bind(wx.EVT_LISTBOX_DCLICK, self.EvtListBoxDClick, self.fontlb)
  1076. gridSizer.Add(item = self.fontlb,
  1077. flag = wx.EXPAND, pos = (1, 0))
  1078. if self.type == 'font':
  1079. if "GRASS_FONT" in os.environ:
  1080. self.font = os.environ["GRASS_FONT"]
  1081. else:
  1082. self.font = self.settings.Get(group = 'display',
  1083. key = 'font', subkey = 'type')
  1084. self.encoding = self.settings.Get(group = 'display',
  1085. key = 'font', subkey = 'encoding')
  1086. label = wx.StaticText(parent = panel, id = wx.ID_ANY,
  1087. label = _("Character encoding:"))
  1088. gridSizer.Add(item = label,
  1089. flag = wx.ALIGN_CENTER_VERTICAL,
  1090. pos = (2, 0))
  1091. self.textentry = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
  1092. value = self.encoding)
  1093. gridSizer.Add(item = self.textentry,
  1094. flag = wx.EXPAND, pos = (3, 0))
  1095. self.textentry.Bind(wx.EVT_TEXT, self.OnEncoding)
  1096. elif self.type == 'outputfont':
  1097. self.font = self.settings.Get(group = 'appearance',
  1098. key = 'outputfont', subkey = 'type')
  1099. self.fontsize = self.settings.Get(group = 'appearance',
  1100. key = 'outputfont', subkey = 'size')
  1101. label = wx.StaticText(parent = panel, id = wx.ID_ANY,
  1102. label = _("Font size:"))
  1103. gridSizer.Add(item = label,
  1104. flag = wx.ALIGN_CENTER_VERTICAL,
  1105. pos = (2, 0))
  1106. self.spin = wx.SpinCtrl(parent = panel, id = wx.ID_ANY)
  1107. if self.fontsize:
  1108. self.spin.SetValue(self.fontsize)
  1109. self.spin.Bind(wx.EVT_SPINCTRL, self.OnSizeSpin)
  1110. self.spin.Bind(wx.EVT_TEXT, self.OnSizeSpin)
  1111. gridSizer.Add(item = self.spin,
  1112. flag = wx.ALIGN_CENTER_VERTICAL,
  1113. pos = (3, 0))
  1114. else:
  1115. return
  1116. if self.font:
  1117. self.fontlb.SetStringSelection(self.font, True)
  1118. sizer.Add(item = gridSizer, proportion = 1,
  1119. flag = wx.EXPAND | wx.ALL,
  1120. border = 5)
  1121. border.Add(item = sizer, proportion = 1,
  1122. flag = wx.ALL | wx.EXPAND, border = 3)
  1123. btnsizer = wx.StdDialogButtonSizer()
  1124. btn = wx.Button(parent = panel, id = wx.ID_OK)
  1125. btn.SetDefault()
  1126. btnsizer.AddButton(btn)
  1127. btn = wx.Button(parent = panel, id = wx.ID_CANCEL)
  1128. btnsizer.AddButton(btn)
  1129. btnsizer.Realize()
  1130. border.Add(item = btnsizer, proportion = 0,
  1131. flag = wx.EXPAND | wx.ALIGN_RIGHT | wx.ALL, border = 5)
  1132. panel.SetAutoLayout(True)
  1133. panel.SetSizer(border)
  1134. border.Fit(self)
  1135. self.Layout()
  1136. def EvtRadioBox(self, event):
  1137. if event.GetInt() == 0:
  1138. self.fonttype = 'grassfont'
  1139. elif event.GetInt() == 1:
  1140. self.fonttype = 'truetype'
  1141. self.fontlist = self.GetFonts(self.fonttype)
  1142. self.fontlb.SetItems(self.fontlist)
  1143. def OnEncoding(self, event):
  1144. self.encoding = event.GetString()
  1145. def EvtListBox(self, event):
  1146. self.font = event.GetString()
  1147. event.Skip()
  1148. def EvtListBoxDClick(self, event):
  1149. self.font = event.GetString()
  1150. event.Skip()
  1151. def OnSizeSpin(self, event):
  1152. self.fontsize = self.spin.GetValue()
  1153. event.Skip()
  1154. def GetFonts(self):
  1155. """
  1156. parses fonts directory or fretypecap file to get a list of fonts for the listbox
  1157. """
  1158. fontlist = []
  1159. cmd = ["d.font", "-l"]
  1160. ret = RunCommand('d.font',
  1161. read = True,
  1162. flags = 'l')
  1163. if not ret:
  1164. return fontlist
  1165. dfonts = ret.splitlines()
  1166. dfonts.sort(lambda x,y: cmp(x.lower(), y.lower()))
  1167. for item in range(len(dfonts)):
  1168. # ignore duplicate fonts and those starting with #
  1169. if not dfonts[item].startswith('#') and \
  1170. dfonts[item] != dfonts[item-1]:
  1171. fontlist.append(dfonts[item])
  1172. return fontlist
  1173. class MapsetAccess(wx.Dialog):
  1174. """!Controls setting options and displaying/hiding map overlay
  1175. decorations
  1176. """
  1177. def __init__(self, parent, id = wx.ID_ANY,
  1178. title = _('Manage access to mapsets'),
  1179. size = (350, 400),
  1180. style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, **kwargs):
  1181. wx.Dialog.__init__(self, parent, id, title, size = size, style = style)
  1182. self.all_mapsets_ordered = ListOfMapsets(get = 'ordered')
  1183. self.accessible_mapsets = ListOfMapsets(get = 'accessible')
  1184. self.curr_mapset = grass.gisenv()['MAPSET']
  1185. # make a checklistbox from available mapsets and check those that are active
  1186. sizer = wx.BoxSizer(wx.VERTICAL)
  1187. label = wx.StaticText(parent = self, id = wx.ID_ANY,
  1188. label = _("Check a mapset to make it accessible, uncheck it to hide it.\n"
  1189. " Notes:\n"
  1190. " - The current mapset is always accessible.\n"
  1191. " - You may only write to the current mapset.\n"
  1192. " - You may only write to mapsets which you own."))
  1193. sizer.Add(item = label, proportion = 0,
  1194. flag = wx.ALL, border = 5)
  1195. self.mapsetlb = CheckListMapset(parent = self)
  1196. self.mapsetlb.LoadData()
  1197. sizer.Add(item = self.mapsetlb, proportion = 1,
  1198. flag = wx.ALL | wx.EXPAND, border = 5)
  1199. # check all accessible mapsets
  1200. for mset in self.accessible_mapsets:
  1201. self.mapsetlb.CheckItem(self.all_mapsets_ordered.index(mset), True)
  1202. # FIXME (howto?): grey-out current mapset
  1203. #self.mapsetlb.Enable(0, False)
  1204. # dialog buttons
  1205. line = wx.StaticLine(parent = self, id = wx.ID_ANY,
  1206. style = wx.LI_HORIZONTAL)
  1207. sizer.Add(item = line, proportion = 0,
  1208. flag = wx.EXPAND | wx.ALIGN_CENTRE | wx.ALL, border = 5)
  1209. btnsizer = wx.StdDialogButtonSizer()
  1210. okbtn = wx.Button(self, wx.ID_OK)
  1211. okbtn.SetDefault()
  1212. btnsizer.AddButton(okbtn)
  1213. cancelbtn = wx.Button(self, wx.ID_CANCEL)
  1214. btnsizer.AddButton(cancelbtn)
  1215. btnsizer.Realize()
  1216. sizer.Add(item = btnsizer, proportion = 0,
  1217. flag = wx.EXPAND | wx.ALIGN_RIGHT | wx.ALL, border = 5)
  1218. # do layout
  1219. self.Layout()
  1220. self.SetSizer(sizer)
  1221. sizer.Fit(self)
  1222. self.SetMinSize(size)
  1223. def GetMapsets(self):
  1224. """!Get list of checked mapsets"""
  1225. ms = []
  1226. i = 0
  1227. for mset in self.all_mapsets_ordered:
  1228. if self.mapsetlb.IsChecked(i):
  1229. ms.append(mset)
  1230. i += 1
  1231. return ms
  1232. class CheckListMapset(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.CheckListCtrlMixin):
  1233. """!List of mapset/owner/group"""
  1234. def __init__(self, parent, pos = wx.DefaultPosition,
  1235. log = None):
  1236. self.parent = parent
  1237. wx.ListCtrl.__init__(self, parent, wx.ID_ANY,
  1238. style = wx.LC_REPORT)
  1239. listmix.CheckListCtrlMixin.__init__(self)
  1240. self.log = log
  1241. # setup mixins
  1242. listmix.ListCtrlAutoWidthMixin.__init__(self)
  1243. def LoadData(self):
  1244. """!Load data into list"""
  1245. self.InsertColumn(0, _('Mapset'))
  1246. self.InsertColumn(1, _('Owner'))
  1247. ### self.InsertColumn(2, _('Group'))
  1248. gisenv = grass.gisenv()
  1249. locationPath = os.path.join(gisenv['GISDBASE'], gisenv['LOCATION_NAME'])
  1250. for mapset in self.parent.all_mapsets_ordered:
  1251. index = self.InsertStringItem(sys.maxint, mapset)
  1252. mapsetPath = os.path.join(locationPath,
  1253. mapset)
  1254. stat_info = os.stat(mapsetPath)
  1255. if havePwd:
  1256. self.SetStringItem(index, 1, "%s" % pwd.getpwuid(stat_info.st_uid)[0])
  1257. # FIXME: get group name
  1258. ### self.SetStringItem(index, 2, "%-8s" % stat_info.st_gid)
  1259. else:
  1260. # FIXME: no pwd under MS Windows (owner: 0, group: 0)
  1261. self.SetStringItem(index, 1, "%-8s" % stat_info.st_uid)
  1262. ### self.SetStringItem(index, 2, "%-8s" % stat_info.st_gid)
  1263. self.SetColumnWidth(col = 0, width = wx.LIST_AUTOSIZE)
  1264. ### self.SetColumnWidth(col = 1, width = wx.LIST_AUTOSIZE)
  1265. def OnCheckItem(self, index, flag):
  1266. """!Mapset checked/unchecked"""
  1267. mapset = self.parent.all_mapsets_ordered[index]
  1268. if mapset == self.parent.curr_mapset:
  1269. self.CheckItem(index, True)