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

Class ButtonMenu

PySimpleGUI/PySimpleGUI.py:5329–5570  ·  view source on GitHub ↗

The Button Menu Element. Creates a button that when clicked will show a menu similar to right click menu

Source from the content-addressed store, hash-verified

5327# ButtonMenu Class #
5328# ---------------------------------------------------------------------- #
5329class ButtonMenu(Element):
5330 """
5331 The Button Menu Element. Creates a button that when clicked will show a menu similar to right click menu
5332 """
5333
5334 def __init__(self, button_text, menu_def, tooltip=None, disabled=False, image_source=None,
5335 image_filename=None, image_data=None, image_size=(None, None), image_subsample=None, image_zoom=None, border_width=None,
5336 size=(None, None), s=(None, None), auto_size_button=None, button_color=None, text_color=None, background_color=None, disabled_text_color=None,
5337 font=None, item_font=None, pad=None, p=None, expand_x=False, expand_y=False, key=None, k=None, tearoff=False, visible=True,
5338 metadata=None):
5339 """
5340 :param button_text: Text to be displayed on the button
5341 :type button_text: (str)
5342 :param menu_def: A list of lists of Menu items to show when this element is clicked. See docs for format as they are the same for all menu types
5343 :type menu_def: List[List[str]]
5344 :param tooltip: text, that will appear when mouse hovers over the element
5345 :type tooltip: (str)
5346 :param disabled: If True button will be created disabled
5347 :type disabled: (bool)
5348 :param image_source: Image to place on button. Use INSTEAD of the image_filename and image_data. Unifies these into 1 easier to use parm
5349 :type image_source: (str | bytes)
5350 :param image_filename: image filename if there is a button image. GIFs and PNGs only.
5351 :type image_filename: (str)
5352 :param image_data: Raw or Base64 representation of the image to put on button. Choose either filename or data
5353 :type image_data: bytes | str
5354 :param image_size: Size of the image in pixels (width, height)
5355 :type image_size: (int, int)
5356 :param image_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
5357 :type image_subsample: (int)
5358 :param image_zoom: amount to increase the size of the image. 2=twice size, 3=3 times, etc
5359 :type image_zoom: (int)
5360 :param border_width: width of border around button in pixels
5361 :type border_width: (int)
5362 :param size: (w, h) w=characters-wide, h=rows-high. If an int instead of a tuple is supplied, then height is auto-set to 1
5363 :type size: (int, int) | (None, None) | int
5364 :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
5365 :type s: (int, int) | (None, None) | int
5366 :param auto_size_button: if True the button size is sized to fit the text
5367 :type auto_size_button: (bool)
5368 :param button_color: of button. Easy to remember which is which if you say "ON" between colors. "red" on "green"
5369 :type button_color: (str, str) | str
5370 :param background_color: color of the background
5371 :type background_color: (str)
5372 :param text_color: element's text color. Can be in #RRGGBB format or a color name "black"
5373 :type text_color: (str)
5374 :param disabled_text_color: color to use for text when item is disabled. Can be in #RRGGBB format or a color name "black"
5375 :type disabled_text_color: (str)
5376 :param font: specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
5377 :type font: (str or (str, int[, str]) or None)
5378 :param item_font: specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike, for the menu items
5379 :type item_font: (str or (str, int[, str]) or None)
5380 :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)
5381 :type pad: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
5382 :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
5383 :type p: (int, int) or ((int, int),(int,int)) or (int,(int,int)) or ((int, int),int) | int
5384 :param expand_x: If True the element will automatically expand in the X direction to fill available space
5385 :type expand_x: (bool)
5386 :param expand_y: If True the element will automatically expand in the Y direction to fill available space

Callers 2

MenubarCustomFunction · 0.85
_create_main_windowFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected