attachο
- class eomaps._cb_container._click_container._attach(parent)ο
Attach custom or pre-defined callbacks to the map.
Each callback-function takes 2 additional keyword-arguments:
- double_clickbool
Indicator if the callback should be executed on double-click (True) or on single-click events (False). The default is False
- buttonint
The mouse-button to use for executing the callback:
LEFT = 1
MIDDLE = 2
RIGHT = 3
BACK = 8
FORWARD = 9
The default is None in which case 1 (e.g. LEFT is used)
- modifierstr or None
Define a keypress-modifier to execute the callback only if the corresponding key is pressed on the keyboard.
If None, the callback is executed if no modifier is activated.
The default is None.
- on_motionbool
!! Only relevant for βclickβ callbacks !!
True: Continuously execute the callback if the mouse is moved while the assigned button is pressed.
False: Only execute the callback on clicks.
The default is True.
For additional keyword-arguments check the doc of the callback-functions!
Examples
Get a (temporary) annotation on a LEFT-double-click:
>>> m.cb.click.attach.annotate(double_click=True, button=1, permanent=False)
Permanently color LEFT-clicked pixels red with a black border:
>>> m.cb.pick.attach.mark(facecolor="r", edgecolor="k", permanent=True)
Attach a customly defined callback
>>> def some_callback(self, asdf, **kwargs): >>> print("hello world") >>> print("the position of the clicked pixel", kwargs["pos"]) >>> print("the data-index of the clicked pixel", kwargs["ID"]) >>> print("data-value of the clicked pixel", kwargs["val"]) >>> print("the plot-crs is:", self.crs_plot)
>>> m.cb.pick.attach(some_callback, double_click=False, button=1, asdf=1)
- __call__(f, double_click=False, button=None, modifier=None, **kwargs)ο
add a custom callback-function to the map
- Parameters
f (callable) β
the function to attach to the map. The call-signature is:
>>> def some_callback(asdf, **kwargs): >>> print("hello world") >>> print("the position of the clicked pixel", kwargs["pos"]) >>> print("the data-index of the clicked pixel", kwargs["ID"]) >>> print("data-value of the clicked pixel", kwargs["val"]) >>> >>> m.cb.attach(some_callback, asdf=1)
double_click (bool) β Indicator if the callback should be executed on double-click (True) or on single-click events (False)
button (int) β
The mouse-button to use for executing the callback:
LEFT = 1
MIDDLE = 2
RIGHT = 3
BACK = 8
FORWARD = 9
The default is None in which case 1 (e.g. the LEFT button) is used
modifier (str or None) β
Define a keypress-modifier to execute the callback only if the corresponding key is pressed on the keyboard.
If None, the callback is executed if no modifier is activated.
The default is None.
on_motion (bool) β
!! Only relevant for βclickβ callbacks !!
True: Continuously execute the callback if the mouse is moved while the assigned button is pressed.
False: Only execute the callback on clicks.
The default is True.
kwargs β kwargs passed to the callback-function For documentation of the individual functions check the docs in m.cb
- Returns
cid β the ID of the attached callback
- Return type
int