Skip to content

whitecanvas.tools

Built-in tools.

lasso_selector(canvas, buttons='left', modifiers=None, *, tracking=False)

Create a Lasso selector tool with given settings.

A Lasso selector emits a XYData object by freehand drawing. A selection tool is constructed by specifying the canvas to attach the tool.

canvas = new_canvas("matplotlib:qt") tool = lasso_selector(canvas)

Use buttons and modifiers to specify how to trigger the tool.

tool = lasso_selector(canvas, buttons="right", modifiers="ctrl")

Parameters:

Name Type Description Default
canvas CanvasBase

The canvas to which the tool is attached.

required
buttons MouseButton or Sequence[MouseButton]

The mouse buttons that can trigger the tool.

"left"
modifiers Modifier or Sequence[Modifier]

The modifier keys that must be pressed to trigger the tool.

None
tracking bool

If True, the tool emits the changed signal while dragging. Otherwise, it emits the signal only when dragging is finished.

False
Source code in whitecanvas\tools\_selection.py
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
def lasso_selector(
    canvas: CanvasBase,
    buttons: _MouseButton | Sequence[_MouseButton] = "left",
    modifiers: _Modifier | Sequence[_Modifier] | None = None,
    *,
    tracking: bool = False,
) -> LassoSelectionTool:
    """
    Create a Lasso selector tool with given settings.

    A Lasso selector emits a XYData object by freehand drawing.
    A selection tool is constructed by specifying the canvas to attach the tool.

    >>> canvas = new_canvas("matplotlib:qt")
    >>> tool = lasso_selector(canvas)

    Use `buttons` and `modifiers` to specify how to trigger the tool.

    >>> tool = lasso_selector(canvas, buttons="right", modifiers="ctrl")

    Parameters
    ----------
    canvas : CanvasBase
        The canvas to which the tool is attached.
    buttons : MouseButton or Sequence[MouseButton], default "left"
        The mouse buttons that can trigger the tool.
    modifiers : Modifier or Sequence[Modifier], optional
        The modifier keys that must be pressed to trigger the tool.
    tracking : bool, default False
        If True, the tool emits the changed signal while dragging. Otherwise, it emits
        the signal only when dragging is finished.
    """
    _buttons, _modifiers = _norm_input(buttons, modifiers)
    return LassoSelectionTool(canvas, _buttons, _modifiers, tracking=tracking)

line_selector(canvas, buttons='left', modifiers=None, *, tracking=False)

Create a line selector tool with given settings.

A line selector emits a LineSelection object when a line is drawn. A selection tool is constructed by specifying the canvas to attach the tool.

canvas = new_canvas("matplotlib:qt") tool = line_selector(canvas)

Use buttons and modifiers to specify how to trigger the tool.

tool = line_selector(canvas, buttons="right", modifiers="ctrl")

Parameters:

Name Type Description Default
canvas CanvasBase

The canvas to which the tool is attached.

required
buttons MouseButton or Sequence[MouseButton]

The mouse buttons that can trigger the tool.

"left"
modifiers Modifier or Sequence[Modifier]

The modifier keys that must be pressed to trigger the tool.

None
tracking bool

If True, the tool emits the changed signal while dragging. Otherwise, it emits the signal only when dragging is finished.

False
Source code in whitecanvas\tools\_selection.py
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
def line_selector(
    canvas: CanvasBase,
    buttons: _MouseButton | Sequence[_MouseButton] = "left",
    modifiers: _Modifier | Sequence[_Modifier] | None = None,
    *,
    tracking: bool = False,
) -> LineSelectionTool:
    """
    Create a line selector tool with given settings.

    A line selector emits a LineSelection object when a line is drawn.
    A selection tool is constructed by specifying the canvas to attach the tool.

    >>> canvas = new_canvas("matplotlib:qt")
    >>> tool = line_selector(canvas)

    Use `buttons` and `modifiers` to specify how to trigger the tool.

    >>> tool = line_selector(canvas, buttons="right", modifiers="ctrl")

    Parameters
    ----------
    canvas : CanvasBase
        The canvas to which the tool is attached.
    buttons : MouseButton or Sequence[MouseButton], default "left"
        The mouse buttons that can trigger the tool.
    modifiers : Modifier or Sequence[Modifier], optional
        The modifier keys that must be pressed to trigger the tool.
    tracking : bool, default False
        If True, the tool emits the changed signal while dragging. Otherwise, it emits
        the signal only when dragging is finished.
    """
    _buttons, _modifiers = _norm_input(buttons, modifiers)
    return LineSelectionTool(canvas, _buttons, _modifiers, tracking=tracking)

