0% found this document useful (0 votes)
6 views17 pages

PyQT5 GUI Programming Basics

This document is a lecture on Applied Programming with Python, focusing on PyQT5 for creating graphical user interfaces. It covers installation, basic window classes (QMainWindow, QWidget, QDialog), and provides examples of GUI applications, including a calculator. References for further learning are also included.

Uploaded by

myatkyalsin10
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views17 pages

PyQT5 GUI Programming Basics

This document is a lecture on Applied Programming with Python, focusing on PyQT5 for creating graphical user interfaces. It covers installation, basic window classes (QMainWindow, QWidget, QDialog), and provides examples of GUI applications, including a calculator. References for further learning are also included.

Uploaded by

myatkyalsin10
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

IT

Applied Programming – Python


Part IV
Lecture 5

Dr. Nwe Nwe Htay Win


M. C. Sc, University of Computer Studies, Mandalay
Ph.D (IT), China
Harbin Institute of Technology
IT
Outlines
• Graphical User Interface
• PyQT-5 installation
IT
PyQT5 installation
• pip3 install pyqt5
• pip3 install pyqt-tools

• Or
• pip install pyqt5
• pip install pyqt-tools
IT
Find PyQT5 Designer
• Locate qt designer exe file at your computer.
• Go to Anaconda\env file –
• C:\Users\USER\anaconda3\envs\teaching\Lib\site-
packages\qt5_applications\Qt\bin
IT
Create Desktop Shortcut
IT
Qt Designer
IT
Basic Introduction to QMain Windows
• In PyQt5, three main classes are used to create windows, which can be used directly or inherited
and reused.
• QMainWindow
• QWidget
• QDialog
• QMainWindow
• QMainWindow can include menu bar, toolbar, status bar, Title bar, etc. It is the main window of
GUI program.
• If we need to create a main window program, use this class.
• QDialog
• QDialog is the base class of dialog window. Dialog is usually used to perform short-term tasks
or interact with users. It can be modal or non-modal. QDialog has no menu bar, toolbar, status
bar, etc.
• If we need a dialog box, select this class.
• QWidget
• As the parent class of QMainWindow and QWidget, this class is not refined to the main
window or dialog box. As a general window class, if you are not sure which window class to
use, you can use this class.
IT
Hello World Program with GUI
IT
QMainWindow
IT
Importing UI file
• from PyQt5 import QtWidgets, uic

• import sys

• app = [Link]([])

• win = [Link]("[Link]") #specify the location of your .ui file

• [Link]()

• [Link]([Link]())
IT
Importing UI File with loadUI function
IT
Example GUI Example
IT

• from PyQt5 import uic,QtCore


• import sys
• from [Link] import
• def showBookData(self):
QApplication,QDialog,QMessageBox
• pass
• from PyQt5 import QtCore, QtGui, QtWidgets, QtPrintSupport
• from [Link] import *
• import [Link] as c • def updateBookData(self):
• import pandas as pd
• pass
• class AdminInfoProcessForm(QDialog):
• def __init__(self):
• app=QApplication([Link])
• super(AdminInfoProcessForm,self).__init__()
• [Link]('[Link]',self) • stu=AdminInfoProcessForm(
• [Link]([Link]) )

[Link]([Link])
• [Link]()
• [Link]=None • app.exec_()
• [Link]("Show Users")
IT
Let’s Design Calculator
IT

Let’s Write Code for Calculator


IT
Next Lecture
• Applied Programming- Python – Part III
IT
References
• [Link]

• [Link]
qmainwindow/

• [Link]

You might also like