imagepanel

Based on ChartPanelBase, a canvas for displaying an image within a wxPython window using PIL and matplotlib, with a right click menu with some basic options

Classes:

EvtImgPanelChanged(windowID, obj)

Custom Event for an image in the ImagePanel being changed.

ImagePanel(parent[, image, id, pos, size, …])

Panel that contains a matplotlib plotting window, used for displaying an image.

class EvtImgPanelChanged(windowID, obj)[source]

Bases: PyCommandEvent

Custom Event for an image in the ImagePanel being changed.

Parameters
  • windowID (int)

  • obj

Attributes:

eventType

eventType = 0

Type:    int

class ImagePanel(parent, image=None, id=- 1, pos=(- 1, - 1), size=(- 1, - 1), style=0, name=b'panel')[source]

Bases: ChartPanelBase

Panel that contains a matplotlib plotting window, used for displaying an image. The image can be right clicked to bring up a context menu allowing copying, pasting and saving of the image. The image can be panned by holding the left mouse button and moving the mouse, and zoomed in and out using the scrollwheel on the mouse.

Parameters
  • parent (Window) – The parent window.

  • image – Default None.

  • id (int) – An identifier for the panel. wx.ID_ANY is taken to mean a default. Default -1.

  • pos (Point) – The panel position. The value wx.DefaultPosition indicates a default position, chosen by either the windowing system or wxWidgets, depending on platform. Default (-1, -1).

  • size (Size) – The panel size. The value ::wxDefaultSize indicates a default size, chosen by either the windowing system or wxWidgets, depending on platform. Default (-1, -1).

  • style (int) – The window style. See wxPanel. Default 0.

  • name (str) – Window name. Default b'panel'.

Methods:

clear([event])

Clear the image from the control

copy([_])

Copy the image to the clipboard.

load_image([new_image, suppress_event])

Load the ‘new_image’ into the control.

on_context_menu(event)

Event Handler for bringing up right click context menu

on_load([event])

Load the image into the dialog from the file selected in the dialog

on_save([event])

Save the image to the location selected in the dialog

paste([event])

Paste the image from the clipboard into the control.

reset_view(*_)

Reset the view of the image.

Attributes:

default_image

image

Returns the image being displayed in the control

clear(event=None)[source]

Clear the image from the control

copy(_=None)[source]

Copy the image to the clipboard.

default_image = ('RGB', (640, 480), (240, 240, 240))

Type:    tuple

property image

Returns the image being displayed in the control

Return type

PIL.Image.Image

load_image(new_image=None, suppress_event=False)[source]

Load the ‘new_image’ into the control.

Parameters
  • new_image (Union[Image, None, str, Path, PathLike]) – The image to load, or a string pointing to the image on a filesystem. Default None.

  • suppress_event (bool) – Whether the event that the image has changed should be suppressed. Default False.

on_context_menu(event)[source]

Event Handler for bringing up right click context menu

on_load(event=None)[source]

Load the image into the dialog from the file selected in the dialog

on_save(event=None)[source]

Save the image to the location selected in the dialog

paste(event=None)[source]

Paste the image from the clipboard into the control.

reset_view(*_)[source]

Reset the view of the image.