polygon_selector(canvas, buttons='left', modifiers=None, *, tracking=False)

Create a polygon selector tool with given settings.

A polygon selector emits a XYData object by freehand drawing. A selection tool is constructed by specifying the canvas to attach the tool.

canvas = new_canvas("matplotlib:qt") tool = polygon_selector(canvas)

Use buttons and modifiers to specify how to trigger the tool.

tool = polygon_selector(canvas, buttons="right", modifiers="ctrl")

Parameters:

Name Type Description Default
canvas CanvasBase

The canvas to which the tool is attached.

required
buttons MouseButton or Sequence[MouseButton]

The mouse buttons that can trigger the tool.

"left"
modifiers Modifier or Sequence[Modifier]

The modifier keys that must be pressed to trigger the tool.

None
tracking bool

If True, the tool emits the changed signal while dragging. Otherwise, it emits the signal only when dragging is finished.

False
Source code in whitecanvas\tools\_selection.py
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
def polygon_selector(
    canvas: CanvasBase,
    buttons: _MouseButton | Sequence[_MouseButton] = "left",
    modifiers: _Modifier | Sequence[_Modifier] | None = None,
    *,
    tracking: bool = False,
) -> LassoSelectionTool:
    """
    Create a polygon selector tool with given settings.

    A polygon selector emits a XYData object by freehand drawing.
    A selection tool is constructed by specifying the canvas to attach the tool.

    >>> canvas = new_canvas("matplotlib:qt")
    >>> tool = polygon_selector(canvas)

    Use `buttons` and `modifiers` to specify how to trigger the tool.

    >>> tool = polygon_selector(canvas, buttons="right", modifiers="ctrl")

    Parameters
    ----------
    canvas : CanvasBase
        The canvas to which the tool is attached.
    buttons : MouseButton or Sequence[MouseButton], default "left"
        The mouse buttons that can trigger the tool.
    modifiers : Modifier or Sequence[Modifier], optional
        The modifier keys that must be pressed to trigger the tool.
    tracking : bool, default False
        If True, the tool emits the changed signal while dragging. Otherwise, it emits
        the signal only when dragging is finished.
    """
    _buttons, _modifiers = _norm_input(buttons, modifiers)
    return PolygonSelectionTool(canvas, _buttons, _modifiers, tracking=tracking)

rect_selector(canvas, buttons='left', modifiers=None, *, tracking=False)

Create a rectangle selector tool with given settings.

A rectangle selector emits a Rect object when a rectangle is drawn. A selection tool is constructed by specifying the canvas to attach the tool.

canvas = new_canvas("matplotlib:qt") tool = rect_selector(canvas)

Use buttons and modifiers to specify how to trigger the tool.

tool = rect_selector(canvas, buttons="right", modifiers="ctrl")

Parameters:

Name Type Description Default
canvas CanvasBase

The canvas to which the tool is attached.

required
buttons MouseButton or Sequence[MouseButton]

The mouse buttons that can trigger the tool.

"left"
modifiers Modifier or Sequence[Modifier]

The modifier keys that must be pressed to trigger the tool.

None
tracking bool

If True, the tool emits the changed signal while dragging. Otherwise, it emits the signal only when dragging is finished.

False
Source code in whitecanvas\tools\_selection.py
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
def rect_selector(
    canvas: CanvasBase,
    buttons: _MouseButton | Sequence[_MouseButton] = "left",
    modifiers: _Modifier | Sequence[_Modifier] | None = None,
    *,
    tracking: bool = False,
) -> RectSelectionTool:
    """
    Create a rectangle selector tool with given settings.

    A rectangle selector emits a Rect object when a rectangle is drawn.
    A selection tool is constructed by specifying the canvas to attach the tool.

    >>> canvas = new_canvas("matplotlib:qt")
    >>> tool = rect_selector(canvas)

    Use `buttons` and `modifiers` to specify how to trigger the tool.

    >>> tool = rect_selector(canvas, buttons="right", modifiers="ctrl")

    Parameters
    ----------
    canvas : CanvasBase
        The canvas to which the tool is attached.
    buttons : MouseButton or Sequence[MouseButton], default "left"
        The mouse buttons that can trigger the tool.
    modifiers : Modifier or Sequence[Modifier], optional
        The modifier keys that must be pressed to trigger the tool.
    tracking : bool, default False
        If True, the tool emits the changed signal while dragging. Otherwise, it emits
        the signal only when dragging is finished.
    """
    _buttons, _modifiers = _norm_input(buttons, modifiers)
    return RectSelectionTool(canvas, _buttons, _modifiers, tracking=tracking)

xspan_selector(canvas, buttons='left', modifiers=None, *, tracking=False)

