123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172 |
- """
- @package gui_core.preferences
- @brief User preferences dialog
- Sets default display font, etc. If you want to add some value to
- settings you have to add default value to defaultSettings and set
- constraints in internalSettings in Settings class. Everything can be
- used in PreferencesDialog.
- Classes:
- - preferences::PreferencesBaseDialog
- - preferences::PreferencesDialog
- - preferences::MapsetAccess
- - preferences::CheckListMapset
- (C) 2007-2014 by the GRASS Development Team
- This program is free software under the GNU General Public License
- (>=v2). Read the file COPYING that comes with GRASS for details.
- @author Michael Barton (Arizona State University)
- @author Martin Landa <landa.martin gmail.com>
- @author Vaclav Petras <wenzeslaus gmail.com> (menu customization)
- @author Luca Delucchi <lucadeluge gmail.com> (language choice)
- """
- import os
- import sys
- import copy
- try:
- import pwd
- havePwd = True
- except ImportError:
- havePwd = False
- import wx
- import wx.lib.colourselect as csel
- import wx.lib.mixins.listctrl as listmix
- import wx.lib.scrolledpanel as SP
- from grass.pydispatch.signal import Signal
- import grass.script as grass
- from grass.exceptions import OpenError
- from core import globalvar
- from core.gcmd import RunCommand, GError
- from core.utils import ListOfMapsets, GetColorTables, ReadEpsgCodes, _
- from core.settings import UserSettings
- from gui_core.dialogs import SymbolDialog, DefaultFontDialog
- from gui_core.widgets import IntegerValidator, ColorTablesComboBox
- from core.debug import Debug
- class PreferencesBaseDialog(wx.Dialog):
- """Base preferences dialog"""
- def __init__(self, parent, giface, settings, title=_("User settings"),
- size=(500, 475),
- style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
- self.parent = parent # ModelerFrame
- self.title = title
- self.size = size
- self.settings = settings
- self._giface = giface
- wx.Dialog.__init__(self, parent=parent, id=wx.ID_ANY, title=title,
- style=style)
- self.settingsChanged = Signal('PreferencesBaseDialog.settingsChanged')
- # notebook
- self.notebook = wx.Notebook(
- parent=self, id=wx.ID_ANY, style=wx.BK_DEFAULT)
- # dict for window ids
- self.winId = {}
- # create notebook pages
- # buttons
- self.btnDefault = wx.Button(self, wx.ID_ANY, _("Set to default"))
- self.btnSave = wx.Button(self, wx.ID_SAVE)
- self.btnApply = wx.Button(self, wx.ID_APPLY)
- self.btnCancel = wx.Button(self, wx.ID_CANCEL)
- self.btnSave.SetDefault()
- # bindigs
- self.btnDefault.Bind(wx.EVT_BUTTON, self.OnDefault)
- self.btnDefault.SetToolTipString(_("Revert settings to default"))
- self.btnApply.Bind(wx.EVT_BUTTON, self.OnApply)
- self.btnApply.SetToolTipString(
- _("Apply changes for the current session only and close"))
- self.btnApply.SetLabel(_("Save for this session only"))
- self.btnSave.Bind(wx.EVT_BUTTON, self.OnSave)
- self.btnSave.SetToolTipString(
- _("Apply and save changes to user settings file (default for next sessions)"))
- self.btnSave.SetDefault()
- self.btnCancel.Bind(wx.EVT_BUTTON, self.OnCancel)
- self.btnCancel.SetToolTipString(_("Close dialog and ignore changes"))
- self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
- self._layout()
- def _layout(self):
- """Layout window"""
- # sizers
- btnSizer = wx.BoxSizer(wx.HORIZONTAL)
- btnSizer.Add(item=self.btnDefault, proportion=1,
- flag=wx.ALL, border=5)
- btnStdSizer = wx.StdDialogButtonSizer()
- btnStdSizer.AddButton(self.btnCancel)
- btnStdSizer.AddButton(self.btnSave)
- btnStdSizer.AddButton(self.btnApply)
- btnStdSizer.Realize()
- mainSizer = wx.BoxSizer(wx.VERTICAL)
- mainSizer.Add(
- item=self.notebook,
- proportion=1,
- flag=wx.EXPAND | wx.ALL,
- border=5)
- mainSizer.Add(item=btnSizer, proportion=0,
- flag=wx.EXPAND, border=0)
- mainSizer.Add(item=btnStdSizer, proportion=0,
- flag=wx.EXPAND | wx.ALL | wx.ALIGN_RIGHT, border=5)
- self.SetSizer(mainSizer)
- mainSizer.Fit(self)
- def OnDefault(self, event):
- """Button 'Set to default' pressed"""
- # update widgets
- for gks in self.winId.keys():
- try:
- group, key, subkey = gks.split(':')
- value = self.settings.Get(
- group, key, subkey, settings_type='default')
- except ValueError:
- group, key, subkey, subkey1 = gks.split(':')
- value = self.settings.Get(
- group, key, [subkey, subkey1],
- settings_type='default')
- win = self.FindWindowById(self.winId[gks])
- if win.GetName() in ('GetValue', 'IsChecked'):
- value = win.SetValue(value)
- elif win.GetName() == 'GetSelection':
- value = win.SetSelection(value)
- elif win.GetName() == 'GetStringSelection':
- value = win.SetStringSelection(value)
- elif win.GetName() == 'GetLabel':
- value = win.SetLabel(value)
- else:
- value = win.SetValue(value)
- def OnApply(self, event):
- """Button 'Apply' pressed
- Emits signal settingsChanged.
- """
- if self._updateSettings():
- self._giface.WriteLog(
- _('Settings applied to current session but not saved'))
- self.settingsChanged.emit()
- self.Close()
- def OnCloseWindow(self, event):
- event.Skip()
- self.Destroy()
- def OnCancel(self, event):
- """Button 'Cancel' pressed"""
- self.Close()
- def OnSave(self, event):
- """Button 'Save' pressed
- Emits signal settingsChanged.
- """
- if self._updateSettings():
- lang = self.settings.Get(
- group='language', key='locale', subkey='lc_all')
- if lang == 'system':
- # Most fool proof way to use system locale is to not provide
- # any locale info at all
- self.settings.Set(
- group='language',
- key='locale',
- subkey='lc_all',
- value=None)
- lang = None
- if lang == 'en':
- # GRASS doesn't ship EN translation, default texts have to be
- # used instead
- self.settings.Set(
- group='language',
- key='locale',
- subkey='lc_all',
- value='C')
- lang = 'C'
- self.settings.SaveToFile()
- Debug.msg(
- 1, "Settings saved to file '%s'" %
- self.settings.filePath)
- self.settingsChanged.emit()
- self.Close()
- def _updateSettings(self):
- """Update user settings"""
- for item in self.winId.keys():
- try:
- group, key, subkey = item.split(':')
- subkey1 = None
- except ValueError:
- group, key, subkey, subkey1 = item.split(':')
- id = self.winId[item]
- win = self.FindWindowById(id)
- if win.GetName() == 'GetValue':
- value = win.GetValue()
- elif win.GetName() == 'GetSelection':
- value = win.GetSelection()
- elif win.GetName() == 'IsChecked':
- value = win.IsChecked()
- elif win.GetName() == 'GetStringSelection':
- value = win.GetStringSelection()
- elif win.GetName() == 'GetLabel':
- value = win.GetLabel()
- elif win.GetName() == 'GetColour':
- value = tuple(win.GetValue())
- else:
- value = win.GetValue()
- if key == 'keycolumn' and value == '':
- wx.MessageBox(parent=self,
- message=_("Key column cannot be empty string."),
- caption=_("Error"), style=wx.OK | wx.ICON_ERROR)
- win.SetValue(
- self.settings.Get(
- group='atm',
- key='keycolumn',
- subkey='value'))
- return False
- if subkey1:
- self.settings.Set(group, value, key, [subkey, subkey1])
- else:
- self.settings.Set(group, value, key, subkey)
- return True
- class PreferencesDialog(PreferencesBaseDialog):
- """User preferences dialog"""
- def __init__(self, parent, giface, title=_("GUI Settings"),
- settings=UserSettings):
- PreferencesBaseDialog.__init__(
- self,
- parent=parent,
- giface=giface,
- title=title,
- settings=settings)
- # create notebook pages
- self._createGeneralPage(self.notebook)
- self._createAppearancePage(self.notebook)
- self._createDisplayPage(self.notebook)
- self._createCmdPage(self.notebook)
- self._createLayersPage(self.notebook)
- self._createAttributeManagerPage(self.notebook)
- self._createProjectionPage(self.notebook)
- self.SetMinSize(self.GetBestSize())
- self.SetSize(self.size)
- def _createGeneralPage(self, notebook):
- """Create notebook page for general settings"""
- panel = SP.ScrolledPanel(parent=notebook, id=wx.ID_ANY)
- panel.SetupScrolling(scroll_x=False, scroll_y=True)
- notebook.AddPage(page=panel, text=_("General"))
- border = wx.BoxSizer(wx.VERTICAL)
- #
- # Layer Manager settings
- #
- box = wx.StaticBox(
- parent=panel,
- id=wx.ID_ANY,
- label=" %s " %
- _("Layer Manager settings"))
- sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
- gridSizer = wx.GridBagSizer(hgap=3, vgap=3)
- #
- # ask when removing map layer from layer tree
- #
- row = 0
- askOnRemoveLayer = wx.CheckBox(parent=panel, id=wx.ID_ANY, label=_(
- "Ask when removing map layer from layer tree"), name='IsChecked')
- askOnRemoveLayer.SetValue(
- self.settings.Get(
- group='manager',
- key='askOnRemoveLayer',
- subkey='enabled'))
- self.winId['manager:askOnRemoveLayer:enabled'] = askOnRemoveLayer.GetId()
- gridSizer.Add(item=askOnRemoveLayer,
- pos=(row, 0), span=(1, 2))
- row += 1
- askOnQuit = wx.CheckBox(parent=panel, id=wx.ID_ANY, label=_(
- "Ask when quiting wxGUI or closing display"), name='IsChecked')
- askOnQuit.SetValue(
- self.settings.Get(
- group='manager',
- key='askOnQuit',
- subkey='enabled'))
- self.winId['manager:askOnQuit:enabled'] = askOnQuit.GetId()
- gridSizer.Add(item=askOnQuit,
- pos=(row, 0), span=(1, 2))
- row += 1
- hideSearch = wx.CheckBox(
- parent=panel,
- id=wx.ID_ANY,
- label=_("Hide '%s' tab (requires GUI restart)") %
- _("Modules"),
- name='IsChecked')
- hideSearch.SetValue(
- self.settings.Get(
- group='manager',
- key='hideTabs',
- subkey='search'))
- self.winId['manager:hideTabs:search'] = hideSearch.GetId()
- gridSizer.Add(item=hideSearch,
- pos=(row, 0), span=(1, 2))
- row += 1
- hidePyShell = wx.CheckBox(
- parent=panel,
- id=wx.ID_ANY,
- label=_("Hide '%s' tab (requires GUI restart)") %
- _("Python"),
- name='IsChecked')
- hidePyShell.SetValue(
- self.settings.Get(
- group='manager',
- key='hideTabs',
- subkey='pyshell'))
- self.winId['manager:hideTabs:pyshell'] = hidePyShell.GetId()
- gridSizer.Add(item=hidePyShell,
- pos=(row, 0), span=(1, 2))
- #
- # Selected text is copied to clipboard
- #
- row += 1
- copySelectedTextToClipboard = wx.CheckBox(
- parent=panel, id=wx.ID_ANY,
- label=_(
- "Automatically copy selected text to clipboard (in the Console tab)"),
- name='IsChecked')
- copySelectedTextToClipboard.SetValue(
- self.settings.Get(
- group='manager',
- key='copySelectedTextToClipboard',
- subkey='enabled'))
- self.winId[
- 'manager:copySelectedTextToClipboard:enabled'] = copySelectedTextToClipboard.GetId()
- gridSizer.Add(item=copySelectedTextToClipboard,
- pos=(row, 0), span=(1, 2))
- gridSizer.AddGrowableCol(0)
- sizer.Add(
- item=gridSizer,
- proportion=1,
- flag=wx.ALL | wx.EXPAND,
- border=5)
- border.Add(item=sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=3)
- #
- # workspace
- #
- box = wx.StaticBox(
- parent=panel,
- id=wx.ID_ANY,
- label=" %s " %
- _("Workspace settings"))
- sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
- gridSizer = wx.GridBagSizer(hgap=3, vgap=3)
- row = 0
- posDisplay = wx.CheckBox(parent=panel, id=wx.ID_ANY, label=_(
- "Suppress positioning Map Display Window(s)"), name='IsChecked')
- posDisplay.SetValue(
- self.settings.Get(
- group='general',
- key='workspace',
- subkey=[
- 'posDisplay',
- 'enabled']))
- self.winId['general:workspace:posDisplay:enabled'] = posDisplay.GetId()
- gridSizer.Add(item=posDisplay,
- pos=(row, 0), span=(1, 2))
- row += 1
- posManager = wx.CheckBox(parent=panel, id=wx.ID_ANY, label=_(
- "Suppress positioning Layer Manager window"), name='IsChecked')
- posManager.SetValue(
- self.settings.Get(
- group='general',
- key='workspace',
- subkey=[
- 'posManager',
- 'enabled']))
- self.winId['general:workspace:posManager:enabled'] = posManager.GetId()
- gridSizer.Add(item=posManager,
- pos=(row, 0), span=(1, 2))
- row += 1
- defaultPos = wx.CheckBox(parent=panel, id=wx.ID_ANY, label=_(
- "Save current window layout as default"), name='IsChecked')
- defaultPos.SetValue(
- self.settings.Get(
- group='general',
- key='defWindowPos',
- subkey='enabled'))
- defaultPos.SetToolTip(
- wx.ToolTip(
- _(
- "Save current position and size of Layer Manager window and opened "
- "Map Display window(s) and use as default for next sessions.")))
- self.winId['general:defWindowPos:enabled'] = defaultPos.GetId()
- gridSizer.Add(item=defaultPos,
- pos=(row, 0), span=(1, 2))
- gridSizer.AddGrowableCol(0)
- sizer.Add(
- item=gridSizer,
- proportion=1,
- flag=wx.ALL | wx.EXPAND,
- border=5)
- border.Add(item=sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=3)
- panel.SetSizer(border)
- return panel
- def _createAppearancePage(self, notebook):
- """Create notebook page for display settings"""
- panel = SP.ScrolledPanel(parent=notebook, id=wx.ID_ANY)
- panel.SetupScrolling(scroll_x=False, scroll_y=True)
- notebook.AddPage(page=panel, text=_("Appearance"))
- border = wx.BoxSizer(wx.VERTICAL)
- box = wx.StaticBox(
- parent=panel,
- id=wx.ID_ANY,
- label=" %s " %
- _("Font settings"))
- sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
- gridSizer = wx.GridBagSizer(hgap=3, vgap=3)
- #
- # font settings
- #
- sizer.Add(
- item=gridSizer,
- proportion=1,
- flag=wx.ALL | wx.EXPAND,
- border=5)
- border.Add(item=sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=3)
- row = 0
- gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
- label=_("Font for command output:")),
- flag=wx.ALIGN_LEFT |
- wx.ALIGN_CENTER_VERTICAL,
- pos=(row, 0))
- outfontButton = wx.Button(parent=panel, id=wx.ID_ANY,
- label=_("Set font"))
- gridSizer.Add(item=outfontButton,
- flag=wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL,
- pos=(row, 1))
- gridSizer.AddGrowableCol(0)
- #
- # languages
- #
- box = wx.StaticBox(
- parent=panel,
- id=wx.ID_ANY,
- label=" %s " %
- _("Language settings"))
- sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
- gridSizer = wx.GridBagSizer(hgap=3, vgap=3)
- sizer.Add(
- item=gridSizer,
- proportion=1,
- flag=wx.ALL | wx.EXPAND,
- border=5)
- border.Add(item=sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=3)
- row = 0
- gridSizer.Add(
- item=wx.StaticText(
- parent=panel,
- id=wx.ID_ANY,
- label=_("Choose language (requires to save and GRASS restart):")),
- flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL,
- pos=(
- row,
- 0))
- locales = self.settings.Get(group='language', key='locale',
- subkey='choices', settings_type='internal')
- loc = self.settings.Get(
- group='language',
- key='locale',
- subkey='lc_all')
- elementList = wx.Choice(parent=panel, id=wx.ID_ANY, size=(325, -1),
- choices=locales, name="GetStringSelection")
- if loc in locales:
- elementList.SetStringSelection(loc)
- if loc == 'C':
- elementList.SetStringSelection('en')
- if not loc:
- elementList.SetStringSelection('system')
- self.winId['language:locale:lc_all'] = elementList.GetId()
- gridSizer.Add(item=elementList,
- flag=wx.ALIGN_RIGHT |
- wx.ALIGN_CENTER_VERTICAL,
- pos=(row, 1))
- gridSizer.AddGrowableCol(0)
- #
- # appearence
- #
- box = wx.StaticBox(
- parent=panel,
- id=wx.ID_ANY,
- label=" %s " %
- _("Appearance settings"))
- sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
- gridSizer = wx.GridBagSizer(hgap=3, vgap=3)
- #
- # element list
- #
- row = 0
- gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
- label=_("Element list:")),
- flag=wx.ALIGN_LEFT |
- wx.ALIGN_CENTER_VERTICAL,
- pos=(row, 0))
- elementList = wx.Choice(
- parent=panel, id=wx.ID_ANY, size=(325, -1),
- choices=self.settings.Get(
- group='appearance', key='elementListExpand', subkey='choices',
- settings_type='internal'),
- name="GetSelection")
- elementList.SetSelection(
- self.settings.Get(
- group='appearance',
- key='elementListExpand',
- subkey='selection'))
- self.winId['appearance:elementListExpand:selection'] = elementList.GetId()
- gridSizer.Add(item=elementList,
- flag=wx.ALIGN_RIGHT |
- wx.ALIGN_CENTER_VERTICAL,
- pos=(row, 1))
- #
- # menu style
- #
- row += 1
- gridSizer.Add(
- item=wx.StaticText(
- parent=panel,
- id=wx.ID_ANY,
- label=_("Menu style (requires to save and GUI restart):")),
- flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL,
- pos=(
- row,
- 0))
- listOfStyles = self.settings.Get(
- group='appearance',
- key='menustyle',
- subkey='choices',
- settings_type='internal')
- menuItemText = wx.Choice(parent=panel, id=wx.ID_ANY, size=(325, -1),
- choices=listOfStyles,
- name="GetSelection")
- menuItemText.SetSelection(
- self.settings.Get(
- group='appearance',
- key='menustyle',
- subkey='selection'))
- self.winId['appearance:menustyle:selection'] = menuItemText.GetId()
- gridSizer.Add(item=menuItemText,
- flag=wx.ALIGN_RIGHT,
- pos=(row, 1))
- #
- # gselect.TreeCtrlComboPopup height
- #
- row += 1
- gridSizer.Add(
- item=wx.StaticText(
- parent=panel,
- id=wx.ID_ANY,
- label=_("Height of map selection popup window (in pixels):")),
- flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL,
- pos=(
- row,
- 0))
- min = self.settings.Get(
- group='appearance',
- key='gSelectPopupHeight',
- subkey='min',
- settings_type='internal')
- max = self.settings.Get(
- group='appearance',
- key='gSelectPopupHeight',
- subkey='max',
- settings_type='internal')
- value = self.settings.Get(
- group='appearance',
- key='gSelectPopupHeight',
- subkey='value')
- popupHeightSpin = wx.SpinCtrl(
- parent=panel, id=wx.ID_ANY, size=(100, -1))
- popupHeightSpin.SetRange(min, max)
- popupHeightSpin.SetValue(value)
- self.winId[
- 'appearance:gSelectPopupHeight:value'] = popupHeightSpin.GetId()
- gridSizer.Add(item=popupHeightSpin,
- flag=wx.ALIGN_RIGHT,
- pos=(row, 1))
- #
- # icon theme
- #
- row += 1
- gridSizer.Add(
- item=wx.StaticText(
- parent=panel,
- id=wx.ID_ANY,
- label=_("Icon theme (requires GUI restart):")),
- flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL,
- pos=(
- row,
- 0))
- iconTheme = wx.Choice(
- parent=panel, id=wx.ID_ANY, size=(100, -1),
- choices=self.settings.Get(
- group='appearance', key='iconTheme', subkey='choices',
- settings_type='internal'),
- name="GetStringSelection")
- iconTheme.SetStringSelection(
- self.settings.Get(
- group='appearance',
- key='iconTheme',
- subkey='type'))
- self.winId['appearance:iconTheme:type'] = iconTheme.GetId()
- gridSizer.Add(item=iconTheme,
- flag=wx.ALIGN_RIGHT |
- wx.ALIGN_CENTER_VERTICAL,
- pos=(row, 1))
- #
- # command dialog style
- #
- row += 1
- gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
- label=_("Module dialog style:")),
- flag=wx.ALIGN_LEFT |
- wx.ALIGN_CENTER_VERTICAL,
- pos=(row, 0))
- styleList = wx.Choice(
- parent=panel, id=wx.ID_ANY, size=(325, -1),
- choices=self.settings.Get(
- group='appearance', key='commandNotebook', subkey='choices',
- settings_type='internal'),
- name="GetSelection")
- styleList.SetSelection(
- self.settings.Get(
- group='appearance',
- key='commandNotebook',
- subkey='selection'))
- self.winId['appearance:commandNotebook:selection'] = styleList.GetId()
- gridSizer.Add(item=styleList,
- flag=wx.ALIGN_RIGHT |
- wx.ALIGN_CENTER_VERTICAL,
- pos=(row, 1))
- gridSizer.AddGrowableCol(0)
- sizer.Add(
- item=gridSizer,
- proportion=1,
- flag=wx.ALL | wx.EXPAND,
- border=5)
- border.Add(item=sizer, proportion=0, flag=wx.LEFT |
- wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=3)
- panel.SetSizer(border)
- # bindings
- if sys.platform == 'darwin':
- outfontButton.Bind(wx.EVT_BUTTON, self.OnSetOutputFontCustomDialog)
- else:
- outfontButton.Bind(wx.EVT_BUTTON, self.OnSetOutputFont)
- return panel
- def _createDisplayPage(self, notebook):
- """Create notebook page for display settings"""
- panel = SP.ScrolledPanel(parent=notebook, id=wx.ID_ANY)
- panel.SetupScrolling(scroll_x=False, scroll_y=True)
- notebook.AddPage(page=panel, text=_("Map Display"))
- border = wx.BoxSizer(wx.VERTICAL)
- box = wx.StaticBox(
- parent=panel,
- id=wx.ID_ANY,
- label=" %s " %
- _("Font settings"))
- sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
- gridSizer = wx.GridBagSizer(hgap=3, vgap=3)
- #
- # font settings
- #
- row = 0
- gridSizer.Add(
- item=wx.StaticText(
- parent=panel,
- id=wx.ID_ANY,
- label=_("Default font for GRASS displays:")),
- flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL,
- pos=(
- row,
- 0))
- fontButton = wx.Button(parent=panel, id=wx.ID_ANY,
- label=_("Set font"))
- gridSizer.Add(item=fontButton,
- flag=wx.ALIGN_RIGHT |
- wx.ALIGN_CENTER_VERTICAL,
- pos=(row, 1))
- gridSizer.AddGrowableCol(0)
- sizer.Add(
- item=gridSizer,
- proportion=1,
- flag=wx.ALL | wx.EXPAND,
- border=5)
- border.Add(item=sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=3)
- #
- # display settings
- #
- box = wx.StaticBox(
- parent=panel,
- id=wx.ID_ANY,
- label=" %s " %
- _("Default display settings"))
- sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
- gridSizer = wx.GridBagSizer(hgap=3, vgap=3)
- #
- # display driver
- #
- row = 0
- gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
- label=_("Display driver:")),
- flag=wx.ALIGN_LEFT |
- wx.ALIGN_CENTER_VERTICAL,
- pos=(row, 0))
- listOfDrivers = self.settings.Get(
- group='display', key='driver', subkey='choices',
- settings_type='internal')
- driver = wx.Choice(parent=panel, id=wx.ID_ANY, size=(150, -1),
- choices=listOfDrivers,
- name="GetStringSelection")
- driver.SetStringSelection(
- self.settings.Get(
- group='display',
- key='driver',
- subkey='type'))
- self.winId['display:driver:type'] = driver.GetId()
- gridSizer.Add(item=driver,
- flag=wx.ALIGN_RIGHT,
- pos=(row, 1))
- #
- # Statusbar mode
- #
- row += 1
- gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
- label=_("Statusbar mode:")),
- flag=wx.ALIGN_LEFT |
- wx.ALIGN_CENTER_VERTICAL,
- pos=(row, 0))
- listOfModes = self.settings.Get(
- group='display',
- key='statusbarMode',
- subkey='choices',
- settings_type='internal')
- statusbarMode = wx.Choice(parent=panel, id=wx.ID_ANY, size=(150, -1),
- choices=listOfModes,
- name="GetSelection")
- statusbarMode.SetSelection(
- self.settings.Get(
- group='display',
- key='statusbarMode',
- subkey='selection'))
- self.winId['display:statusbarMode:selection'] = statusbarMode.GetId()
- gridSizer.Add(item=statusbarMode,
- flag=wx.ALIGN_RIGHT,
- pos=(row, 1))
- #
- # Background color
- #
- row += 1
- gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
- label=_("Background color:")),
- flag=wx.ALIGN_LEFT |
- wx.ALIGN_CENTER_VERTICAL,
- pos=(row, 0))
- bgColor = csel.ColourSelect(
- parent=panel,
- id=wx.ID_ANY,
- colour=self.settings.Get(
- group='display',
- key='bgcolor',
- subkey='color'),
- size=globalvar.DIALOG_COLOR_SIZE)
- bgColor.SetName('GetColour')
- self.winId['display:bgcolor:color'] = bgColor.GetId()
- gridSizer.Add(item=bgColor,
- flag=wx.ALIGN_RIGHT,
- pos=(row, 1))
- #
- # Align extent to display size
- #
- row += 1
- alignExtent = wx.CheckBox(parent=panel, id=wx.ID_ANY, label=_(
- "Align region extent based on display size"), name="IsChecked")
- alignExtent.SetValue(
- self.settings.Get(
- group='display',
- key='alignExtent',
- subkey='enabled'))
- self.winId['display:alignExtent:enabled'] = alignExtent.GetId()
- gridSizer.Add(item=alignExtent,
- pos=(row, 0), span=(1, 2))
- #
- # Use computation resolution
- #
- row += 1
- compResolution = wx.CheckBox(parent=panel, id=wx.ID_ANY, label=_(
- "Constrain display resolution to computational settings"), name="IsChecked")
- compResolution.SetValue(
- self.settings.Get(
- group='display',
- key='compResolution',
- subkey='enabled'))
- self.winId['display:compResolution:enabled'] = compResolution.GetId()
- gridSizer.Add(item=compResolution,
- pos=(row, 0), span=(1, 2))
- #
- # auto-rendering
- #
- row += 1
- autoRendering = wx.CheckBox(parent=panel, id=wx.ID_ANY,
- label=_("Enable auto-rendering"),
- name="IsChecked")
- autoRendering.SetValue(
- self.settings.Get(
- group='display',
- key='autoRendering',
- subkey='enabled'))
- self.winId['display:autoRendering:enabled'] = autoRendering.GetId()
- gridSizer.Add(item=autoRendering,
- pos=(row, 0), span=(1, 2))
- #
- # auto-zoom
- #
- row += 1
- autoZooming = wx.CheckBox(parent=panel, id=wx.ID_ANY, label=_(
- "Enable auto-zooming to selected map layer"), name="IsChecked")
- autoZooming.SetValue(
- self.settings.Get(
- group='display',
- key='autoZooming',
- subkey='enabled'))
- self.winId['display:autoZooming:enabled'] = autoZooming.GetId()
- gridSizer.Add(item=autoZooming,
- pos=(row, 0), span=(1, 2))
- #
- # mouse wheel zoom
- #
- row += 1
- gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
- label=_("Mouse wheel action:")),
- flag=wx.ALIGN_LEFT |
- wx.ALIGN_CENTER_VERTICAL,
- pos=(row, 0))
- listOfModes = self.settings.Get(
- group='display',
- key='mouseWheelZoom',
- subkey='choices',
- settings_type='internal')
- zoomAction = wx.Choice(parent=panel, id=wx.ID_ANY, size=(200, -1),
- choices=listOfModes,
- name="GetSelection")
- zoomAction.SetSelection(
- self.settings.Get(
- group='display',
- key='mouseWheelZoom',
- subkey='selection'))
- self.winId['display:mouseWheelZoom:selection'] = zoomAction.GetId()
- gridSizer.Add(item=zoomAction,
- flag=wx.ALIGN_RIGHT,
- pos=(row, 1))
- row += 1
- gridSizer.Add(
- item=wx.StaticText(
- parent=panel,
- id=wx.ID_ANY,
- label=_("Mouse scrolling direction:")),
- flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL,
- pos=(
- row,
- 0))
- listOfModes = self.settings.Get(
- group='display',
- key='scrollDirection',
- subkey='choices',
- settings_type='internal')
- scrollDir = wx.Choice(parent=panel, id=wx.ID_ANY, size=(200, -1),
- choices=listOfModes,
- name="GetSelection")
- scrollDir.SetSelection(
- self.settings.Get(
- group='display',
- key='scrollDirection',
- subkey='selection'))
- self.winId['display:scrollDirection:selection'] = scrollDir.GetId()
- gridSizer.Add(item=scrollDir,
- flag=wx.ALIGN_RIGHT,
- pos=(row, 1))
- gridSizer.AddGrowableCol(0)
- sizer.Add(
- item=gridSizer,
- proportion=1,
- flag=wx.ALL | wx.EXPAND,
- border=5)
- border.Add(item=sizer, proportion=0, flag=wx.LEFT |
- wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=3)
- #
- # advanced
- #
- # see initialization of nviz GLWindow
- if globalvar.CheckWxVersion(version=[2, 8, 11]) and \
- sys.platform not in ('win32', 'darwin'):
- box = wx.StaticBox(
- parent=panel, id=wx.ID_ANY, label=" %s " %
- _("Advanced display settings"))
- sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
- gridSizer = wx.GridBagSizer(hgap=3, vgap=3)
- row = 0
- gridSizer.Add(
- item=wx.StaticText(
- parent=panel,
- id=wx.ID_ANY,
- label=_("3D view depth buffer (possible values are 16, 24, 32):")),
- flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL,
- pos=(
- row,
- 0))
- value = self.settings.Get(
- group='display',
- key='nvizDepthBuffer',
- subkey='value')
- textCtrl = wx.TextCtrl(
- parent=panel,
- id=wx.ID_ANY,
- value=str(value),
- validator=IntegerValidator(),
- name='GetValue')
- self.winId['display:nvizDepthBuffer:value'] = textCtrl.GetId()
- gridSizer.Add(item=textCtrl,
- flag=wx.ALIGN_RIGHT |
- wx.ALIGN_CENTER_VERTICAL,
- pos=(row, 1))
- gridSizer.AddGrowableCol(0)
- sizer.Add(
- item=gridSizer,
- proportion=1,
- flag=wx.ALL | wx.EXPAND,
- border=5)
- border.Add(
- item=sizer,
- proportion=0,
- flag=wx.ALL | wx.EXPAND,
- border=3)
- panel.SetSizer(border)
- # bindings
- fontButton.Bind(wx.EVT_BUTTON, self.OnSetFont)
- zoomAction.Bind(wx.EVT_CHOICE, self.OnEnableWheelZoom)
- # enable/disable controls according to settings
- self.OnEnableWheelZoom(None)
- return panel
- def _createCmdPage(self, notebook):
- """Create notebook page for commad dialog settings"""
- panel = SP.ScrolledPanel(parent=notebook, id=wx.ID_ANY)
- panel.SetupScrolling(scroll_x=False, scroll_y=True)
- notebook.AddPage(page=panel, text=_("Modules"))
- border = wx.BoxSizer(wx.VERTICAL)
- box = wx.StaticBox(
- parent=panel,
- id=wx.ID_ANY,
- label=" %s " %
- _("Module dialog settings"))
- sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
- gridSizer = wx.GridBagSizer(hgap=3, vgap=3)
- #
- # command dialog settings
- #
- row = 0
- # overwrite
- overwrite = wx.CheckBox(parent=panel, id=wx.ID_ANY, label=_(
- "Allow output files to overwrite existing files"), name="IsChecked")
- overwrite.SetValue(
- self.settings.Get(
- group='cmd',
- key='overwrite',
- subkey='enabled'))
- self.winId['cmd:overwrite:enabled'] = overwrite.GetId()
- gridSizer.Add(item=overwrite,
- pos=(row, 0), span=(1, 2))
- row += 1
- # close
- close = wx.CheckBox(
- parent=panel, id=wx.ID_ANY,
- label=_("Close dialog when module is successfully finished"),
- name="IsChecked")
- close.SetValue(
- self.settings.Get(
- group='cmd',
- key='closeDlg',
- subkey='enabled'))
- self.winId['cmd:closeDlg:enabled'] = close.GetId()
- gridSizer.Add(item=close,
- pos=(row, 0), span=(1, 2))
- row += 1
- # add layer
- add = wx.CheckBox(parent=panel, id=wx.ID_ANY,
- label=_("Add created map into layer tree"),
- name="IsChecked")
- add.SetValue(
- self.settings.Get(
- group='cmd',
- key='addNewLayer',
- subkey='enabled'))
- self.winId['cmd:addNewLayer:enabled'] = add.GetId()
- gridSizer.Add(item=add,
- pos=(row, 0), span=(1, 2))
- row += 1
- # interactive input
- interactive = wx.CheckBox(parent=panel, id=wx.ID_ANY,
- label=_("Allow interactive input"),
- name="IsChecked")
- interactive.SetValue(
- self.settings.Get(
- group='cmd',
- key='interactiveInput',
- subkey='enabled'))
- self.winId['cmd:interactiveInput:enabled'] = interactive.GetId()
- gridSizer.Add(item=interactive,
- pos=(row, 0), span=(1, 2))
- row += 1
- # verbosity
- gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
- label=_("Verbosity level:")),
- flag=wx.ALIGN_LEFT |
- wx.ALIGN_CENTER_VERTICAL,
- pos=(row, 0))
- verbosity = wx.Choice(
- parent=panel, id=wx.ID_ANY, size=(200, -1),
- choices=self.settings.Get(
- group='cmd', key='verbosity', subkey='choices',
- settings_type='internal'),
- name="GetStringSelection")
- verbosity.SetStringSelection(
- self.settings.Get(
- group='cmd',
- key='verbosity',
- subkey='selection'))
- self.winId['cmd:verbosity:selection'] = verbosity.GetId()
- gridSizer.Add(item=verbosity,
- pos=(row, 1), flag=wx.ALIGN_RIGHT)
- gridSizer.AddGrowableCol(0)
- sizer.Add(
- item=gridSizer,
- proportion=1,
- flag=wx.ALL | wx.EXPAND,
- border=5)
- border.Add(item=sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=3)
- panel.SetSizer(border)
- return panel
- def _createLayersPage(self, notebook):
- """Create notebook page for layer settings"""
- panel = SP.ScrolledPanel(parent=notebook, id=wx.ID_ANY)
- panel.SetupScrolling(scroll_x=False, scroll_y=True)
- notebook.AddPage(page=panel, text=_("Layers"))
- border = wx.BoxSizer(wx.VERTICAL)
- #
- # raster settings
- #
- box = wx.StaticBox(
- parent=panel,
- id=wx.ID_ANY,
- label=" %s " %
- _("Default raster settings"))
- sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
- gridSizer = wx.GridBagSizer(hgap=3, vgap=3)
- #
- # raster overlay
- #
- row = 0
- rasterOpaque = wx.CheckBox(parent=panel, id=wx.ID_ANY,
- label=_("Make null cells opaque"),
- name='IsChecked')
- rasterOpaque.SetValue(
- self.settings.Get(
- group='rasterLayer',
- key='opaque',
- subkey='enabled'))
- self.winId['rasterLayer:opaque:enabled'] = rasterOpaque.GetId()
- gridSizer.Add(item=rasterOpaque,
- pos=(row, 0), span=(1, 2))
- # default color table
- row += 1
- rasterCTCheck = wx.CheckBox(parent=panel, id=wx.ID_ANY,
- label=_("Default color table"),
- name='IsChecked')
- rasterCTCheck.SetValue(
- self.settings.Get(
- group='rasterLayer',
- key='colorTable',
- subkey='enabled'))
- self.winId['rasterLayer:colorTable:enabled'] = rasterCTCheck.GetId()
- rasterCTCheck.Bind(wx.EVT_CHECKBOX, self.OnCheckColorTable)
- gridSizer.Add(item=rasterCTCheck, flag=wx.ALIGN_CENTER_VERTICAL,
- pos=(row, 0))
- rasterCTName = ColorTablesComboBox(
- parent=panel,
- size=globalvar.DIALOG_COMBOBOX_SIZE,
- choices=GetColorTables(),
- name="GetStringSelection")
- rasterCTName.SetStringSelection(
- self.settings.Get(
- group='rasterLayer',
- key='colorTable',
- subkey='selection'))
- self.winId['rasterLayer:colorTable:selection'] = rasterCTName.GetId()
- if not rasterCTCheck.IsChecked():
- rasterCTName.Enable(False)
- gridSizer.Add(item=rasterCTName,
- pos=(row, 1))
- gridSizer.AddGrowableCol(0)
- sizer.Add(
- item=gridSizer,
- proportion=1,
- flag=wx.ALL | wx.EXPAND,
- border=5)
- border.Add(item=sizer, proportion=0, flag=wx.LEFT |
- wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=3)
- #
- # vector settings
- #
- box = wx.StaticBox(
- parent=panel,
- id=wx.ID_ANY,
- label=" %s " %
- _("Default vector settings"))
- sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
- gridSizer = wx.FlexGridSizer(cols=7, hgap=10, vgap=3)
- gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
- label=_("Display:")),
- flag=wx.ALIGN_CENTER_VERTICAL)
- for type in ('point', 'line', 'centroid', 'boundary',
- 'area', 'face'):
- chkbox = wx.CheckBox(parent=panel, label=type)
- checked = self.settings.Get(group='vectorLayer', key='showType',
- subkey=[type, 'enabled'])
- chkbox.SetValue(checked)
- self.winId[
- 'vectorLayer:showType:%s:enabled' %
- type] = chkbox.GetId()
- gridSizer.Add(item=chkbox)
- sizer.Add(
- item=gridSizer,
- proportion=0,
- flag=wx.ALL | wx.EXPAND,
- border=5)
- row = col = 0
- gridSizer = wx.GridBagSizer(hgap=3, vgap=3)
- # feature color
- gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
- label=_("Feature color:")),
- flag=wx.ALIGN_CENTER_VERTICAL, pos=(row, 0))
- featureColor = csel.ColourSelect(
- parent=panel,
- id=wx.ID_ANY,
- colour=self.settings.Get(
- group='vectorLayer',
- key='featureColor',
- subkey='color'),
- size=globalvar.DIALOG_COLOR_SIZE)
- featureColor.SetName('GetColour')
- self.winId['vectorLayer:featureColor:color'] = featureColor.GetId()
- gridSizer.Add(
- item=featureColor,
- pos=(
- row,
- col + 2),
- flag=wx.ALIGN_RIGHT)
- transpFeature = wx.CheckBox(parent=panel, id=wx.ID_ANY,
- label=_("Transparent"), name="IsChecked")
- transpFeature.SetValue(
- self.settings.Get(
- group='vectorLayer',
- key='featureColor',
- subkey=[
- 'transparent',
- 'enabled']))
- self.winId[
- 'vectorLayer:featureColor:transparent:enabled'] = transpFeature.GetId()
- gridSizer.Add(
- item=transpFeature,
- pos=(
- row,
- col + 1),
- flag=wx.ALIGN_CENTER_VERTICAL)
- # area fill color
- row += 1
- gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
- label=_("Area fill color:")),
- flag=wx.ALIGN_CENTER_VERTICAL, pos=(row, col))
- fillColor = csel.ColourSelect(
- parent=panel,
- id=wx.ID_ANY,
- colour=self.settings.Get(
- group='vectorLayer',
- key='areaFillColor',
- subkey='color'),
- size=globalvar.DIALOG_COLOR_SIZE)
- fillColor.SetName('GetColour')
- self.winId['vectorLayer:areaFillColor:color'] = fillColor.GetId()
- gridSizer.Add(item=fillColor, pos=(row, col + 2), flag=wx.ALIGN_RIGHT)
- transpArea = wx.CheckBox(parent=panel, id=wx.ID_ANY,
- label=_("Transparent"), name="IsChecked")
- transpArea.SetValue(
- self.settings.Get(
- group='vectorLayer',
- key='areaFillColor',
- subkey=[
- 'transparent',
- 'enabled']))
- self.winId[
- 'vectorLayer:areaFillColor:transparent:enabled'] = transpArea.GetId()
- gridSizer.Add(
- item=transpArea, pos=(row, col + 1),
- flag=wx.ALIGN_CENTER_VERTICAL)
- # line
- row += 1
- gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
- label=_("Line width:")),
- flag=wx.ALIGN_CENTER_VERTICAL, pos=(row, col))
- hlWidth = wx.SpinCtrl(
- parent=panel, id=wx.ID_ANY, size=(50, -1),
- initial=self.settings.Get(
- group='vectorLayer', key='line', subkey='width'),
- min=1, max=1e6, name="GetValue")
- self.winId['vectorLayer:line:width'] = hlWidth.GetId()
- gridSizer.Add(
- item=hlWidth, pos=(row, col + 1),
- span=(1, 2),
- flag=wx.ALIGN_RIGHT)
- # symbol
- row = 0
- col = 4
- gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
- label=_("Symbol size:")),
- flag=wx.ALIGN_CENTER_VERTICAL, pos=(row, col))
- ptSize = wx.SpinCtrl(
- parent=panel, id=wx.ID_ANY, size=(50, -1),
- initial=self.settings.Get(
- group='vectorLayer', key='point', subkey='size'),
- min=1, max=1e6, name="GetValue")
- self.winId['vectorLayer:point:size'] = ptSize.GetId()
- gridSizer.Add(item=ptSize, pos=(row, col + 2), flag=wx.ALIGN_RIGHT)
- row += 1
- gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
- label=_("Symbol:")),
- flag=wx.ALIGN_CENTER_VERTICAL, pos=(row, col))
- symbolPath = self.settings.Get(
- group='vectorLayer', key='point', subkey='symbol')
- symbolLabel = wx.StaticText(parent=panel, id=wx.ID_ANY,
- label=symbolPath, name='GetLabel')
- symbolLabel.SetMinSize((150, -1))
- self.winId['vectorLayer:point:symbol'] = symbolLabel.GetId()
- gridSizer.Add(
- item=symbolLabel,
- flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT,
- pos=(
- row,
- col + 1))
- bitmap = wx.Bitmap(
- os.path.join(
- globalvar.SYMBDIR,
- symbolPath) + '.png')
- bb = wx.BitmapButton(
- parent=panel,
- id=wx.ID_ANY,
- bitmap=bitmap,
- name="symbolButton")
- bb.Bind(wx.EVT_BUTTON, self.OnSetSymbol)
- gridSizer.Add(item=bb, pos=(row, col + 2))
- gridSizer.AddGrowableCol(0)
- gridSizer.AddGrowableCol(3)
- sizer.Add(
- item=gridSizer,
- proportion=1,
- flag=wx.ALL | wx.EXPAND,
- border=5)
- border.Add(item=sizer, proportion=0, flag=wx.LEFT |
- wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=3)
- panel.SetSizer(border)
- return panel
- def _createAttributeManagerPage(self, notebook):
- """Create notebook page for 'Attribute Table Manager' settings"""
- panel = SP.ScrolledPanel(parent=notebook, id=wx.ID_ANY)
- panel.SetupScrolling(scroll_x=False, scroll_y=True)
- notebook.AddPage(page=panel, text=_("Attributes"))
- pageSizer = wx.BoxSizer(wx.VERTICAL)
- #
- # highlighting
- #
- highlightBox = wx.StaticBox(
- parent=panel, id=wx.ID_ANY, label=" %s " %
- _("Highlight selected features"))
- highlightSizer = wx.StaticBoxSizer(highlightBox, wx.VERTICAL)
- flexSizer = wx.FlexGridSizer(cols=2, hgap=5, vgap=5)
- flexSizer.AddGrowableCol(0)
- # color
- label = wx.StaticText(parent=panel, id=wx.ID_ANY, label=_("Color:"))
- hlColor = csel.ColourSelect(
- parent=panel,
- id=wx.ID_ANY,
- colour=self.settings.Get(
- group='atm',
- key='highlight',
- subkey='color'),
- size=globalvar.DIALOG_COLOR_SIZE)
- hlColor.SetName('GetColour')
- self.winId['atm:highlight:color'] = hlColor.GetId()
- flexSizer.Add(label, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
- flexSizer.Add(
- hlColor,
- proportion=0,
- flag=wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
- # width
- label = wx.StaticText(
- parent=panel,
- id=wx.ID_ANY,
- label=_("Line width (in pixels):"))
- hlWidth = wx.SpinCtrl(
- parent=panel, id=wx.ID_ANY, size=(50, -1),
- initial=self.settings.Get(
- group='atm', key='highlight', subkey='width'),
- min=1, max=1e6)
- self.winId['atm:highlight:width'] = hlWidth.GetId()
- flexSizer.Add(label, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
- flexSizer.Add(
- hlWidth,
- proportion=0,
- flag=wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
- # auto
- autoHighlight = wx.CheckBox(parent=panel, id=wx.ID_ANY, label=_(
- "Automatically hightlight selected features in map display"))
- autoHighlight.SetValue(
- self.settings.Get(
- group='atm',
- key='highlight',
- subkey='auto'))
- self.winId['atm:highlight:auto'] = autoHighlight.GetId()
- flexSizer.Add(autoHighlight, proportion=1)
- highlightSizer.Add(item=flexSizer,
- proportion=0,
- flag=wx.ALL | wx.EXPAND,
- border=5)
- pageSizer.Add(item=highlightSizer,
- proportion=0,
- flag=wx.ALL | wx.EXPAND,
- border=5)
- #
- # data browser related settings
- #
- dataBrowserBox = wx.StaticBox(parent=panel, id=wx.ID_ANY,
- label=" %s " % _("Data browser"))
- dataBrowserSizer = wx.StaticBoxSizer(dataBrowserBox, wx.VERTICAL)
- flexSizer = wx.FlexGridSizer(cols=2, hgap=5, vgap=5)
- flexSizer.AddGrowableCol(0)
- label = wx.StaticText(
- parent=panel,
- id=wx.ID_ANY,
- label=_("Left mouse double click:"))
- leftDbClick = wx.Choice(
- parent=panel,
- id=wx.ID_ANY,
- choices=self.settings.Get(
- group='atm',
- key='leftDbClick',
- subkey='choices',
- settings_type='internal'),
- name="GetSelection")
- leftDbClick.SetSelection(
- self.settings.Get(
- group='atm',
- key='leftDbClick',
- subkey='selection'))
- self.winId['atm:leftDbClick:selection'] = leftDbClick.GetId()
- flexSizer.Add(label, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
- flexSizer.Add(
- leftDbClick,
- proportion=0,
- flag=wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
- # encoding
- label = wx.StaticText(parent=panel, id=wx.ID_ANY, label=_(
- "Encoding (e.g. utf-8, ascii, iso8859-1, koi8-r):"))
- encoding = wx.TextCtrl(
- parent=panel, id=wx.ID_ANY, value=self.settings.Get(
- group='atm', key='encoding', subkey='value'), name="GetValue", size=(
- 200, -1))
- self.winId['atm:encoding:value'] = encoding.GetId()
- flexSizer.Add(label, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
- flexSizer.Add(
- encoding,
- proportion=0,
- flag=wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
- # ask on delete record
- askOnDeleteRec = wx.CheckBox(parent=panel, id=wx.ID_ANY, label=_(
- "Ask when deleting data record(s) from table"), name='IsChecked')
- askOnDeleteRec.SetValue(
- self.settings.Get(
- group='atm',
- key='askOnDeleteRec',
- subkey='enabled'))
- self.winId['atm:askOnDeleteRec:enabled'] = askOnDeleteRec.GetId()
- flexSizer.Add(askOnDeleteRec, proportion=0)
- dataBrowserSizer.Add(item=flexSizer,
- proportion=0,
- flag=wx.ALL | wx.EXPAND,
- border=5)
- pageSizer.Add(item=dataBrowserSizer,
- proportion=0,
- flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND,
- border=3)
- #
- # create table
- #
- createTableBox = wx.StaticBox(parent=panel, id=wx.ID_ANY,
- label=" %s " % _("Create table"))
- createTableSizer = wx.StaticBoxSizer(createTableBox, wx.VERTICAL)
- flexSizer = wx.FlexGridSizer(cols=2, hgap=5, vgap=5)
- flexSizer.AddGrowableCol(0)
- label = wx.StaticText(parent=panel, id=wx.ID_ANY,
- label=_("Key column:"))
- keyColumn = wx.TextCtrl(parent=panel, id=wx.ID_ANY,
- size=(250, -1))
- keyColumn.SetValue(
- self.settings.Get(
- group='atm',
- key='keycolumn',
- subkey='value'))
- self.winId['atm:keycolumn:value'] = keyColumn.GetId()
- flexSizer.Add(label, proportion=0, flag=wx.ALIGN_CENTER_VERTICAL)
- flexSizer.Add(
- keyColumn,
- proportion=0,
- flag=wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
- createTableSizer.Add(item=flexSizer,
- proportion=0,
- flag=wx.ALL | wx.EXPAND,
- border=5)
- pageSizer.Add(item=createTableSizer,
- proportion=0,
- flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND,
- border=3)
- panel.SetSizer(pageSizer)
- return panel
- def _createProjectionPage(self, notebook):
- """Create notebook page for workspace settings"""
- panel = SP.ScrolledPanel(parent=notebook, id=wx.ID_ANY)
- panel.SetupScrolling(scroll_x=False, scroll_y=True)
- notebook.AddPage(page=panel, text=_("Projection"))
- border = wx.BoxSizer(wx.VERTICAL)
- #
- # projections statusbar settings
- #
- box = wx.StaticBox(
- parent=panel, id=wx.ID_ANY, label=" %s " %
- _("Projection statusbar settings"))
- sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
- gridSizer = wx.GridBagSizer(hgap=3, vgap=3)
- # note for users expecting on-the-fly data reprojection
- row = 0
- note0 = wx.StaticText(
- parent=panel, id=wx.ID_ANY, label=_(
- "\nNote: This only controls the coordinates "
- "displayed in the lower-left of the Map "
- "Display\nwindow's status bar. It is purely "
- "cosmetic and does not affect the working "
- "location's\nprojection in any way. You will "
- "need to enable the Projection check box in "
- "the drop-down\nmenu located at the bottom "
- "of the Map Display window.\n"))
- gridSizer.Add(item=note0,
- span=(1, 2),
- pos=(row, 0))
- # epsg
- row += 1
- label = wx.StaticText(parent=panel, id=wx.ID_ANY,
- label=_("EPSG code:"))
- epsgCode = wx.ComboBox(parent=panel, id=wx.ID_ANY,
- name="GetValue",
- size=(150, -1))
- self.epsgCodeDict = dict()
- epsgCode.SetValue(str(self.settings.Get(
- group='projection', key='statusbar', subkey='epsg')))
- self.winId['projection:statusbar:epsg'] = epsgCode.GetId()
- gridSizer.Add(item=label,
- pos=(row, 0),
- flag=wx.ALIGN_CENTER_VERTICAL)
- gridSizer.Add(item=epsgCode,
- pos=(row, 1), span=(1, 2))
- # proj
- row += 1
- label = wx.StaticText(parent=panel, id=wx.ID_ANY,
- label=_("Proj.4 string (required):"))
- projString = wx.TextCtrl(
- parent=panel, id=wx.ID_ANY, value=self.settings.Get(
- group='projection', key='statusbar', subkey='proj4'), name="GetValue", size=(
- 400, -1))
- self.winId['projection:statusbar:proj4'] = projString.GetId()
- gridSizer.Add(item=label,
- pos=(row, 0),
- flag=wx.ALIGN_CENTER_VERTICAL)
- gridSizer.Add(item=projString,
- pos=(row, 1), span=(1, 2),
- flag=wx.ALIGN_CENTER_VERTICAL)
- # epsg file
- row += 1
- label = wx.StaticText(parent=panel, id=wx.ID_ANY,
- label=_("EPSG file:"))
- projFile = wx.TextCtrl(
- parent=panel, id=wx.ID_ANY, value=self.settings.Get(
- group='projection', key='statusbar', subkey='projFile'),
- name="GetValue", size=(400, -1))
- self.winId['projection:statusbar:projFile'] = projFile.GetId()
- gridSizer.Add(item=label,
- pos=(row, 0),
- flag=wx.ALIGN_CENTER_VERTICAL)
- gridSizer.Add(item=projFile,
- pos=(row, 1),
- flag=wx.ALIGN_CENTER_VERTICAL)
- # note + button
- row += 1
- note = wx.StaticText(
- parent=panel, id=wx.ID_ANY, label=_(
- "Load EPSG codes (be patient), enter EPSG code or "
- "insert Proj.4 string directly."))
- gridSizer.Add(item=note,
- span=(1, 2),
- pos=(row, 0))
- row += 1
- epsgLoad = wx.Button(parent=panel, id=wx.ID_ANY,
- label=_("&Load EPSG codes"))
- gridSizer.Add(item=epsgLoad,
- flag=wx.ALIGN_RIGHT,
- pos=(row, 1))
- gridSizer.AddGrowableCol(1)
- sizer.Add(
- item=gridSizer,
- proportion=1,
- flag=wx.ALL | wx.EXPAND,
- border=5)
- border.Add(item=sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=3)
- #
- # format
- #
- box = wx.StaticBox(
- parent=panel,
- id=wx.ID_ANY,
- label=" %s " %
- _("Coordinates format"))
- sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
- gridSizer = wx.GridBagSizer(hgap=3, vgap=3)
- row = 0
- # ll format
- ll = wx.RadioBox(parent=panel, id=wx.ID_ANY,
- label=" %s " % _("Lat/long projections"),
- choices=["DMS", "DEG"],
- name="GetStringSelection")
- self.winId['projection:format:ll'] = ll.GetId()
- if self.settings.Get(group='projection',
- key='format', subkey='ll') == 'DMS':
- ll.SetSelection(0)
- else:
- ll.SetSelection(1)
- # precision
- precision = wx.SpinCtrl(parent=panel, id=wx.ID_ANY,
- min=0, max=12,
- name="GetValue")
- precision.SetValue(int(self.settings.Get(
- group='projection', key='format', subkey='precision')))
- self.winId['projection:format:precision'] = precision.GetId()
- gridSizer.Add(item=ll,
- pos=(row, 0))
- gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
- label=_("Precision:")),
- flag=wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT | wx.LEFT,
- border=20,
- pos=(row, 1))
- gridSizer.Add(item=precision,
- flag=wx.ALIGN_CENTER_VERTICAL,
- pos=(row, 2))
- gridSizer.AddGrowableCol(2)
- sizer.Add(
- item=gridSizer,
- proportion=1,
- flag=wx.ALL | wx.EXPAND,
- border=5)
- border.Add(item=sizer, proportion=0, flag=wx.LEFT |
- wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=3)
- panel.SetSizer(border)
- # bindings
- epsgLoad.Bind(wx.EVT_BUTTON, self.OnLoadEpsgCodes)
- epsgCode.Bind(wx.EVT_COMBOBOX, self.OnSetEpsgCode)
- epsgCode.Bind(wx.EVT_TEXT_ENTER, self.OnSetEpsgCode)
- return panel
- def _updateSettings(self):
- if not PreferencesBaseDialog._updateSettings(self):
- return False
- #
- # update default window dimension
- #
- if self.settings.Get(
- group='general', key='defWindowPos', subkey='enabled') is True:
- dim = ''
- # layer manager
- pos = self.parent.GetPosition()
- size = self.parent.GetSize()
- dim = '%d,%d,%d,%d' % (pos[0], pos[1], size[0], size[1])
- # opened displays
- for mapdisp in self._giface.GetAllMapDisplays():
- pos = mapdisp.GetPosition()
- size = mapdisp.GetSize()
- # window size must be larger than zero, not minimized
- if not mapdisp.IsIconized() and (size[0] > 0 and size[1] > 0):
- dim += ',%d,%d,%d,%d' % (pos[0], pos[1], size[0], size[1])
- self.settings.Set(
- group='general',
- key='defWindowPos',
- subkey='dim',
- value=dim)
- return True
- def OnCheckColorTable(self, event):
- """Set/unset default color table"""
- win = self.FindWindowById(
- self.winId['rasterLayer:colorTable:selection'])
- if event.IsChecked():
- win.Enable()
- else:
- win.Enable(False)
- def OnLoadEpsgCodes(self, event):
- """Load EPSG codes from the file"""
- win = self.FindWindowById(self.winId['projection:statusbar:projFile'])
- path = win.GetValue()
- epsgCombo = self.FindWindowById(
- self.winId['projection:statusbar:epsg'])
- wx.BeginBusyCursor()
- try:
- self.epsgCodeDict = ReadEpsgCodes(path)
- except OpenError as e:
- wx.EndBusyCursor()
- epsgCombo.SetItems([])
- GError(
- parent=self,
- message=_("Unable to read EPGS codes: {}").format(e),
- showTraceback=False)
- return
- if isinstance(self.epsgCodeDict, type('')):
- wx.MessageBox(
- parent=self,
- message=_("Unable to read EPSG codes: %s") %
- self.epsgCodeDict,
- caption=_("Error"),
- style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
- self.epsgCodeDict = dict()
- epsgCombo.SetItems([])
- epsgCombo.SetValue('')
- self.FindWindowById(
- self.winId['projection:statusbar:proj4']).SetValue('')
- wx.EndBusyCursor()
- return
- choices = map(str, sorted(self.epsgCodeDict.keys()))
- epsgCombo.SetItems(choices)
- wx.EndBusyCursor()
- code = 4326 # default
- win = self.FindWindowById(self.winId['projection:statusbar:proj4'])
- if code in self.epsgCodeDict:
- epsgCombo.SetStringSelection(str(code))
- win.SetValue(self.epsgCodeDict[code][1].replace('<>', '').strip())
- else:
- epsgCombo.SetSelection(0)
- code = int(epsgCombo.GetStringSelection())
- win.SetValue(self.epsgCodeDict[code][1].replace('<>', '').strip())
- def OnSetEpsgCode(self, event):
- """EPSG code selected"""
- winCode = self.FindWindowById(event.GetId())
- win = self.FindWindowById(self.winId['projection:statusbar:proj4'])
- if not self.epsgCodeDict:
- wx.MessageBox(
- parent=self,
- message=_("EPSG code %s not found") %
- event.GetString(),
- caption=_("Error"),
- style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
- winCode.SetValue('')
- win.SetValue('')
- try:
- code = int(event.GetString())
- except ValueError:
- wx.MessageBox(
- parent=self,
- message=_("EPSG code %s not found") %
- str(code),
- caption=_("Error"),
- style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
- winCode.SetValue('')
- win.SetValue('')
- try:
- win.SetValue(self.epsgCodeDict[code][1].replace('<>', '').strip())
- except KeyError:
- wx.MessageBox(
- parent=self,
- message=_("EPSG code %s not found") %
- str(code),
- caption=_("Error"),
- style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
- winCode.SetValue('')
- win.SetValue('')
- def OnSetFont(self, event):
- """'Set font' button pressed"""
- dlg = DefaultFontDialog(parent=self,
- title=_('Select default display font'),
- style=wx.DEFAULT_DIALOG_STYLE,
- type='font')
- if dlg.ShowModal() == wx.ID_OK:
- # set default font and encoding environmental variables
- if dlg.font:
- try:
- os.environ["GRASS_FONT"] = str(dlg.font)
- self.settings.Set(group='display', value=dlg.font,
- key='font', subkey='type')
- except UnicodeEncodeError:
- GError(
- parent=self, message=_(
- "Failed to set default display font. "
- "Try different font."), showTraceback=True)
- dlg.Destroy()
- return
- if dlg.encoding and \
- dlg.encoding != "ISO-8859-1":
- os.environ["GRASS_ENCODING"] = dlg.encoding
- self.settings.Set(group='display', value=dlg.encoding,
- key='font', subkey='encoding')
- dlg.Destroy()
- event.Skip()
- def OnSetOutputFontCustomDialog(self, event):
- """Set font for command console using the custom dialog
- (native is crashing on Mac)"""
- dlg = DefaultFontDialog(parent=self,
- title=_('Select default output font'),
- style=wx.DEFAULT_DIALOG_STYLE,
- type='outputfont')
- if dlg.ShowModal() == wx.ID_OK:
- # set output font and font size variables
- if dlg.font:
- self.settings.Set(group='appearance', value=dlg.font,
- key='outputfont', subkey='type')
- self.settings.Set(group='appearance', value=dlg.fontsize,
- key='outputfont', subkey='size')
- dlg.Destroy()
- def OnSetOutputFont(self, event):
- """'Set output font' button pressed
- """
- type = self.settings.Get(
- group='appearance',
- key='outputfont',
- subkey='type')
- size = self.settings.Get(
- group='appearance',
- key='outputfont',
- subkey='size')
- if size is None or size == 0:
- size = 11
- size = float(size)
- if type is None or type == '':
- type = 'Courier'
- outfont = wx.Font(
- size,
- wx.FONTFAMILY_MODERN,
- wx.NORMAL,
- wx.FONTWEIGHT_NORMAL,
- faceName=type)
- fontdata = wx.FontData()
- fontdata.EnableEffects(True)
- fontdata.SetColour('black')
- fontdata.SetInitialFont(outfont)
- dlg = wx.FontDialog(self, fontdata)
- 'FIXME: native font dialog does not initialize with current font'
- if dlg.ShowModal() == wx.ID_OK:
- outdata = dlg.GetFontData()
- font = outdata.GetChosenFont()
- self.settings.Set(group='appearance', value=font.GetFaceName(),
- key='outputfont', subkey='type')
- self.settings.Set(group='appearance', value=font.GetPointSize(),
- key='outputfont', subkey='size')
- dlg.Destroy()
- event.Skip()
- def OnSetSymbol(self, event):
- """Opens symbol dialog"""
- winId = self.winId['vectorLayer:point:symbol']
- label = self.FindWindowById(winId)
- bb = self.FindWindowByName('symbolButton')
- dlg = SymbolDialog(self, symbolPath=globalvar.SYMBDIR,
- currentSymbol=label.GetLabel())
- if dlg.ShowModal() == wx.ID_OK:
- img = dlg.GetSelectedSymbolPath()
- label.SetLabel(dlg.GetSelectedSymbolName())
- bb.SetBitmapLabel(wx.Bitmap(img + '.png'))
- def OnEnableWheelZoom(self, event):
- """Enable/disable wheel zoom mode control"""
- choiceId = self.winId['display:mouseWheelZoom:selection']
- choice = self.FindWindowById(choiceId)
- if choice.GetSelection() == 2:
- enable = False
- else:
- enable = True
- scrollId = self.winId['display:scrollDirection:selection']
- self.FindWindowById(scrollId).Enable(enable)
- class MapsetAccess(wx.Dialog):
- """Controls setting options and displaying/hiding map overlay
- decorations
- """
- def __init__(self, parent, id=wx.ID_ANY,
- title=_('Manage access to mapsets'),
- size=(350, 400),
- style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, **kwargs):
- wx.Dialog.__init__(self, parent, id, title, size=size, style=style)
- self.all_mapsets_ordered = ListOfMapsets(get='ordered')
- self.accessible_mapsets = ListOfMapsets(get='accessible')
- self.curr_mapset = grass.gisenv()['MAPSET']
- # make a checklistbox from available mapsets and check those that are
- # active
- sizer = wx.BoxSizer(wx.VERTICAL)
- label = wx.StaticText(
- parent=self, id=wx.ID_ANY, label=_(
- "Check a mapset to make it accessible, uncheck it to hide it.\n"
- " Notes:\n"
- " - The current mapset is always accessible.\n"
- " - You may only write to the current mapset.\n"
- " - You may only write to mapsets which you own."))
- sizer.Add(item=label, proportion=0,
- flag=wx.ALL, border=5)
- self.mapsetlb = CheckListMapset(parent=self)
- self.mapsetlb.LoadData()
- sizer.Add(item=self.mapsetlb, proportion=1,
- flag=wx.ALL | wx.EXPAND, border=5)
- # check all accessible mapsets
- for mset in self.accessible_mapsets:
- self.mapsetlb.CheckItem(self.all_mapsets_ordered.index(mset), True)
- # FIXME (howto?): grey-out current mapset
- #self.mapsetlb.Enable(0, False)
- # dialog buttons
- line = wx.StaticLine(parent=self, id=wx.ID_ANY,
- style=wx.LI_HORIZONTAL)
- sizer.Add(item=line, proportion=0,
- flag=wx.EXPAND | wx.ALIGN_CENTRE | wx.ALL, border=5)
- btnsizer = wx.StdDialogButtonSizer()
- okbtn = wx.Button(self, wx.ID_OK)
- okbtn.SetDefault()
- btnsizer.AddButton(okbtn)
- cancelbtn = wx.Button(self, wx.ID_CANCEL)
- btnsizer.AddButton(cancelbtn)
- btnsizer.Realize()
- sizer.Add(item=btnsizer, proportion=0,
- flag=wx.EXPAND | wx.ALIGN_RIGHT | wx.ALL, border=5)
- # do layout
- self.Layout()
- self.SetSizer(sizer)
- sizer.Fit(self)
- self.SetMinSize(size)
- def GetMapsets(self):
- """Get list of checked mapsets"""
- ms = []
- i = 0
- for mset in self.all_mapsets_ordered:
- if self.mapsetlb.IsChecked(i):
- ms.append(mset)
- i += 1
- return ms
- class CheckListMapset(
- wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.CheckListCtrlMixin):
- """List of mapset/owner/group"""
- def __init__(self, parent, log=None):
- self.parent = parent
- wx.ListCtrl.__init__(self, parent, wx.ID_ANY,
- style=wx.LC_REPORT)
- listmix.CheckListCtrlMixin.__init__(self)
- self.log = log
- # setup mixins
- listmix.ListCtrlAutoWidthMixin.__init__(self)
- def LoadData(self):
- """Load data into list"""
- self.InsertColumn(0, _('Mapset'))
- self.InsertColumn(1, _('Owner'))
- ### self.InsertColumn(2, _('Group'))
- gisenv = grass.gisenv()
- locationPath = os.path.join(
- gisenv['GISDBASE'],
- gisenv['LOCATION_NAME'])
- for mapset in self.parent.all_mapsets_ordered:
- index = self.InsertStringItem(self.GetItemCount(), mapset)
- mapsetPath = os.path.join(locationPath,
- mapset)
- stat_info = os.stat(mapsetPath)
- if havePwd:
- try:
- self.SetStringItem(
- index, 1, "%s" %
- pwd.getpwuid(
- stat_info.st_uid)[0])
- except KeyError:
- self.SetStringItem(index, 1, "nobody")
- # FIXME: get group name
- ### self.SetStringItem(index, 2, "%-8s" % stat_info.st_gid)
- else:
- # FIXME: no pwd under MS Windows (owner: 0, group: 0)
- self.SetStringItem(index, 1, "%-8s" % stat_info.st_uid)
- ### self.SetStringItem(index, 2, "%-8s" % stat_info.st_gid)
- self.SetColumnWidth(col=0, width=wx.LIST_AUTOSIZE)
- ### self.SetColumnWidth(col = 1, width = wx.LIST_AUTOSIZE)
- def OnCheckItem(self, index, flag):
- """Mapset checked/unchecked"""
- mapset = self.parent.all_mapsets_ordered[index]
- if mapset == self.parent.curr_mapset:
- self.CheckItem(index, True)
|