Web Analytics Made Easy - Statcounter
Skip to content

Canvas

Canvas Element

Canvas(
    canvas = None,
    background_color = None,
    size = (None, None),
    pad = None,
    key = None,
    k = None,
    tooltip = None,
    metadata = None
)

Parameter Descriptions

Name Type Default Description
background_color str None color of background. Can be in #RRGGBB format or a color name "black"
canvas (tk.Canvas) or None None Your own Canvas if you already created it. Leave blank to create a Canvas
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
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) (width in char, height in rows) size in pixels to make canvas
tooltip str None text, that will appear when mouse hovers over the element

Class Properties

tk_canvas

tk_canvas

Returns the underlying tkinter Canvas widget

tk_canvas
Parameter Descriptions

Name Type Default Description
RETURN (tk.Canvas) The tkinter canvas widget

Class Methods

 def expand
 def get_stylesheet
 def set_stylesheet
 def update

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

Updates the element

update(
    widget,
    background_color = None,
    text_color = None,
    font = None,
    visible = None
)

Parameter Descriptions

Name Type Default Description
background_color str None color of background. Can be in #RRGGBB format or a color name "black"
font (str or (str, int[, str]) or None) None specifies the font family, size. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
text_color str None element's text color. Can be in #RRGGBB format or a color name "black"
visible bool None set visibility state of the element (Default = True)
widget The widget to be updated