Custom Gui keyboard key press

More
06 Jul 2018 12:49 #113566 by echesortux
Hello everybody, I am making a custon gui using glade and python so far so good, the problem is that I want define some function such as "open file" using a key stroke instead using the mouse in my custon Gui. I have read that is posible using "key press event" but I don't figure out how to use it with a widget.
someone could please help me?

Please Log in or Create an account to join the conversation.

More
06 Jul 2018 15:47 - 06 Jul 2018 15:48 #113576 by cmorley
Are you using GTK2 (like gladevcp)?
Look at Gscreen or Gmoccapy both of these offer keystroke functions.
If you allow jogging with keys - it's a pain in the ass to get it right.

For gscreen the initialize_keybinding binds the events from the main window to the on_key_event and the on_key_event pre-process the key events and sends that to a lookup function that calls a 'do something function'
gscreen keybindings are complex because it allow customization.
basically the function between thw try/except in on_key_event is where you would put code to pick a key code and do what you want.

googling ' pygtk on_key_press' probably would get some useful hits too.

Hope that helps

Chris M
Last edit: 06 Jul 2018 15:48 by cmorley.
The following user(s) said Thank You: echesortux

Please Log in or Create an account to join the conversation.

More
06 Jul 2018 16:54 #113587 by echesortux
Thank Chris, I am trying to make a GUI from scratch. no using other existing interface. In fact I want to it for a press brake so the idea is to create a panel using switch and avoid using keyboard and mouse. I know that for more of the function I can use halui (In fact I will use it to power on, run, homming, etc)but my problem is how to load an ngc file without using keyboard and mouse so I though that maybe if I can create key then I could simulate this key press. May there is a better way to do it.
Thanks.

Please Log in or Create an account to join the conversation.

More
06 Jul 2018 23:25 #113615 by cmorley
Well Gscreen was made for building custom screen but some people like to code there own from scratch and that is fine :)

Norbert built a icon based file loading widget (iconview) maybe you can adapt it to use real buttons rather then a touch screen.

Chris M

Please Log in or Create an account to join the conversation.

Time to create page: 0.070 seconds
Powered by Kunena Forum