keyboard shortcuts

More
12 May 2025 07:05 #328250 by theoneandonlyoreo
keyboard shortcuts was created by theoneandonlyoreo
I need to set the jog increment to a specific value and bind it to a key, let's say 'e'.  I'm using the Axis GUI so the key binding is done like this in .axisrc, which works:

root_window.bind( "<e>", set_jog_inc_precise )

The contents of the function set_jog_inc_precise is the issue.  I've tried the following

vars.jog.increment.set( "0.001" )

linuxcnc.command().jog( linuxcnc.JOG_INCREMENT, True, 0, 10, 0.001 )

j = root_window.nametowidget( ".pane.top.jogspeed.jogincrement")
j.set( "0.001" )

root_window.tk.eval( "set jogincrement 0.001" )
commands.set_jog_increments()


Only the second (linuxcnc.command()...) had an effect.  It actually jogged the axis, when I was watching the DRO.  So when I press "e" it would jog X 0.001 in the positive direction but when I used the arrow, it jogged X based on the drop-down menu in the Manual Control tab.

The backstory is that I have a pendant that isn't supported and have managed to map it from /dev/hidraw<n> to a virtual keyboard.  Most of the buttons work but the relative adjustment of the jog increment (i, I) is not the best because the dial on the pendant is labeled and it's easy to get out of sync. 

I've spent a few hours trying to get this working, reviewed the documentation for the python linuxcnc module, and even asked a few chatbots.  What am I doing wrong?

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

More
12 May 2025 16:01 #328284 by JT
Replied by JT on topic keyboard shortcuts
One thing to note is keyboard shortcuts only work when the Axis window has focus.

JT

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

More
12 May 2025 16:43 #328288 by theoneandonlyoreo
Replied by theoneandonlyoreo on topic keyboard shortcuts
OK, I figured out a way to select from the GUI list of jog increments using a single keystroke.

There's more than meets the eye. You've got to pull in some GUI elements that are only apparent if you read through axis.py. It's not good enough to set the increment because the GUI will re-set it based on the dropdown.

import linuxcnc
import tkinter
import hal

def set_jog_inc_rc( event, index ):
global comp, jogincr_index_last

root_window.call( widgets.jogincr._w, "select", index )
jogincr = widgets.jogincr.get()
print( f"setting jog increment to {jogincr} inch " )
comp = float( jogincr.translate(str.maketrans("", "", string.ascii_letters)) ) # remove "in"


root_window.bind( "<e>", lambda event: set_jog_inc_rc( event, 5 ) )
root_window.bind( "<f>", lambda event: set_jog_inc_rc( event, 3 ) )
root_window.bind( "<g>", lambda event: set_jog_inc_rc( event, 1 ) )

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

More
12 May 2025 16:50 #328290 by theoneandonlyoreo
Replied by theoneandonlyoreo on topic keyboard shortcuts
I'm a n00b, straight from UGS, so I don't know if that will be an issue. I anticipate using the pendant during setup, so being on the "Manual Control" window might not be a problem.

What's a solution to the focus problem?

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

More
12 May 2025 17:53 #328294 by JT
Replied by JT on topic keyboard shortcuts
Axis is a great GUI and very stable, the problem with Axis is it's super complicated to try and change the behaviour. Once you start to need a custom GUI this is where Flex GUI shines.

gnipsel.com/linuxcnc/flexgui/index.html

JT

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

Time to create page: 0.086 seconds
Powered by Kunena Forum