Web Analytics Made Easy - Statcounter
Skip to content

ButtonMenu

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

ButtonMenu(
    button_text,
    menu_def,
    tooltip = None,
    disabled = False,
    image_filename = None,
    image_data = None,
    image_size = (None, None),
    image_subsample = None,
    border_width = None,
    size = (None, None),
    auto_size_button = None,
    button_color = None,
    font = None,
    pad = None,
    key = None,
    k = None,
    visible = True,
    size_px = (None, None),
    metadata = None
)

Parameter Descriptions

Name Type Default Description
auto_size_button bool None if True the button size is sized to fit the text
border_width int None width of border around button in pixels
button_color (str, str) or str None of button. Easy to remember which is which if you say "ON" between colors. "red" on "green"
button_text str Text to be displayed on the button
disabled bool False If True button will be created disabled
font (str or (str, int[, str]) or None) None specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
image_data bytes or str None Raw or Base64 representation of the image to put on button. Choose either filename or data
image_filename str None image filename if there is a button image. GIFs and PNGs only.
image_size (int, int) (None, None) Size of the image in pixels (width, height)
image_subsample int None amount to reduce the size of the image. Divides the size by this number. 2=1/2, 3=1/3, 4=1/4, etc
k str or int or tuple or object None Same as the Key. You can use either k or key. Which ever is set will be used.
key str or int or tuple or object None Used with window.find_element and with return values to uniquely identify this element to uniquely identify this element
menu_def List[List[str]] 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
metadata Any None User metadata that can be set to ANYTHING
pad (int, int or (int, int),(int,int) or int,(int,int)) or ((int, int),int) None 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)
size (int, int) or (None, None) (None, None) (w, h) w=characters-wide, h=rows-high. If an int instead of a tuple is supplied, then height is auto-set to 1
size_px (int, int) or (None, None) (None, None) w=pixels-wide, h=pixels-high
tooltip str None text, that will appear when mouse hovers over the element
visible bool True set visibility state of the element

Class Properties

This class has no public properties

Class Methods

 def click
 def expand
 def get_stylesheet
 def set_stylesheet
 def update

click

Generates a click of the button as if the user clicked the button Calls the invoke method for the button

click()

expand

WARNING - NOT USED IN PySimpleGUIQt port. Provided as dummy method

expand(
    expand_x = False,
    expand_y = False,
    expand_row = True
)

Parameter Descriptions

Name Type Default Description
expand_row bool True If True the row containing the element will also expand. Without this your element is "trapped" within the row
expand_x bool False If True Element will expand in the Horizontal directions
expand_y bool False If True Element will expand in the Vertical directions
RETURN None None

get_stylesheet

Returns the stylesheet for element's associated Qt Widget

get_stylesheet()

Parameter Descriptions

Name Type Default Description
RETURN str stylesheet

set_stylesheet

Sets the stylesheet for a Qt Widget

set_stylesheet(
    stylesheet
)

Parameter Descriptions

Name Type Default Description
stylesheet str Stylesheet (string) to set stylesheet to

update

Changes some of the settings for the ButtonMenu Element. Must call Window.Read or Window.Finalize prior

Changes will not be visible in your window until you call window.read or window.refresh.

If you change visibility, your element may MOVE.

update(
    menu_definition = None,
    text = None,
    button_color = (None, None),
    font = None,
    visible = None
)

Parameter Descriptions

Name Type Default Description
button_color (str, str) or str (None, None) of button. Easy to remember which is which if you say "ON" between colors. "red" on "green"
font (str or (str, int[, str]) or None) None specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
menu_definition List[List] None (New menu definition (in menu definition format)
text str None Text to be displayed on the button
visible bool None control visibility of element