Move

I was trying to get a bindkey for "move" (ref point to dest point
by click) by the File>Setup, Customize Menu. What I find is in
the menus there is only "Move By" and "Move To", and both of
these want numeric entry, won't take mouse clicks.

Way down at the bottom of the Configure pane, are three odd
entries. The "duplicate_interactive" is what I'd want as a Copy
command in the traditional style (so I give it "C") and the
"sel_move_interactive" is what I want as a Move command
(so, "M").

Bonus, both of these work as infix mode (the selected object(s)
already know their "from" coords anyhow), so now I can copy and
move texts without having to accurately hit their minuscule
selectable extent (the little origin cross).

Question for Matthias - is it possible, practical, likely that
infix could be, or be made to be, the default mode? I much
prefer it, as I don't have to worry about accurately hitting
the "from" coords or losing my mouse position by having
to leave the layout pane to hit the menus. Evidently some
functions are, presumably others could be. But how?

Question for Matthias - those three oddballs at the bottom,
appear to be three of the "Toolbar" icons' actions on direct
(not pulldown) click. Could the others (esp. Polygon, Box,
Text, Path, Instance, Partial) be added to that section so
I can bind them to keys that match my "brand C muscle
memory" instead of fighting it?

Question for Matthias - how can I save and reload this
"customized" menus & bindkeys "bundle"? I think maybe
you mentioned something about that in some a-while-back
Q&A, but I'm not remembering anything and can't see any
facility for saving the Setup or any pieces of it, or loading
a Setup configuration. It seems to be "sticky" and that's fine
for the moment, but sometimes you want the gum off your
shoe, in one wipe. Something other than "Reset" - like a
favorite key-bindings I could take with me from project
to project, machine to machine without redoing all the
fiddling.

