PySimpleGUI – Element Class


PySimpleGUI – Element Class



”;


The PySimpleGUI library consists of a number of GUI widgets that can be placed on top of the Window object. For instance, the buttons or the textboxes that we have used in the above examples. All these widgets are in fact objects of classes defined in this library, in which Element class acts as the base for all other widget classes.

An object of this Element class is never declared explicitly. It defines the common properties like size, color, etc. Here is the list of the available widgets (also called elements)


























Sr.No. Widget & Description
1 Text Element

Display some text in the window. Usually this means a single line of text.

2 Input Element

Display a single text input field.

3 Multiline Element

Display and/or read multiple lines of text. This is both an input and output element.

4 Combo Element

A combination of a single-line input and a drop-down menu.

5 OptionMenu Element

Similar to Combo. Only on TKinter port

6 Checkbox Element

Displays a checkbox and text next to it.

7 Radio Element

Used in a group of other Radio Elements to provide user with ability to select only one choice in a list of choices.

8 Spin Element

A spinner with up/down buttons and a single line of text.

9 Button Element

Defines all possible buttons. The shortcuts such as Submit, FileBrowse, … each create a Button

10 ButtonMenu element

Creates a button that when clicked will show a menu similar to right click menu.

11 Slider Element

Horizontal or vertical slider to increment/decrement a value.

12 Listbox Element

Provide a list of values for the user to choose one or more of. Returns a list of selected rows when a window.read() is executed.

13 Image Element

Show an image in the window. Should be a GIF or a PNG only.

14 Graph Element

Creates area to draw graph

15 Canvas Element

An area to draw shapes

16 ProgressBar Element

Displays a colored bar that is shaded as progress of some operation is made.

17 Table Element

Display data in rows and columns

18 Tree Element

Presents data in a tree-like manner, much like a file/folder browser.

19 Sizer Element

This element is used to add more space.

20 StatusBar Element

A StatusBar Element creates the sunken text-filled strip at the bottom.

21 Frame Element

The Frame element is a container object that holds on or more elements of other types.

22 Column Element

It is very useful if you want to design the GUI window elements represented in one or more vertical columns.

23 Tab Element

The use of Tab elements makes the design very convenient, effective and easy for the user to navigate. Tab element is also a container element such as Frame or Column.

Properties of Element Class

Following are the properties of the Element Class −









Sr.No. Property & Description
1 size

(w=characters-wide, h=rows-high)

2 font

specifies the font family, size

3 background_color

color of background

4 text_color

element”s text color

5 key

Identifies an Element

6 visible

set visibility state of the element (Default = True)

Methods of Element Class

Following are the methods of the Element Class −










Sr.No. Method & Description
1 set_tooltip()

Called by application to change the tooltip text for an Element

2 set_focus()

Sets the current focus to be on this element

3 set_size()

Changes the size of an element to a specific size

4 get_size()

Return the size of an element in Pixels

5 expand()

Causes the Element to expand to fill available space in the X and Y directions

6 set_cursor()

Sets the cursor for the current Element

7 set_right_click_menu()

Sets right click menu to be invoked when clicked

Advertisements

”;

Leave a Reply

Your email address will not be published. Required fields are marked *