MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / Image

Class Image

PySimpleGUI/PySimpleGUI.py:5745–6036  ·  view source on GitHub ↗

Image Element - show an image in the window. Should be a GIF or a PNG only

Source from the content-addressed store, hash-verified

5743# Image #
5744# ---------------------------------------------------------------------- #
5745class Image(Element):
5746 """
5747 Image Element - show an image in the window. Should be a GIF or a PNG only
5748 """
5749
5750 def __init__(self, source=None, filename=None, data=None, background_color=None, size=(None, None), s=(None, None), pad=None, p=None, key=None, k=None, tooltip=None,
5751 subsample=None, zoom=None, right_click_menu=None, expand_x=False, expand_y=False, visible=True, enable_events=False, metadata=None):
5752 """
5753 :param source: A filename or a base64 bytes. Will automatically detect the type and fill in filename or data for you.
5754 :type source: str | bytes | None
5755 :param filename: image filename if there is a button image. GIFs and PNGs only.
5756 :type filename: str | None
5757 :param data: Raw or Base64 representation of the image to put on button. Choose either filename or data
5758 :type data: bytes | str | None
5759 :param background_color: color of background
5760 :type background_color:
5761 :param size: (width, height) size of image in pixels
5762 :type size: (int, int)
5763 :param s: Same as size parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, size will be used
5764 :type s: (int, int) | (None, None) | int
5765 :param pad: Amount of padding to put around element in pixels (left/right, top/bottom) or ((left, right), (top, bottom)) or an int. If an int, then it's converted into a tuple (int, int)
5766 :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
5767 :param p: Same as pad parameter. It's an alias. If EITHER of them are set, then the one that's set will be used. If BOTH are set, pad will be used
5768 :type p: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
5769 :param key: Used with window.find_element and with return values to uniquely identify this element to uniquely identify this element
5770 :type key: str | int | tuple | object
5771 :param k: Same as the Key. You can use either k or key. Which ever is set will be used.
5772 :type k: str | int | tuple | object
5773 :param tooltip: text, that will appear when mouse hovers over the element
5774 :type tooltip: (str)
5775 :param subsample: amount to reduce the size of the image. Divides the size by this number. 2=1/2, 3=1/3, 4=1/4, etc
5776 :type subsample: (int)
5777 :param zoom: amount to increase the size of the image.
5778 :type zoom: (int)
5779 :param right_click_menu: A list of lists of Menu items to show when this element is right clicked. See user docs for exact format.
5780 :type right_click_menu: List[List[ List[str] | str ]]
5781 :param expand_x: If True the element will automatically expand in the X direction to fill available space
5782 :type expand_x: (bool)
5783 :param expand_y: If True the element will automatically expand in the Y direction to fill available space
5784 :type expand_y: (bool)
5785 :param visible: set visibility state of the element
5786 :type visible: (bool)
5787 :param enable_events: Turns on the element specific events. For an Image element, the event is "image clicked"
5788 :type enable_events: (bool)
5789 :param metadata: User metadata that can be set to ANYTHING
5790 :type metadata: (Any)
5791 """
5792
5793 if source is not None:
5794 if isinstance(source, bytes):
5795 data = source
5796 elif isinstance(source, str):
5797 filename = source
5798 else:
5799 warnings.warn('Image element - source is not a valid type: {}'.format(type(source)), UserWarning)
5800
5801 self.Filename = filename
5802 self.Data = data

Callers 10

__init__Method · 0.85
TitlebarFunction · 0.85
popupFunction · 0.85
popup_scrolledFunction · 0.85
popup_get_folderFunction · 0.85
popup_get_fileFunction · 0.85
popup_get_textFunction · 0.85
popup_animatedFunction · 0.85
_error_popup_with_codeFunction · 0.85
_create_main_windowFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected