pypeit.core.gui.gui_util module

GUI utilities

class pypeit.core.gui.gui_util.Pointer(ax, **kwargs)[source]

Bases: AxesWidget

A pointer widget

Parameters:
  • ax (matplotlib.image.AxesImage) – Returned object after running matplotlib.pyplot.imshow plotting an image to point within.

  • kwargs (dict) – Passed directly to matplotlib.widgets.Cursor.

_button_update(event)[source]

Execute an event created by a button press.

_event_update(event, event_type)[source]

Update the pointer position

Parameters:
_key_update(event)[source]

Execute an event created by a key or mouse press.

_set_event(action, x, y)[source]

Execute an event.

Parameters:
  • action (str) – The keyword for the event action to perform

  • x (float) – X position in the pyplot window where the event took place

  • y (float) – Y position in the pyplot window where the event took place

build_help()[source]

Register the help dialog. Any action already assigned to the ‘?’ key will be removed!

disconnect(action)[source]

Remove the action from the register.

Parameters:

action (str) – The keyword for the event action to remove

print_help(pos)[source]

Print the help dialog.

This is an event call-back function that must accept an array-like object giving the pointer coordinates.

Parameters:

pos (array-like) – List with x and y position of the cursor at the time of the window event.

register(action, func, descr=None)[source]

Register a function to associate with a specific button or key press.

All functions must have the same calling sequence (see _set_event()), which is that they only accept a tuple with the coordinates of the cursor when the event occurred.

Parameters:
  • action (str) – The keyword for the event action to perform

  • func (callable) – The function to call when the corresponding event is triggered

  • descr (str, optional) – The description of the action being taken. Used to build a help dialog.

class pypeit.core.gui.gui_util.UpdateableImage(images, image_plot, slider)[source]

Bases: object

Provides an interface to change the Z range of an image and toggle between a set of images.

Parameters:
change_range(val)[source]

Adjust the plotted range.

Parameters:

val (list) – New range to plot

next_image(*args)[source]

Got to the next image in the list.

All arguments to this function are accepted but ignored. The reason is because this is the function passed to matplotlib.widgets.Button.on_clicked, but this function does not need any of the input from the Button event.

class pypeit.core.gui.gui_util.UpdateableRangeSlider(ax, label, valmin, valmax, valinit=None, valfmt=None, closedmin=True, closedmax=True, dragging=True, valstep=None, orientation='horizontal', track_color='lightgrey', handle_style=None, **kwargs)[source]

Bases: RangeSlider

A range slider.

This is virtually identical to the base class, but with a few customizations regarding where labels are placed (or removed).

See matplotlib.widgets.RangeSlider for the argument descriptions.

update_range(rng, label=None)[source]

Update the slider to cover a different range.

Parameters:
  • rng (array-like) – Two-element array like object setting the new limits for the slider.

  • label (str, optional) – New label for the updated slider. If None, the label remains unchanged.

pypeit.core.gui.gui_util.clean_pyplot_keymap()[source]

Remove all default key bindings for a matplotlib plot window.