我使用Gtk(python3)+Glade创建一个应用程序。我在空地上设置了一些加速器,如下所示:
<child>
<object class="GtkImageMenuItem" id="imagemenuitem5">
<property name="label">gtk-quit</property>
<accelerator key="q" signal="activate" modifiers="GDK_CONTROL_MASK"/>
</object>
</child>
但我不知道如何在应用程序运行时将此事件的加速器更改为其他内容。有可能吗?我的实施是否与我的计划不符?在
<accelerator>
元素在内部使用^{事实上,还有一种比这更现代的方法,使用},根本不需要创建任何菜单栏。以下是在运行时更改菜单项的加速器的示例:
GAction
,GApplication
,和{您也可以使用Glade文件来完成一些操作,并通过创建一个
menus.ui
文件并使其在特定的GResource路径上对您的应用程序可用来自动连接它:这被描述为here。在相关问题 更多 >
编程相关推荐