Mouse And Keyboard Input#

squap.on_mouse_click(func, pixel_mode=False)[source]#

Bind function to run on mouse click. As arguments it gets the position of the mouse; in pixels if pixel_mode is set to True and in coordinates if set to False. The second argument that is passed is which mouse button is clicked.

Parameters:
  • func (callable) – The function that is called when the mouse is clicked. The function can take up to 2 arguments: the first is the mouse position, the second is the pyqtgraph internal event for more advanced usage.

  • pixel_mode (bool) – whether to return pixels from the top left (True), or coordinates (False). Defaults to False.

todo: check all MouseClickEvent options, and check with middle mouse button todo: automatically determine which ax.

squap.on_mouse_move(func, pixel_mode=False)[source]#

Bind a function to mouse move.

Parameters:
  • func (callable) – The function that is called when the mouse is moved. The function receives the mouse position as an argument.

  • pixel_mode (bool) – whether to return pixels from the top left (True), or coordinates (False). Defaults to False.

squap.get_mouse_pos(pixel_mode=False)[source]#

Get the position of the mouse cursor on the plot, either as pixels from the top left, or as coordinates.

Parameters:

pixel_mode (bool) – whether to return pixels from the top left (True), or coordinates (False). Defaults to False.

Returns:

The coordinates of the mouse cursor on the plot.

Return type:

tuple

squap.on_key_press(
func,
accept_modifier=False,
modifier_arg=False,
event_arg=False,
)[source]#

Bind func to keypress. func takes as argument which key is pressed. This function is not great yet but good enough for simple stuff. For complex stuff look into event_arg for now.

Parameters:
  • func (callable) – The function that is called when the key is pressed.

  • accept_modifier (bool) – Whether to call the function when the input is a modifier, such as shift or alt. Defaults to False.

  • modifier_arg (bool) – Whether to call the function with the modifier as an extra argument. Defaults to False.

  • event_arg (bool) – Whether to call the function with just the event as an argument. This is more complex to deal with but much more versatile. Defaults to False.

Returns:

The edited function that accepts the arguments listed above.

Return type:

callable