Visualization¶
Classes for plotting, drawing, and displaying images and video.
Figures¶
- class mytk.figures.Figure(figure=None, figsize=None)[source]¶
Bases:
BaseWrapper around matplotlib Figure for embedding plots in tkinter.
- property figure¶
The underlying matplotlib Figure.
- property first_axis¶
The first axes of the figure, or None if unavailable.
- property axes¶
All axes of the figure, or None if the figure is not set.
CanvasView¶
- class mytk.canvasview.CanvasView(width=200, height=200, **kwargs)[source]¶
Bases:
BaseTkinter Canvas wrapper with coordinate system support.
- property relative_basis¶
A dynamic basis that tracks the current canvas size.
- property is_disabled¶
Whether the canvas and its children are disabled.
- class mytk.canvasview.CanvasElement(basis=None, **kwargs)[source]¶
Bases:
objectBase class for drawable elements on a CanvasView.
- property coords¶
The current coordinates of this element on the canvas.
- property tags¶
The tags associated with this element on the canvas.
- class mytk.canvasview.Rectangle(size: (<class 'int'>, <class 'int'>), basis=None, position_is_center=True, **kwargs)[source]¶
Bases:
CanvasElementA rectangle element for drawing on a CanvasView.
- class mytk.canvasview.Oval(size: (<class 'int'>, <class 'int'>), basis=None, position_is_center=True, **kwargs)[source]¶
Bases:
CanvasElementAn oval element for drawing on a CanvasView.
- class mytk.canvasview.Line(points=None, basis=None, **kwargs)[source]¶
Bases:
CanvasElementA line element connecting a series of points on a CanvasView.
- class mytk.canvasview.Arrow(start=None, end=None, **kwargs)[source]¶
Bases:
LineA line with an arrowhead at the end.
- class mytk.canvasview.CanvasLabel(font_size=20, basis=None, **kwargs)[source]¶
Bases:
CanvasElementA text label element for drawing on a CanvasView.
- class mytk.canvasview.Arc(radius, basis=None, **kwargs)[source]¶
Bases:
CanvasElementAn arc element for drawing on a CanvasView.
Data Views¶
- class mytk.dataviews.DataPoint(size: float, **kwargs)[source]¶
Bases:
OvalA circular data point drawn as an oval on a canvas.
- class mytk.dataviews.Function(fct, xs, basis=None, **kwarg)[source]¶
Bases:
CanvasElementA canvas element that draws a mathematical function as a polyline.
- class mytk.dataviews.XYCoordinateSystemElement(size=None, normalized_size=None, axes_limits=((0, 1), (0, 1)), **kwargs)[source]¶
Bases:
CanvasElementAn XY coordinate system with axes, ticks, and labels drawn on a canvas.
- property basis¶
Compute the coordinate basis from axes limits and canvas size.
Images¶
- class mytk.images.Image(filepath=None, url=None, pil_image=None)[source]¶
Bases:
BaseWidget for displaying a PIL image in a tkinter label.
- property width¶
The width of the source PIL image in pixels.
- property height¶
The height of the source PIL image in pixels.
- property displayed_width¶
The width of the currently displayed image in pixels.
- property displayed_height¶
The height of the currently displayed image in pixels.
- observed_property_changed(observed_object, observed_property_name, new_value, context)[source]¶
Handle changes to observed properties such as is_rescalable.
- event_resized(event)[source]¶
Resize the image if is_rescalable, throttling to avoid infinite loops.
- class mytk.images.ImageWithGrid(filepath=None, url=None, pil_image=None)[source]¶
Bases:
ImageImage widget with an optional grid overlay drawn on top.
- class mytk.images.DynamicImage(width=200, height=200)[source]¶
Bases:
CanvasViewCanvas-based image that can be redrawn dynamically.
VideoView¶
- class mytk.videoview.VideoView(device=0, zoom_level=3, auto_start=True)[source]¶
Bases:
BaseLive video capture and display widget backed by OpenCV.
- is_environment_valid()[source]¶
Check that OpenCV and Pillow are available, installing them if needed.
- classmethod available_devices()[source]¶
Return a list of indices for available video capture devices.
- property is_running¶
Return True if video capture is currently active.
- property startstop_button_label¶
Return the appropriate label for the start/stop button.
- update_display(readonly_frame=None)[source]¶
Read the next frame, update the display widget, and schedule the next refresh.
- create_behaviour_buttons()[source]¶
Create start/stop, save, and stream buttons with their callbacks.
- bind_button_to_startstop_behaviour(button)[source]¶
Bind a button to toggle video capture on and off.
- bind_button_to_save_behaviour(button)[source]¶
Bind a button to save the current frame as an image file.
- bind_button_to_stream_behaviour(button)[source]¶
Bind a button to start streaming frames to a video file.
- bind_popup_to_camera_selection_behaviour(popup)[source]¶
Bind a popup menu to switch the active camera device.
- click_start_stop_button(event, button)[source]¶
Toggle capture and update the button label accordingly.
- click_save_button(event, button)[source]¶
Prompt the user for a filename and save the current frame.
Indicators¶
- class mytk.indicators.NumericIndicator(value_variable=None, value=0, format_string='{0}')[source]¶
Bases:
BaseA label that displays a formatted numeric value from a tkinter variable.
- class mytk.indicators.BooleanIndicator(diameter=15)[source]¶
Bases:
CanvasViewA colored circle indicator that is green when True and red when False.
- class mytk.indicators.Level(maximum=100, width=200, height=20)[source]¶
Bases:
CanvasViewA horizontal bar indicator that fills proportionally to a value.