########################################################################################## ########## MODIFYING AXIS KEYBINDING MADE EASY BUT NOT TOO EASY ########## ########################################################################################## ### This file goes into the same folder as your config ### Add this line to your ini file, under the display section (without the #) ### USER_COMMAND_FILE = keybingdings.py ### unbind a key first (if needed), then rebind to your new thing, for example root_window.unbind('') root_window.unbind('') root_window.unbind('') root_window.unbind('') # then rebind it to your new command # bind right and left keys to joint 0, usually x bind_axis("Right", "Left", 0) # bind down and up keys to joint 1, usually y bind_axis("Up", "Down", 1) # ### UNBIND #root_window.unbind("Prior") #root_window.unbind("Next") #root_window.unbind("Home") #root_window.unbind("End") #root_window.unbind("KP_Left") #root_window.unbind("KP_Right") #root_window.unbind("KP_Down") #root_window.unbind("KP_Up") #root_window.unbind("KP_Next") #root_window.unbind("KP_Prior") #root_window.unbind("KP_Home") #root_window.unbind("KP_End") #root_window.unbind("KP_7") #root_window.unbind("KP_1") #root_window.unbind("bracketleft") #root_window.unbind("bracketright") #root_window.unbind("l")#, commands.toggle_override_limits) #root_window.unbind("o")#, commands.open_file) #root_window.unbind("s")#, commands.task_resume) #root_window.unbind("t")#, commands.task_step) #root_window.unbind("p")#, commands.task_pause) #root_window.unbind("R")#, commands.task_reverse) #root_window.unbind("F")#, commands.task_forward) #root_window.unbind("v")#, commands.cycle_view) #root_window.unbind("r")#, commands.task_run) #root_window.unbind("B")#, commands.brake_on) #root_window.unbind("b")#, commands.brake_off) #root_window.unbind("x")#, lambda event: activate_ja_widget("x")) #root_window.unbind("y")#, lambda event: activate_ja_widget("y")) #root_window.unbind("z")#, lambda event: activate_ja_widget("z")) #root_window.unbind("a")#, lambda event: activate_ja_widget("a")) #root_window.unbind("c")#, lambda event: jogspeed_continuous()) #root_window.unbind("d")#, lambda event: widgets.rotate.invoke()) #root_window.unbind("i")#, lambda event: jogspeed_incremental()) #root_window.unbind("I")#, lambda event: jogspeed_incremental(-1)) #root_window.unbind("`")#, lambda event: activate_ja_widget_or_set_feedrate(0)) #root_window.unbind("1")#, lambda event: activate_ja_widget_or_set_feedrate(1)) #root_window.unbind("2")#, lambda event: activate_ja_widget_or_set_feedrate(2)) #root_window.unbind("3")#, lambda event: activate_ja_widget_or_set_feedrate(3)) #root_window.unbind("4")#, lambda event: activate_ja_widget_or_set_feedrate(4)) #root_window.unbind("5")#, lambda event: activate_ja_widget_or_set_feedrate(5)) #root_window.unbind("6")#, lambda event: activate_ja_widget_or_set_feedrate(6)) #root_window.unbind("7")#, lambda event: activate_ja_widget_or_set_feedrate(7)) #root_window.unbind("8")#, lambda event: activate_ja_widget_or_set_feedrate(8)) #root_window.unbind("9")#, lambda event: activate_ja_widget_or_set_feedrate(9)) #root_window.unbind("0")#, lambda event: activate_ja_widget_or_set_feedrate(10)) #root_window.unbind("!")#, "set metric [expr {!$metric}]; redraw") #root_window.unbind("@")#, commands.toggle_display_type) #root_window.unbind("#")#, commands.toggle_coord_type) #root_window.unbind("$")#, commands.toggle_teleop_mode) #root_window.unbind("")#, commands.home_joint) #root_window.unbind("")#, commands.touch_off_system) #root_window.unbind(".")#, commands.toggle_coord_type) #root_window.unbind(",")#, commands.toggle_teleop_mode) #root_window.unbind(";")#, commands.toggle_coord_type) #root_window.unbind("'")#, commands.toggle_teleop_mode) #########bind #root_window.bind("l", commands.toggle_override_limits) #root_window.bind("o", commands.open_file) #root_window.bind("s", commands.task_resume) #root_window.bind("t", commands.task_step) #root_window.bind("p", commands.task_pause) #root_window.bind("R", commands.task_reverse) #root_window.bind("F", commands.task_forward) #root_window.bind("v", commands.cycle_view) #root_window.bind("r", commands.task_run) #root_window.bind("B", commands.brake_on) #root_window.bind("b", commands.brake_off) #root_window.bind("x", lambda event: activate_ja_widget("x")) #root_window.bind("y", lambda event: activate_ja_widget("y")) #root_window.bind("z", lambda event: activate_ja_widget("z")) #root_window.bind("a", lambda event: activate_ja_widget("a")) #root_window.bind("c", lambda event: jogspeed_continuous()) #root_window.bind("d", lambda event: widgets.rotate.invoke()) #root_window.bind("i", lambda event: jogspeed_incremental()) #root_window.bind("I", lambda event: jogspeed_incremental(-1)) #root_window.bind("`", lambda event: activate_ja_widget_or_set_feedrate(0)) #root_window.bind("1", lambda event: activate_ja_widget_or_set_feedrate(1)) #root_window.bind("2", lambda event: activate_ja_widget_or_set_feedrate(2)) #root_window.bind("3", lambda event: activate_ja_widget_or_set_feedrate(3)) #root_window.bind("4", lambda event: activate_ja_widget_or_set_feedrate(4)) #root_window.bind("5", lambda event: activate_ja_widget_or_set_feedrate(5)) #root_window.bind("6", lambda event: activate_ja_widget_or_set_feedrate(6)) #root_window.bind("7", lambda event: activate_ja_widget_or_set_feedrate(7)) #root_window.bind("8", lambda event: activate_ja_widget_or_set_feedrate(8)) #root_window.bind("9", lambda event: activate_ja_widget_or_set_feedrate(9)) #root_window.bind("0", lambda event: activate_ja_widget_or_set_feedrate(10)) #root_window.bind("!", "set metric [expr {!$metric}]; redraw") #root_window.bind("@", commands.toggle_display_type) #root_window.bind("#", commands.toggle_coord_type) #root_window.bind("$", commands.toggle_teleop_mode) #root_window.bind("", commands.home_joint) #root_window.bind("", commands.touch_off_system) #################################################### # this is the very slick keybinding thing used in plasmac2 # posted for reference only # ~ def keyboard_bindings(state): # ~ if firstRun: # ~ set_help_text() # ~ # delete kb shortcuts from help menu # ~ rC('.menu.help','delete',3,5) # ~ # remove current bindings # ~ for key in root_window.bind(): # ~ root_window.unbind(key) # ~ # create new key bindings if enabled # ~ if state: # ~ # Escape # ~ root_window.bind('', commands.task_stop) # ~ # F keys # ~ root_window.bind_class('all', '', commands.estop_clicked) # ~ root_window.bind('', commands.onoff_clicked) # ~ root_window.bind('', pane_top + '.tabs raise manual') # ~ root_window.bind('', commands.next_tab) # ~ root_window.bind('', pane_top + '.tabs raise mdi') # ~ root_window.bind('', '+' + tabs_mdi + '.command selection range 0 end') # ~ root_window.bind('', commands.manual_cut) # ~ # axis selection # ~ root_window.bind('x', lambda event: activate_ja_widget('x')) # ~ root_window.bind('y', lambda event: activate_ja_widget('y')) # ~ root_window.bind('z', lambda event: activate_ja_widget('z')) # ~ root_window.bind('a', lambda event: activate_ja_widget('a')) # ~ root_window.bind('b', lambda event: activate_ja_widget('b')) # ~ #jogging # ~ root_window.bind('c', lambda event: jogspeed_continuous()) # ~ root_window.bind('i', lambda event: jogspeed_incremental()) # ~ root_window.bind('I', lambda event: jogspeed_incremental(-1)) # ~ bind_axis('Left', 'Right', 0) # ~ bind_axis('Down', 'Up', 1) # ~ bind_axis('Next', 'Prior', 2) # ~ bind_axis('KP_Left', 'KP_Right', 0) # ~ bind_axis('KP_Down', 'KP_Up', 1) # ~ bind_axis('KP_Next', 'KP_Prior', 2) # ~ # bind_axis('KP_4', 'KP_6', 0) # ~ # bind_axis('KP_2', 'KP_8', 1) # ~ # bind_axis('KP_3', 'KP_9', 2) # ~ bind_axis('bracketleft', 'bracketright', 3) # ~ bind_axis('semicolon', 'quoteright', 4) # ~ root_window.bind('', lambda event: commands.key_pressed('jogfast')) # ~ root_window.bind('', lambda event: commands.key_released('jogfast')) # ~ root_window.bind('', lambda event: commands.key_pressed('jogslow')) # ~ root_window.bind('', lambda event: commands.key_released('jogslow')) # ~ # sliders # ~ root_window.bind('`', lambda event: activate_ja_widget_or_set_feedrate(0)) # ~ root_window.bind('',lambda event: set_rapidrate(0)) # ~ root_window.bind('',lambda event: set_jog_slider(0.0)) # ~ for n in range(10): # ~ rate = n if n > 0 else 10 # ~ root_window.bind('{}'.format(n), make_lambda(activate_ja_widget_or_set_feedrate, rate)) # ~ root_window.bind(''.format(n), make_lambda(set_rapidrate, rate * 10)) # ~ root_window.bind(''.format(n), make_lambda(set_jog_slider, rate * 0.1)) # ~ # homing # ~ if homing_order_defined: # ~ root_window.bind('', commands.home_all_joints) # ~ else: # ~ root_window.bind('', commands.home_joint) # ~ root_window.bind('', commands.home_joint) # ~ # touchoff # ~ root_window.bind('', lambda event: commands.touch_off_xy('1', 0, 0)) # ~ root_window.bind('', lambda event: commands.touch_off_xy('0', 0, 0)) # ~ root_window.bind('', commands.set_axis_offset) # ~ root_window.bind('', commands.touch_off_system) # ~ root_window.bind('', lambda event: commands.key_pressed('Delete')) # ~ root_window.bind('', lambda event: commands.key_released('Delete')) # ~ # program # ~ root_window.bind('o', commands.open_file) # ~ root_window.bind('r', commands.task_run) # ~ root_window.bind('p', commands.task_pause) # ~ root_window.bind('', commands.task_pause) # ~ root_window.bind('s', commands.task_resume) # ~ root_window.bind('', commands.reload_file) # ~ root_window.bind('', commands.save_gcode) # ~ # clearing # ~ root_window.bind('', commands.clear_live_plot) # ~ root_window.bind('', lambda event: notifications.clear()) # ~ # whacky keypad stuff # ~ keys1 = ['Decimal', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] # ~ # Down, Next, Left, Right, Up, and Prior are done in the jogging section above # ~ keys2 = ['Delete', 'Insert', 'End', None, None, None, 'Begin', None, 'Home', None, None] # ~ for k in range(len(keys2)): # ~ if keys2[k]: # ~ root_window.bind(''.format(keys2[k]), make_lambda(key_pressed, keys2[k])) # ~ root_window.bind(''.format(keys2[k]), make_lambda(key_released, keys2[k])) # ~ root_window.bind(''.format(keys2[k]), make_lambda(key_released, keys1[k])) # ~ # add kb shortcuts to help menu # ~ rC('.menu.help','add','separator') # ~ rC('.menu.help','add','command','-command','wm transient .keys .;wm deiconify .keys; focus .keys.ok') # ~ rC('setup_menu_accel','.menu.help','end',_('Keyboard Shortcuts')) # ~ rC('.menu.help','add','command','-command','wm transient .keyp .;wm deiconify .keyp; focus .keyp.ok') # ~ rC('setup_menu_accel','.menu.help','end',_('Keypad Shortcuts')) # ~ # use arrow buttons for spinboxes # ~ for item in rpList + cpList: # ~ widget = item[0] + '.' + item[1] # ~ rC('bind',widget,'','%W invoke buttonup') # ~ rC('bind',widget,'','%W invoke buttondown') # ~ rC('bind',widget,'','::tk::EntrySetCursor %W [expr {[%W index insert] - 1}]') # ~ rC('bind',widget,'','::tk::EntrySetCursor %W [expr {[%W index insert] + 1}]')