Comments

  • edited April 2021

    Hmm you could do something like this, place this is your pymacros or macros directory
    save as a .lym file the description below when placed in the above dir's should autoload each time
    you fire up Klayout, load in the IDE and run , test your keybindings


    <?xml version="1.0" encoding="utf-8"?> <klayout-macro> <description/> <version/> <category>pymacros</category> <prolog/> <epilog/> <doc/> <autorun>true</autorun> <autorun-early>false</autorun-early> <shortcut/> <show-in-menu>false</show-in-menu> <group-name/> <menu-path/> <interpreter>python</interpreter> <dsl-interpreter-name/> <text> import pya # Enter your Python code here .. # Enter your Custom registerKeyBindings(): import os config = pya.Application.instance().get_config('key-bindings') if config == '': print('WARNING: get_config(key-bindings) returned null') mapping = dict() else: mapping = dict(item.split(":") for item in config.split(";")) #Tracy's Menu mapped to Keys use Ruby menu_map to get menu definitions #mapping['trt_menu.layout_submenu.macro_in_menu_chopit'] = "'Shift+C'" #mapping['trt_menu.layout_submenu.macro_in_menu_Quick_Trace'] = "'Shift+T'" #End Map mapping['edit_menu.clear_all_rulers'] = "'Ctrl+K'" mapping['edit_menu.copy'] = "'Ctrl+C'" mapping['edit_menu.cut'] = "'Ctrl+X'" mapping['edit_menu.paste'] = "'Ctrl+V'" mapping['edit_menu.redo'] = "'Ctrl+Y'" mapping['edit_menu.undo'] = "'Ctrl+Z'" mapping['edit_menu.delete'] = "'Del'" mapping['edit_menu.duplicate'] = "'Ctrl+D'" mapping['edit_menu.mode_menu.move'] = "'M'" mapping['edit_menu.mode_menu.ruler'] = "'R'" mapping['edit_menu.mode_menu.select'] = "'S'" mapping['edit_menu.mode_menu.box'] = "'B'" mapping['edit_menu.mode_menu.instance'] = "'I'" mapping['edit_menu.mode_menu.partial'] = "'L'" mapping['edit_menu.mode_menu.path'] = "'P'" mapping['edit_menu.mode_menu.polygon'] = "'p'" mapping['edit_menu.mode_menu.text'] = "'T'" mapping['edit_menu.select_menu.select_all'] = "'Shift+Ctrl+A'" mapping['edit_menu.show_properties'] = "'Q'" mapping['edit_menu.edit_options'] = "'E'" mapping['edit_menu.selection_menu.change_layer'] = "'Shift+L'" mapping['edit_menu.selection_menu.sel_flip_x'] = "'Shift+H'" mapping['edit_menu.selection_menu.sel_flip_y'] = "'Shift+V'" mapping['edit_menu.selection_menu.sel_move'] = "'Ctrl+M'" mapping['edit_menu.selection_menu.sel_rot_ccw'] = "'Shift+R'" mapping['edit_menu.selection_menu.sel_free_rot'] = "'Ctrl+Shift+R'" mapping['edit_menu.selection_menu.flatten_insts'] = "'Ctrl+Shift+F'" mapping['edit_menu.selection_menu.make_cell'] = "'Ctrl+Shift+M'" # mapping['edit_menu.selection_menu.size'] = "'Z'" # mapping['edit_menu.selection_menu.tap'] = "''" mapping['file_menu.new_layout'] = "'Ctrl+N'" mapping['file_menu.close'] = "'Ctrl+W'" mapping['file_menu.open_new_panel'] = "'Ctrl+O'" mapping['file_menu.open_same_panel'] = "'Ctrl+Shift+O'" mapping['file_menu.save'] = "'Ctrl+S'" mapping['file_menu.save_as'] = "'Ctrl+Shift+S'" mapping['file_menu.screenshot'] = "'F12'" # mapping['file_menu.setup'] = "'F4'" mapping['macros_menu.macro_development'] = "'F5'" mapping['zoom_menu.max_hier'] = "'Shift+F'" mapping['zoom_menu.select_current_cell'] = "'Shift+S'" # Display &gt; Show as new top mapping['zoom_menu.zoom_fit'] = "'F'" mapping['zoom_menu.zoom_fit_sel'] = "'Shift+F2'" mapping['zoom_menu.zoom_in'] = "'Return'" mapping['zoom_menu.zoom_out'] = "'Shift+Return'" # turn the hash back into a config string config = ''.join('{}:{};'.format(key, val) for key, val in sorted(mapping.items()))[:-1] pya.Application.instance().set_config('key-bindings', config) pya.Application.instance().set_config('edit-connect-angle-mode', 'ortho') pya.Application.instance().set_config('edit-inst-angle', '0') pya.Application.instance().set_config('edit-move-angle-mode', 'diagonal') pya.Application.instance().set_config('edit-snap-to-objects', 'true') pya.Application.instance().set_config('grid-micron', '0.01') pya.Application.instance().set_config('edit-top-level-selection', 'true') pya.Application.instance().set_config('inst-color', '#ffcdcd') pya.Application.instance().set_config('text-font', '3') pya.Application.instance().set_config('guiding-shape-line-width', '0') pya.Application.instance().set_config('rdb-marker-color', '#ff0000') pya.Application.instance().set_config('rdb-marker-line-width', '8') # pya.Application.instance().set_config('default-layer-properties', os.path.join(os.path.realpath(__file__), os.pardir, os.pardir, os.pardir, 'libraries', 'klayout_Layers_EBeam.lyp')) if pya.Application.instance().get_config('edit-mode') == 'false': pya.Application.instance().set_config('edit-mode', 'true') pya.MessageBox.warning( "Restart", "Please restart KLayout. Tracy's settings have been applied.", pya.MessageBox.Ok) </text> </klayout-macro>
  • @dick_freebird I recall the three functions have been introduced on your request :)

    @tagger5896 This code is essentially what some users use to establish a fixed configuration. For the conversion of the mapping array to a string, KLayout provides a special function (AbstractMenu#pack_key_binding), so you don't need to emulate this with "format".

    Please also note that in order to turn a binding off (to avoid duplicate bindings), you need to specify "pya.Action.NoKeyBound".

    Here is some example:

    mapping = {}
    mapping['file_menu.new_layout'] = "Ctrl+N"
    mapping['edit_menu.copy'] = pya.Action.NoKeyBound    # disable existing key binding
    
    config = pya.AbstractMenu.pack_key_binding(mapping)
    pya.Application.instance().set_config('key-bindings', config)
    

    Matthias

  • Thanks, Matthias. So, could I request the others I noted
    (Polygon, Box, Text, Path, Instance, Partial) be added to
    that "special-request gang at the bottom"?

    Or, is there a way for users to add key-bindings besides
    what is offered initially in the Configure pane, and if so,
    how to find out the proper names of "stuff we do in the
    GUI" so that bindkeys could invoke? I think it could be
    way handy, to be able to make a bindkey execute a
    Python script or whatever. If I had one.

    For that matter, "jailbreaking" the whole menu hierarchy?

    I certainly see many things I never use, and would like to
    make other "expressions" of the menus to reduce the
    "number of layers" traversed to get to the desired command
    (like, basic edit functions, I'd like to have at the top level
    rather than buried under classes like Selection, etc.).
    It would be cool to have key bindings and menus as
    "user-modifiable" adjunct files, I think, for propagating
    and preserving one's preferred environment.

  • @Matthias

    Learn something new every day thanks

Sign In or Register to comment.