我在Windows 7中运行这个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()
答案 0 :(得分:2)
Ctrl + x而文本ctrl具有焦点是切割文本的快捷方式,而Ctrl + c用于复制&按Ctrl + v进行粘贴。