我该如何添加按钮快捷键/加速器?在
self.newItemButton = wx.Button(self.mainPanel, label='Scan &New Item')
在我的平台上似乎不起作用。在
^{pr2}$找到的文章:
示例代码:
import wx
class SpamButton(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, title=title)
self.mainPanel = wx.Panel(self)
self.thisSpamButton()
self.Show()
def thisSpamButton(self):
self.sizer = wx.BoxSizer(wx.VERTICAL)
#---------------------------------------------
# So the letter 's' should be underlined right? | Here it is
#-----------------------------------------------------v
self.newItemButton = wx.Button(self.mainPanel, label='&spam')
self.sizer.Add(self.newItemButton, 0, wx.ALL, 2)
self.mainPanel.Layout()
def main():
app = wx.App(False)
MainFrame = SpamButton(None, 'This Button Short Cut is weird')
app.MainLoop()
if __name__ == '__main__':
main()
结果:
我直到现在才真正尝试热键,只是因为我不够好奇。在
好的,所以在这个例子中按alt+hot_key
来处理垃圾邮件时。。。它起作用了!在
但是:
热键字母最初不带下划线。在
下划线仅在按下alt时呈现。:(
正如@RobinDunn所说,这是一个GTK配置。在
基本上将
gtk-auto-mnemonics
从0改为1。在因为我使用的是XFCE4,所以我在GTK2中为一个特定的主题启用了助记符,如下所示:
虽然它们可以工作,但通过按
alt
提前知道哪些“丑陋”按钮有加速器是很好的。在或在GTK3中将
^{pr2}$gtk-auto-mnemonics
从0更改为1:无需按alt的结果:
相关问题 更多 >
编程相关推荐