Create a x-span selector tool with given settings.

A x-span selector emits a SpanSelection object (tuple of start and end) when a span is drawn. A selection tool is constructed by specifying the canvas to attach the tool.

canvas = new_canvas("matplotlib:qt") tool = xspan_selector(canvas)

Use buttons and modifiers to specify how to trigger the tool.

tool = line_selector(canvas, buttons="right", modifiers="ctrl")

Parameters:

Name Type Description Default
canvas CanvasBase

The canvas to which the tool is attached.

required
buttons MouseButton or Sequence[MouseButton]

The mouse buttons that can trigger the tool.

"left"
modifiers Modifier or Sequence[Modifier]

The modifier keys that must be pressed to trigger the tool.

None
tracking bool

If True, the tool emits the changed signal while dragging. Otherwise, it emits the signal only when dragging is finished.

False
Source code in whitecanvas\tools\_selection.py
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
def xspan_selector(
    canvas: CanvasBase,
    buttons: _MouseButton | Sequence[_MouseButton] = "left",
    modifiers: _Modifier | Sequence[_Modifier] | None = None,
    *,
    tracking: bool = False,
) -> XSpanSelectionTool:
    """
    Create a x-span selector tool with given settings.

    A x-span selector emits a SpanSelection object (tuple of start and end) when a span
    is drawn.
    A selection tool is constructed by specifying the canvas to attach the tool.

    >>> canvas = new_canvas("matplotlib:qt")
    >>> tool = xspan_selector(canvas)

    Use `buttons` and `modifiers` to specify how to trigger the tool.

    >>> tool = line_selector(canvas, buttons="right", modifiers="ctrl")

    Parameters
    ----------
    canvas : CanvasBase
        The canvas to which the tool is attached.
    buttons : MouseButton or Sequence[MouseButton], default "left"
        The mouse buttons that can trigger the tool.
    modifiers : Modifier or Sequence[Modifier], optional
        The modifier keys that must be pressed to trigger the tool.
    tracking : bool, default False
        If True, the tool emits the changed signal while dragging. Otherwise, it emits
        the signal only when dragging is finished.
    """
    _buttons, _modifiers = _norm_input(buttons, modifiers)
    return XSpanSelectionTool(canvas, _buttons, _modifiers, tracking=tracking)

yspan_selector(canvas, buttons='left', modifiers=None, *, tracking=False)

Create a line selector tool with given settings.

A y-span selector emits a SpanSelection object (tuple of start and end) when a span is drawn. A selection tool is constructed by specifying the canvas to attach the tool.

canvas = new_canvas("matplotlib:qt") tool = yspan_selector(canvas)

Use buttons and modifiers to specify how to trigger the tool.

tool = line_selector(canvas, buttons="right", modifiers="ctrl")

Parameters:

Name Type Description Default
canvas CanvasBase

The canvas to which the tool is attached.

required
buttons MouseButton or Sequence[MouseButton]

The mouse buttons that can trigger the tool.

"left"
modifiers Modifier or Sequence[Modifier]

The modifier keys that must be pressed to trigger the tool.

None
tracking bool

If True, the tool emits the changed signal while dragging. Otherwise, it emits the signal only when dragging is finished.

False
Source code in whitecanvas\tools\_selection.py
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
def yspan_selector(
    canvas: CanvasBase,
    buttons: _MouseButton | Sequence[_MouseButton] = "left",
    modifiers: _Modifier | Sequence[_Modifier] | None = None,
    *,
    tracking: bool = False,
) -> YSpanSelectionTool:
    """
    Create a line selector tool with given settings.

    A y-span selector emits a SpanSelection object (tuple of start and end) when a span
    is drawn.
    A selection tool is constructed by specifying the canvas to attach the tool.

    >>> canvas = new_canvas("matplotlib:qt")
    >>> tool = yspan_selector(canvas)

    Use `buttons` and `modifiers` to specify how to trigger the tool.

    >>> tool = line_selector(canvas, buttons="right", modifiers="ctrl")

    Parameters
    ----------
    canvas : CanvasBase
        The canvas to which the tool is attached.
    buttons : MouseButton or Sequence[MouseButton], default "left"
        The mouse buttons that can trigger the tool.
    modifiers : Modifier or Sequence[Modifier], optional
        The modifier keys that must be pressed to trigger the tool.
    tracking : bool, default False
        If True, the tool emits the changed signal while dragging. Otherwise, it emits
        the signal only when dragging is finished.
    """
    _buttons, _modifiers = _norm_input(buttons, modifiers)
    return YSpanSelectionTool(canvas, _buttons, _modifiers, tracking=tracking)