View Full Version : GTK menu question
nickos
August 19th, 2011, 02:23 PM
how can i add these extra characters next to a menu item?
EG :
i create the following:
file
|
-> Open
-> Quit
how can i make it look like this :
file
|
-> Open Ctrl + 0
-> Quit Ctrl + Q
thanks :D
Smart Viking
August 19th, 2011, 02:41 PM
You can do that with gtk.AccelGroup
There was a tut in a magazine about it, I'll just copy in here the code you need:
accelgroup = gtk.AccelGroup()
window.add_accel_group(accelgroup)
key,mod = gtk.accelerator_parse("<Control>Q")
quit_item.add_accelerator("activate",accelgroup,key,mod,gtk.ACCEL_VISIBLE)
nickos
August 19th, 2011, 02:59 PM
thanks for your reply,but it is GTK+ in C.
JupiterV2
August 19th, 2011, 03:13 PM
Read the GTK+ C API. The code is essentially the same but with the C API. You should be able to translate the example into C fairly easily (hint, you'll need to look at the docs on Accelerator Groups, Windows and Widgets). A simple search in your browser for 'accel' under each of the listed docs will get you want you want. Struggle with it for a bit and if you can't get code to work, post it, and we'll see if we can help point you in the right direction.
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.