How to implement keyboard shortcuts (F1 etc.)
27 Jan 2014 09:49 #43224
by gww250
How to implement keyboard shortcuts (F1 etc.) was created by gww250
Is there a method to incorporate the standard linuxcnc keyboard shortcuts into a custom Glade/python gui?
Please Log in or Create an account to join the conversation.
27 Jan 2014 10:07 #43226
by cmorley
Replied by cmorley on topic How to implement keyboard shortcuts (F1 etc.)
It is possible to catch key events and do something in gladevcp using the python handler extensions
Gscreen does this.
add a keypress event to the top window (if your going to embed the panel then the second to top widget)
(It's more involved then this but this gives the idea)
gscreen adds:
What key presses do you want to use?
Chris M
Gscreen does this.
add a keypress event to the top window (if your going to embed the panel then the second to top widget)
(It's more involved then this but this gives the idea)
gscreen adds:
def initialize_keybindings(self):
self.widgets.window1.connect('key_press_event', self.on_key_event,1)
self.widgets.window1.connect('key_release_event', self.on_key_event,0)
def on_key_event(self,widget, event,state):
CNTRL = SHIFT = ALT = 0
keyname = gtk.gdk.keyval_name(event.keyval)
self.verbosely_print("Key %s (%d) was pressed state: %d last: %s" % (keyname, event.keyval,state, self.data.key_event_last))
if event.state & gtk.gdk.CONTROL_MASK:
CNTRL = 1
self.verbosely_print("Control was being held down")
if event.state & gtk.gdk.MOD1_MASK:
ALT = 1
self.verbosely_print("Alt was being held down")
if event.state & gtk.gdk.SHIFT_MASK:
SHIFT = 1
self.verbosely_print("Shift was being held down")
if keyname in( "Shift_L","Shift_R"): return True # ignore shift key press
if self.data.key_event_last[0] == keyname and self.data.key_event_last[1] == state : return True
self.data.key_event_last = keyname,state
What key presses do you want to use?
Chris M
Please Log in or Create an account to join the conversation.
27 Jan 2014 10:12 #43227
by gww250
Replied by gww250 on topic How to implement keyboard shortcuts (F1 etc.)
This is excellent. I looked through Gscreen and completely missed this. I only want to implement the F1-F12 keys, the V-key for cycling thru the live plotter and a few others, none of the combination key types.
This is a great help and I appreciate it very much.
This is a great help and I appreciate it very much.
Please Log in or Create an account to join the conversation.
27 Jan 2014 12:08 #43228
by cmorley
Replied by cmorley on topic How to implement keyboard shortcuts (F1 etc.)
No problem - if you get stuck - I'll do what I can to help.
Chris M
Chris M
Please Log in or Create an account to join the conversation.
30 Jan 2014 07:15 #43319
by gww250
Replied by gww250 on topic How to implement keyboard shortcuts (F1 etc.)
by the way I never thought to try and add the keyboard shortcuts as 'Glade' accelerator attributes but it works for most keys except 'escape' and then it thinks you're trying to close Glade but I'll try to figure it out.
Please Log in or Create an account to join the conversation.
30 Jan 2014 13:18 #43321
by cmorley
Replied by cmorley on topic How to implement keyboard shortcuts (F1 etc.)
Ya I didn't find them flexible enough and didn't research them much.
What doe your GUI look like?
Chris M
What doe your GUI look like?
Chris M
Please Log in or Create an account to join the conversation.
Time to create page: 0.121 seconds