kqcircuits.util.gui_helper.get_nodes_near_position(top_cell, position, box_size=10, require_gui_editing_enabled=True)[source]

Find all WaveguideComposite nodes near a specified position.

Considers only waveguides that are a direct child of the specified top_cell.

  • top_cell – cell in which to search for WaveguideComposite instances

  • position – pya.DPoint position where to search for nodes

  • box_size – capture distance in x,y away from position where the node can be

  • require_gui_editing_enabled – if True, only instances with enable_gui_editing==True are considered.


a list of tuples (instance, node, node_index) where instance is the WaveguideComposite Instance, node is the Node object that node_index is the index of node in the nodes parameter of the waveguide.


Convert Node object to text fields that can be used for GUI editing.

The inverse of this function is node_from_text.


node – Node to convert


tuple of strings (x, y, element, inst_name, angle, length_before, length_increment, align, parameters)

kqcircuits.util.gui_helper.node_from_text(x, y, element, inst_name, angle, length_before, length_increment, align, parameters)[source]

Create Node from text inputs.

This is the inverse of node_to_text.

For all arguments except x and y, an empty string is treated as default value. Spaces are stripped from the inputs. For parameters, the values will be parsed by ast.literal_eval, which accepts most standard python literals.

  • x (str) – x position, will be converted to float

  • y (str) – y position, will be converted to float

  • element (str) – class name of the element, must exist in the kqcircuits.elements namespace

  • inst_name (str) – instance name to use for the element

  • angle (str) – angle of the node, will be converted to float

  • length_before (str) – length before this node, will be converted to float

  • length_increment (str) – length increment produced by meander before this node, will be converted to float

  • align (str) – input and output refpoint to use for aligning the element, separated by a comma

  • parameters (str) – multiline string, where each line contains a parameter=value pair.

Returns: Node


ValueError – if an input value cannot be converted to the correct type.

kqcircuits.util.gui_helper.replace_node(waveguide_instance, node_index, node)[source]

Replace a Node in a WaveguideComposite by index.

  • waveguide_instance – Instance of the waveguide

  • node_index – (int) index of the node to replace

  • node – new Node


Returns all class names from PCells in the Element library which can be used in WaveguideComposite nodes


List of class names (str)


Returns a list of all element class names which would be, at least in principle, usable as `Node.element`.

An element is considered valid if it has at least two refpoint pairs `X` and `X_corner`, for any value of x.

Note: this function creates each element with default parameter values. Since this is generally slow and clumsy, this function is not used at startup. Instead, a curated list `node_editor_valid_elements` is kept in `kqcircuits.defaults`.


List of class names (str)