- PySimpleGUI - Discussion
- PySimpleGUI - Useful Resources
- PySimpleGUI - Quick Guide
- PySimpleGUI - Settings
- PySimpleGUI - Debugger
- PySimpleGUI - Working with PIL
- PySimpleGUI - Matplotlib Integration
- PySimpleGUI - Menubar
- PySimpleGUI - Events
- PySimpleGUI - Element Class
- PySimpleGUI - Window Class
- PySimpleGUI - Popup Windows
- PySimpleGUI - Hello World
- PySimpleGUI - Environment Setup
- PySimpleGUI - Introduction
- PySimpleGUI - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
PySimpleGUI - Element Class
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 | Display some text in the window. Usually this means a single pne of text. |
2 | 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 | A combination of a single-pne input and a drop-down menu. |
5 | OptionMenu Element Similar to Combo. Only on TKinter port |
6 | Displays a checkbox and text next to it. |
7 | Used in a group of other Radio Elements to provide user with abipty to select only one choice in a pst of choices. |
8 | 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 | Creates a button that when cpcked will show a menu similar to right cpck menu. |
11 | Horizontal or vertical spder to increment/decrement a value. |
12 | 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 | Show an image in the window. Should be a GIF or a PNG only. |
14 | Creates area to draw graph |
15 | An area to draw shapes |
16 | Displays a colored bar that is shaded as progress of some operation is made. |
17 | Display data in rows and columns |
18 | 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 | The Frame element is a container object that holds on or more elements of other types. |
22 | It is very useful if you want to design the GUI window elements represented in one or more vertical columns. |
23 | 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 |