1
我在Windows 7中运行这个wxpython应用程序。出于某种原因,当我在键盘上按ctrl+x
时,框架无法关闭。wxpython ctrl + x快捷方式不起作用
但是,如果我将绑定从text='quit\tCtrl+x'
更改为text='quit\tCtrl+q'
或除x
之外的任何其他字符,则该框关闭。
请问ctrl+x
在wxpython中有什么特别的意义,是防止帧被关闭?
import os
import wx
class MainMe(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, parent=None, size=(300, 300), title = 'test frame')
wx.TextCtrl(parent=self, style =wx.TE_MULTILINE | wx.TE_NO_VSCROLL)
self.CreateStatusBar()
filemenu = wx.Menu()
exitId, aboutId = wx.NewId(), wx.NewId()
menuAbout = filemenu.Append(id=aboutId, text='about\tCtrl+a', help='more information')
menuExit = filemenu.Append(id=exitId, text='quit\tCtrl+x', help="close")
menubar = wx.MenuBar()
menubar.Append(filemenu, title='File')
self.SetMenuBar(menubar)
self.Bind(wx.EVT_MENU, self.onAbout, source=menuAbout)
self.Bind(wx.EVT_MENU, self.onExit, source=menuExit)
self.Show()
def onAbout(self, e):
dlg = wx.MessageDialog(self, "A small text editor", "About Sample Editor", wx.OK)
dlg.ShowModal()
dlg.Destroy()
def onExit(self, e):
self.Close(True)
a = wx.App()
f = MainMe()
a.MainLoop()
有什么方法可以覆盖这些默认值? – user784637
我不希望用户期望ctrl + x被削减,他们会去削减一些东西,而他们会退出。 – Yoriz
我明白了,但对于其他热键,有没有办法覆盖它们? – user784637