[GRASS-SVN] r46402 - in grass/branches/develbranch_6/gui/wxpython:
. gui_modules icons
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue May 24 06:46:51 EDT 2011
Author: martinl
Date: 2011-05-24 03:46:51 -0700 (Tue, 24 May 2011)
New Revision: 46402
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/menu.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py
grass/branches/develbranch_6/gui/wxpython/icons/icon.py
grass/branches/develbranch_6/gui/wxpython/wxgui.py
Log:
wxGUI: menu customization implemented by Vaclav Petras (CTU in Prague)
during GRASS Community Sprint in Prague 2011
(merge r46397 from trunk)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py 2011-05-23 23:56:42 UTC (rev 46401)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py 2011-05-24 10:46:51 UTC (rev 46402)
@@ -999,10 +999,10 @@
settings = preferences.Settings()
- typeface = settings.Get(group='display', key='outputfont', subkey='type')
+ typeface = settings.Get(group='appearance', key='outputfont', subkey='type')
if typeface == "": typeface = "Courier New"
- typesize = settings.Get(group='display', key='outputfont', subkey='size')
+ typesize = settings.Get(group='appearance', key='outputfont', subkey='size')
if typesize == None or typesize <= 0: typesize = 10
typesize = float(typesize)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py 2011-05-23 23:56:42 UTC (rev 46401)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py 2011-05-24 10:46:51 UTC (rev 46402)
@@ -26,6 +26,7 @@
@author Michael Barton
@author Martin Landa <landa.martin gmail.com>
+ at author Vaclav Petras <wenzeslaus gmail.com> (menu customization)
"""
import os
@@ -237,7 +238,10 @@
self.seltree.SelectItem(found)
def GetAdjustedSize(self, minWidth, prefHeight, maxHeight):
- return wx.Size(minWidth, min(200, maxHeight))
+ """!Reads UserSettings to get height (which was 200 in old implementation).
+ """
+ height = UserSettings.Get(group = 'appearance', key = 'gSelectPopupHeight', subkey = 'value')
+ return wx.Size(minWidth, min(height, maxHeight))
def _getElementList(self, element, mapsets = None, elements = None, exclude = False):
"""!Get list of GIS elements in accessible mapsets and display as tree
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/menu.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/menu.py 2011-05-23 23:56:42 UTC (rev 46401)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/menu.py 2011-05-24 10:46:51 UTC (rev 46402)
@@ -11,6 +11,10 @@
(>=v2). Read the file COPYING that comes with GRASS for details.
@author Martin Landa <landa.martin gmail.com>
+ at author Pawel Netzel (menu customization)
+ at author Milena Nowotarska (menu customization)
+ at author Robert Szczepanek (menu customization)
+ at author Vaclav Petras <wenzeslaus gmail.com> (menu customization)
"""
import wx
@@ -18,6 +22,8 @@
import globalvar
import utils
+from preferences import globalSettings as UserSettings
+
class Menu(wx.MenuBar):
def __init__(self, parent, data):
"""!Creates menubar"""
@@ -26,6 +32,8 @@
self.menudata = data
self.menucmd = dict()
+ self.menustyle = UserSettings.Get(group='appearance', key='menustyle', subkey='selection')
+
for eachMenuData in self.menudata.GetMenu():
for eachHeading in eachMenuData:
menuLabel = eachHeading[0]
@@ -41,21 +49,28 @@
subMenu = self._createMenu(eachItem[1])
menu.AppendMenu(wx.ID_ANY, label, subMenu)
else:
- self._createMenuItem(menu, *eachItem)
+ self._createMenuItem(menu, *eachItem, menustyle = self.menustyle)
self.parent.Bind(wx.EVT_MENU_HIGHLIGHT_ALL, self.OnMenuHighlight)
return menu
def _createMenuItem(self, menu, label, help, handler, gcmd, keywords,
- shortcut = '', kind = wx.ITEM_NORMAL):
- """!Creates menu items"""
+ shortcut = '', kind = wx.ITEM_NORMAL, menustyle = 0):
+ """!Creates menu items
+ There are three menu styles (menu item text styles).
+ 1 -- label only, 2 -- label and cmd name, 3 -- cmd name only
+ """
if not label:
menu.AppendSeparator()
return
if len(gcmd) > 0:
helpString = gcmd + ' -- ' + help
+ if menustyle == 1:
+ label += ' [' + gcmd + ']'
+ elif menustyle == 2:
+ label = ' [' + gcmd + ']'
else:
helpString = help
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py 2011-05-23 23:56:42 UTC (rev 46401)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/preferences.py 2011-05-24 10:46:51 UTC (rev 46402)
@@ -4,6 +4,9 @@
@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:
- Settings
@@ -20,6 +23,7 @@
@author Michael Barton (Arizona State University)
@author Martin Landa <landa.martin gmail.com>
+ at author Vaclav Petras <wenzeslaus gmail.com> (menu customization)
"""
import os
@@ -49,6 +53,10 @@
import globalvar
from debug import Debug as Debug
+from wx.lib.newevent import NewEvent
+
+wxSettingsChanged, EVT_SETTINGS_CHANGED = NewEvent()
+
class Settings:
"""!Generic class where to store settings"""
def __init__(self):
@@ -106,6 +114,24 @@
},
},
#
+ # appearance
+ #
+ 'appearance': {
+ 'outputfont' : {
+ 'type' : 'Courier New',
+ 'size': '10',
+ },
+ 'menustyle' : {
+ 'selection' : 1
+ },
+ 'gSelectPopupHeight' : {
+ 'value' : 200
+ },
+ 'iconTheme' : {
+ 'type' : 'grass2'
+ }, # grass2, grass, silk
+ },
+ #
# display
#
'display': {
@@ -113,10 +139,6 @@
'type' : '',
'encoding': 'ISO-8859-1',
},
- 'outputfont' : {
- 'type' : 'Courier New',
- 'size': '10',
- },
'driver': {
'type': 'default'
},
@@ -151,17 +173,6 @@
},
},
#
- # advanced
- #
- 'advanced' : {
- 'settingsFile' : {
- 'type' : 'home'
- }, # home, gisdbase, location, mapset
- 'iconTheme' : {
- 'type' : 'grass2'
- }, # grass2, grass, silk
- },
- #
# Attribute Table Manager
#
'atm' : {
@@ -624,16 +635,22 @@
_("Expand all"))
self.internalSettings['atm']['leftDbClick']['choices'] = (_('Edit selected record'),
_('Display selected'))
- self.internalSettings['advanced']['settingsFile']['choices'] = ('home',
- 'gisdbase',
- 'location',
- 'mapset')
- self.internalSettings['advanced']['iconTheme']['choices'] = ('grass',
- 'grass2',
- 'silk')
+
self.internalSettings['cmd']['verbosity']['choices'] = ('grassenv',
'verbose',
'quiet')
+
+ self.internalSettings['appearance']['iconTheme']['choices'] = ('grass',
+ 'grass2',
+ 'silk')
+ self.internalSettings['appearance']['menustyle']['choices'] = \
+ (_("Classic (labels only)"),
+ _("Combined (labels and module names)"),
+ _("Professional (module names only)"))
+ self.internalSettings['appearance']['gSelectPopupHeight']['min'] = 50
+ # there is also maxHeight given to TreeCtrlComboPopup.GetAdjustedSize
+ self.internalSettings['appearance']['gSelectPopupHeight']['max'] = 1000
+
self.internalSettings['display']['driver']['choices'] = ['default']
self.internalSettings['display']['statusbarMode']['choices'] = globalvar.MAP_DISPLAY_STATUSBAR_MODE
@@ -736,26 +753,10 @@
if settings is None:
settings = self.userSettings
- loc = self.Get(group='advanced', key='settingsFile', subkey='type')
home = os.path.expanduser("~") # MS Windows fix ?
- gisenv = grass.gisenv()
- gisdbase = gisenv['GISDBASE']
- location_name = gisenv['LOCATION_NAME']
- mapset_name = gisenv['MAPSET']
- filePath = None
- if loc == 'home':
- filePath = os.path.join(home, self.fileName)
- elif loc == 'gisdbase':
- filePath = os.path.join(gisdbase, self.fileName)
- elif loc == 'location':
- filePath = os.path.join(gisdbase, location_name, self.fileName)
- elif loc == 'mapset':
- filePath = os.path.join(gisdbase, location_name, mapset_name, self.fileName)
+ filePath = os.path.join(home, self.fileName)
- if filePath is None:
- raise gcmd.SettingsError(_('Uknown settings file location.'))
-
try:
file = open(filePath, "w")
for group in settings.keys():
@@ -1018,9 +1019,13 @@
value = win.SetValue(value)
def OnApply(self, event):
- """!Button 'Apply' pressed"""
+ """!Button 'Apply' pressed
+ Posts event EVT_SETTINGS_CHANGED.
+ """
if self._updateSettings():
self.parent.goutput.WriteLog(_('Settings applied to current session but not saved'))
+ event = wxSettingsChanged()
+ wx.PostEvent(self, event)
self.Close()
def OnCloseWindow(self, event):
@@ -1031,10 +1036,14 @@
self.Close()
def OnSave(self, event):
- """!Button 'Save' pressed"""
+ """!Button 'Save' pressed
+ Posts event EVT_SETTINGS_CHANGED.
+ """
if self._updateSettings():
file = self.settings.SaveToFile()
self.parent.goutput.WriteLog(_('Settings saved to file \'%s\'.') % file)
+ event = wxSettingsChanged()
+ wx.PostEvent(self, event)
self.Close()
def _updateSettings(self):
@@ -1077,7 +1086,7 @@
class PreferencesDialog(PreferencesBaseDialog):
"""!User preferences dialog"""
- def __init__(self, parent, title = _("GUI settings"),
+ def __init__(self, parent, title = _("GUI Settings"),
settings = globalSettings):
PreferencesBaseDialog.__init__(self, parent = parent, title = title,
@@ -1085,12 +1094,12 @@
# create notebook pages
self._CreateGeneralPage(self.notebook)
+ self._CreateAppearancePage(self.notebook)
self._CreateDisplayPage(self.notebook)
self._CreateCmdPage(self.notebook)
self._CreateAttributeManagerPage(self.notebook)
self._CreateProjectionPage(self.notebook)
self._CreateWorkspacePage(self.notebook)
- self._CreateAdvancedPage(self.notebook)
self.SetMinSize(self.GetBestSize())
self.SetSize(self.size)
@@ -1180,6 +1189,7 @@
gridSizer.Add(item=askOnQuit,
pos=(row, 0), span=(1, 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)
@@ -1187,11 +1197,11 @@
return panel
- def _CreateDisplayPage(self, notebook):
+ def _CreateAppearancePage(self, notebook):
"""!Create notebook page for display settings"""
panel = wx.Panel(parent=notebook, id=wx.ID_ANY)
- notebook.AddPage(page=panel, text=_("Display"))
+ notebook.AddPage(page=panel, text=_("Appearance"))
border = wx.BoxSizer(wx.VERTICAL)
@@ -1204,35 +1214,154 @@
#
# 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=_("Default font for GRASS displays:")),
+ label=_("Font for command output:")),
flag=wx.ALIGN_LEFT |
wx.ALIGN_CENTER_VERTICAL,
pos=(row, 0))
- fontButton = wx.Button(parent=panel, id=wx.ID_ANY,
+ outfontButton = wx.Button(parent=panel, id=wx.ID_ANY,
label=_("Set font"), size=(100, -1))
- gridSizer.Add(item=fontButton,
+ gridSizer.Add(item=outfontButton,
flag=wx.ALIGN_RIGHT |
wx.ALIGN_CENTER_VERTICAL,
pos=(row, 1))
+ #
+ # 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)
+ gridSizer.AddGrowableCol(0)
+
+ #
+ # menu style
+ #
+ row = 0
+
+ gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
+ label = _("Menu style:")),
+ flag = wx.ALIGN_LEFT |
+ wx.ALIGN_CENTER_VERTICAL,
+ pos = (row, 0))
+ listOfStyles = self.settings.Get(group = 'appearance', key = 'menustyle',
+ subkey = 'choices', internal = True)
+
+ menuItemText = wx.Choice(parent = panel, id = wx.ID_ANY, size = (300, -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', internal=True)
+ max = self.settings.Get(group='appearance', key='gSelectPopupHeight', subkey='max', internal=True)
+ 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:")),
+ 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', internal=True),
+ 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))
+
+ row += 1
+ gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
+ label=_("Note: For changing the icon theme, "
+ "you must save the settings and restart this GUI.")),
+ flag=wx.ALIGN_CENTER_VERTICAL,
+ pos=(row, 0), span=(1, 2))
+
+
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)
+ border.Add(item=sizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=3)
+
+ panel.SetSizer(border)
+
+ # bindings
+ outfontButton.Bind(wx.EVT_BUTTON, self.OnSetOutputFont)
+
+ return panel
- row = 1
+
+
+ def _CreateDisplayPage(self, notebook):
+ """!Create notebook page for display settings"""
+
+ panel = wx.Panel(parent=notebook, id=wx.ID_ANY)
+ 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)
+ gridSizer.AddGrowableCol(0)
+
+ #
+ # font settings
+ #
+ row = 0
gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
- label=_("Font for command output:")),
+ label=_("Default font for GRASS displays:")),
flag=wx.ALIGN_LEFT |
wx.ALIGN_CENTER_VERTICAL,
pos=(row, 0))
- outfontButton = wx.Button(parent=panel, id=wx.ID_ANY,
+ fontButton = wx.Button(parent=panel, id=wx.ID_ANY,
label=_("Set font"), size=(100, -1))
- gridSizer.Add(item=outfontButton,
+ gridSizer.Add(item=fontButton,
flag=wx.ALIGN_RIGHT |
wx.ALIGN_CENTER_VERTICAL,
pos=(row, 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)
+
#
# display settings
#
@@ -1242,6 +1371,7 @@
gridSizer = wx.GridBagSizer (hgap=3, vgap=3)
gridSizer.AddGrowableCol(0)
+
#
# display driver
#
@@ -1357,7 +1487,6 @@
# bindings
fontButton.Bind(wx.EVT_BUTTON, self.OnSetFont)
- outfontButton.Bind(wx.EVT_BUTTON, self.OnSetOutputFont)
return panel
@@ -1819,76 +1948,7 @@
panel.SetSizer(border)
return panel
-
- def _CreateAdvancedPage(self, notebook):
- """!Create notebook page for advanced settings"""
- panel = wx.Panel(parent=notebook, id=wx.ID_ANY)
- notebook.AddPage(page=panel, text=_("Advanced"))
-
- border = wx.BoxSizer(wx.VERTICAL)
- box = wx.StaticBox (parent=panel, id=wx.ID_ANY, label=" %s " % _("Advanced settings"))
- sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
-
- gridSizer = wx.GridBagSizer (hgap=3, vgap=3)
- gridSizer.AddGrowableCol(0)
-
- row = 0
-
- #
- # place where to store settings
- #
- gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
- label=_("Place where to store settings:")),
- flag=wx.ALIGN_LEFT |
- wx.ALIGN_CENTER_VERTICAL,
- pos=(row, 0))
- settingsFile = wx.Choice(parent=panel, id=wx.ID_ANY, size=(125, -1),
- choices=self.settings.Get(group='advanced', key='settingsFile',
- subkey='choices', internal=True),
- name='GetStringSelection')
- settingsFile.SetStringSelection(self.settings.Get(group='advanced', key='settingsFile', subkey='type'))
- self.winId['advanced:settingsFile:type'] = settingsFile.GetId()
-
- gridSizer.Add(item=settingsFile,
- flag=wx.ALIGN_RIGHT |
- wx.ALIGN_CENTER_VERTICAL,
- pos=(row, 1))
- row += 1
-
- #
- # icon theme
- #
- gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
- label=_("Icon theme:")),
- flag=wx.ALIGN_LEFT |
- wx.ALIGN_CENTER_VERTICAL,
- pos=(row, 0))
- iconTheme = wx.Choice(parent=panel, id=wx.ID_ANY, size=(125, -1),
- choices=self.settings.Get(group='advanced', key='iconTheme',
- subkey='choices', internal=True),
- name="GetStringSelection")
- iconTheme.SetStringSelection(self.settings.Get(group='advanced', key='iconTheme', subkey='type'))
- self.winId['advanced:iconTheme:type'] = iconTheme.GetId()
-
- gridSizer.Add(item=iconTheme,
- flag=wx.ALIGN_RIGHT |
- wx.ALIGN_CENTER_VERTICAL,
- pos=(row, 1))
-
- row += 1
- gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
- label=_("Note: For changing the icon theme, "
- "you must save the settings and restart this GUI.")),
- flag=wx.ALIGN_CENTER_VERTICAL,
- pos=(row, 0), span=(1, 2))
-
- sizer.Add(item=gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
- border.Add(item=sizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=3)
-
- panel.SetSizer(border)
-
- return panel
-
+
def OnCheckColorTable(self, event):
"""!Set/unset default color table"""
win = self.FindWindowById(self.winId['cmd:rasterColorTable:selection'])
@@ -1994,10 +2054,10 @@
if dlg.ShowModal() == wx.ID_OK:
# set output font and font size variables
if dlg.font:
- self.settings.Set(group='display', value=dlg.font,
+ self.settings.Set(group='appearance', value=dlg.font,
key='outputfont', subkey='type')
- self.settings.Set(group='display', value=dlg.fontsize,
+ self.settings.Set(group='appearance', value=dlg.fontsize,
key='outputfont', subkey='size')
# Standard font dialog broken for Mac in OS X 10.6
Modified: grass/branches/develbranch_6/gui/wxpython/icons/icon.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/icons/icon.py 2011-05-23 23:56:42 UTC (rev 46401)
+++ grass/branches/develbranch_6/gui/wxpython/icons/icon.py 2011-05-24 10:46:51 UTC (rev 46402)
@@ -33,7 +33,7 @@
iconPathDefault = grass2_icons.iconPath
iconSetDefault = grass2_icons.iconSet
-iconTheme = UserSettings.Get(group='advanced', key='iconTheme', subkey='type')
+iconTheme = UserSettings.Get(group='appearance', key='iconTheme', subkey='type')
if iconTheme == 'silk':
import silk_icons
iconPath = silk_icons.iconPath
Modified: grass/branches/develbranch_6/gui/wxpython/wxgui.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/wxgui.py 2011-05-23 23:56:42 UTC (rev 46401)
+++ grass/branches/develbranch_6/gui/wxpython/wxgui.py 2011-05-24 10:46:51 UTC (rev 46402)
@@ -17,6 +17,7 @@
@author Michael Barton (Arizona State University)
@author Jachym Cepicky (Mendel University of Agriculture)
@author Martin Landa <landa.martin gmail.com>
+ at author Vaclav Petras <wenzeslaus gmail.com> (menu customization)
"""
import sys
@@ -123,11 +124,9 @@
self.dialogs['atm'] = list()
# creating widgets
- self.menubar = menu.Menu(parent = self, data = menudata.ManagerData())
- self.SetMenuBar(self.menubar)
- self.menucmd = self.menubar.GetCmd()
+ self._createMenuBar()
self.statusbar = self.CreateStatusBar(number=1)
- self.notebook = self.__createNoteBook()
+ self.notebook = self._createNoteBook()
self.toolbars = { 'main' : LayerManagerToolbar(parent = self),
'tools' : ToolsToolbar(parent = self) }
@@ -209,7 +208,13 @@
self.curr_page.maptree.mapdisplay.Raise()
wx.CallAfter(self.Raise)
- def __createNoteBook(self):
+ def _createMenuBar(self):
+ """!Creates menu bar"""
+ self.menubar = menu.Menu(parent = self, data = menudata.ManagerData())
+ self.SetMenuBar(self.menubar)
+ self.menucmd = self.menubar.GetCmd()
+
+ def _createNoteBook(self):
"""!Creates notebook widgets"""
if globalvar.hasAgw:
self.notebook = FN.FlatNotebook(parent = self, id = wx.ID_ANY, agwStyle = globalvar.FNPageDStyle)
@@ -262,6 +267,12 @@
if self.workspaceFile:
self.SetTitle(self.baseTitle + " - " + os.path.basename(self.workspaceFile) + '*')
+ def OnSettingsChanged(self, event):
+ """!Here can be functions which have to be called after EVT_SETTINGS_CHANGED.
+ Now recreates menu only.
+ """
+ self._createMenuBar()
+
def OnGCPManager(self, event):
"""!Launch georectifier module
"""
@@ -1062,7 +1073,9 @@
dlg = preferences.PreferencesDialog(parent = self)
self.dialogs['preferences'] = dlg
self.dialogs['preferences'].CenterOnScreen()
-
+
+ dlg.Bind(preferences.EVT_SETTINGS_CHANGED, self.OnSettingsChanged)
+
self.dialogs['preferences'].ShowModal()
def OnHelp(self, event):
More information about the grass-commit
mailing list