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_modeis set toTrueand in coordinates if set toFalse. 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 toFalse.
todo: check all MouseClickEvent options, and check with middle mouse button todo: automatically determine which ax.
- 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.
- squap.on_key_press(
- func,
- accept_modifier=False,
- modifier_arg=False,
- event_arg=False,
Bind
functo keypress.functakes 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: