English 中文(简体)
PySimpleGUI - Element Class
  • 时间:2024-11-03

PySimpleGUI - Element Class


Previous Page Next Page  

The PySimpleGUI pbrary 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 pbrary, in which Element class acts as the base for all other widget classes.

An object of this Element class is never declared exppcitly. It defines the common properties pke size, color, etc. Here is the pst 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 pne of text.

2 Input Element

Display a single text input field.

3 Multipne Element

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

4 Combo Element

A combination of a single-pne 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 abipty to select only one choice in a pst of choices.

8 Spin Element

A spinner with up/down buttons and a single pne 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 cpcked will show a menu similar to right cpck menu.

11 Spder Element

Horizontal or vertical spder to increment/decrement a value.

12 Listbox Element

Provide a pst of values for the user to choose one or more of. Returns a pst 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-pke manner, much pke 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 visibipty 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 apppcation 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_cpck_menu()

Sets right cpck menu to be invoked when cpcked

Advertisements