Introduction to GUI

In this section, we are going to learn about GUI. Python has various frameworks for GUI. In this section, we are going to look at PyQt5. PyQt5 has different graphics components, also known as object widgets, which can be displayed on screen and also interact with users. The components are listed here:

  • PyQt5 windowThe PyQt5 window will create a simple app window.
  • PyQt5 button: The PyQt5 button is a button that causes an action whenever it is clicked.
  • PyQt5 textboxThe PyQt5 textbox widget allows users to enter the text.
  • PyQt5 labelThe PyQt5 label widget displays a single-line text or an image.
  • PyQt5 combo boxThe PyQt5 combo box widget is a combined button and a popup list.
  • PyQt5 check boxThe PyQt5 check box widget is an option button that can be checked and unchecked.
  • PyQt5 radio buttonThe PyQt5 radio button widget is an option button that can be checked or unchecked. In a group of radio buttons, only one of the buttons can be checked at a time.
  • PyQt5 message boxThe PyQt5 message box widget display a message.
  • PyQt5 menuThe PyQt5 menu widget gives different choices that are displayed.
  • PyQt5 tableThe PyQt5 table widget provides standard table display functionality for applications, which can be constructed with a number of rows and columns.
  • PyQt5 signals/slotsSignals will let you react to the event that has occurred and slot is simply a function that gets called whenever a signal occurs.
  • PyQt5 layoutsThe PyQt5 layouts consist of multiple widgets.

There are several PyQt5 classes available, which are divided into different modules. These modules are listed here:

  • QtGuiQtGui contains classes for event handling, graphics, fonts, texts, and basic imaging.
  • QtWidgetsQtWidgets contains classes to create desktop-style user interfaces.
  • QtCoreQtCore contains core non-GUI functionality such as time, directories, files, streams, URLs, data types, threads, and processes.
  • QtBluetoothQtBluetooth contains classes for connecting with devices and interacting with them.
  • QtPositioningQtPositioning contains classes to determine the position.
  • QtMultimediaQtMultimedia contains classes for APIs and multimedia content.
  • QtNetworkQtNetwork contains classes for network programming.
  • QtWebKitQtWebkit contains classes for web browser implementation.
  • QtXmlQtXml contains classes for XML files.
  • QtSqlQtSql contains classes for databases.

The GUI is driven by the events. Now, what is an event? An event is a signal that indicates that something has happened in your program, for example, menu selection, mouse movement, or button clicks. The events are handled by functions and triggered when a user performs some actions on the objects. The listener will listen to the event and then it will invoke an event handler whenever an event occurs.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset