[GRASS-SVN] r56344 - grass/trunk/gui/wxpython/gui_core
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue May 21 04:05:25 PDT 2013
Author: annakrat
Date: 2013-05-21 04:05:24 -0700 (Tue, 21 May 2013)
New Revision: 56344
Modified:
grass/trunk/gui/wxpython/gui_core/forms.py
Log:
wxGUI/forms: use accelerator table, use ctrl+c for standard text copying (not to copy command), ESC to quit (probably working on wx 2.9 only)
Modified: grass/trunk/gui/wxpython/gui_core/forms.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/forms.py 2013-05-21 07:13:14 UTC (rev 56343)
+++ grass/trunk/gui/wxpython/gui_core/forms.py 2013-05-21 11:05:24 UTC (rev 56344)
@@ -476,6 +476,10 @@
self.btn_cancel.SetToolTipString(_("Close this window without executing the command (Ctrl+Q)"))
btnsizer.Add(item = self.btn_cancel, proportion = 0, flag = wx.ALL | wx.ALIGN_CENTER, border = 10)
self.btn_cancel.Bind(wx.EVT_BUTTON, self.OnCancel)
+ # bind closing to ESC and CTRL+Q
+ self.Bind(wx.EVT_MENU, self.OnCancel, id=wx.ID_CLOSE)
+ accelTableList = [(wx.ACCEL_NORMAL, wx.WXK_ESCAPE, wx.ID_CLOSE)]
+ accelTableList = [(wx.ACCEL_CTRL, ord('Q'), wx.ID_CLOSE)]
if self.get_dcmd is not None: # A callback has been set up
btn_apply = wx.Button(parent = self.panel, id = wx.ID_APPLY)
@@ -500,7 +504,7 @@
# copy
self.btn_clipboard = wx.Button(parent = self.panel, id = wx.ID_COPY)
- self.btn_clipboard.SetToolTipString(_("Copy the current command string to the clipboard (Ctrl+C)"))
+ self.btn_clipboard.SetToolTipString(_("Copy the current command string to the clipboard"))
btnsizer.Add(item = self.btn_run, proportion = 0,
flag = wx.ALL | wx.ALIGN_CENTER,
@@ -511,11 +515,16 @@
border = 10)
self.btn_run.Bind(wx.EVT_BUTTON, self.OnRun)
+ self.Bind(wx.EVT_MENU, self.OnRun, id=wx.ID_OK)
+ accelTableList.append((wx.ACCEL_CTRL, ord('R'), wx.ID_OK))
self.btn_clipboard.Bind(wx.EVT_BUTTON, self.OnCopy)
# help
self.btn_help = wx.Button(parent = self.panel, id = wx.ID_HELP)
self.btn_help.SetToolTipString(_("Show manual page of the command (Ctrl+H)"))
self.btn_help.Bind(wx.EVT_BUTTON, self.OnHelp)
+ self.Bind(wx.EVT_MENU, self.OnHelp, id=wx.ID_HELP)
+ accelTableList.append((wx.ACCEL_CTRL, ord('H'), wx.ID_HELP))
+
if self.notebookpanel.notebook.GetPageIndexByName('manual') < 0:
self.btn_help.Hide()
@@ -524,6 +533,13 @@
guisizer.Add(item = btnsizer, proportion = 0, flag = wx.ALIGN_CENTER | wx.LEFT | wx.RIGHT,
border = 30)
+ # abort key bindings
+ abortId = wx.NewId()
+ self.Bind(wx.EVT_MENU, self.OnAbort, id=abortId)
+ accelTableList.append((wx.ACCEL_CTRL, ord('S'), abortId))
+ # set accelerator table
+ accelTable = wx.AcceleratorTable(accelTableList)
+ self.SetAcceleratorTable(accelTable)
if self.parent and not self.modeler:
addLayer = False
@@ -559,7 +575,6 @@
border = 5)
# bindings
self.Bind(wx.EVT_CLOSE, self.OnCancel)
- self.Bind(wx.EVT_KEY_UP, self.OnKeyUp)
# do layout
# called automatically by SetSizer()
@@ -598,31 +613,6 @@
self.SetStatusText(' '.join(self.notebookpanel.createCmd(ignoreErrors = True)))
if event:
event.Skip()
-
- def OnKeyUp(self, event):
- """!Key released (check hot-keys)"""
- try:
- kc = chr(event.GetKeyCode())
- except ValueError:
- event.Skip()
- return
-
- if not event.ControlDown():
- event.Skip()
- return
-
- if kc == 'Q':
- self.OnCancel(None)
- elif kc == 'S':
- self.OnAbort(None)
- elif kc == 'H':
- self.OnHelp(None)
- elif kc == 'R':
- self.OnRun(None)
- elif kc == 'C':
- self.OnCopy(None)
-
- event.Skip()
def OnDone(self, cmd, returncode):
"""!This function is launched from OnRun() when command is
More information about the grass-commit
mailing list