Article Outline
Example Python program HW_10.py
Modules
- from PyQt5 import QtCore, QtGui, QtWidgets
Classes
- class Ui_Ui_Dialog(object):
Methods
- def setupUi(self, Ui_Dialog):
- def retranslateUi(self, Ui_Dialog):
Code
Example Python PyQt program :
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'HW_10.ui'
#
# Created by: PyQt5 UI code generator 5.6
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Ui_Dialog(object):
def setupUi(self, Ui_Dialog):
Ui_Dialog.setObjectName("Ui_Dialog")
Ui_Dialog.resize(681, 871)
self.centralwidget = QtWidgets.QWidget(Ui_Dialog)
self.centralwidget.setObjectName("centralwidget")
self.InputGroup = QtWidgets.QGroupBox(self.centralwidget)
self.InputGroup.setGeometry(QtCore.QRect(20, 20, 621, 171))
self.InputGroup.setObjectName("InputGroup")
self.OpenButton = QtWidgets.QPushButton(self.InputGroup)
self.OpenButton.setGeometry(QtCore.QRect(170, 40, 231, 34))
self.OpenButton.setObjectName("OpenButton")
self.InputBox = QtWidgets.QListWidget(self.InputGroup)
self.InputBox.setGeometry(QtCore.QRect(55, 90, 521, 61))
self.InputBox.setObjectName("InputBox")
self.ReportGroup = QtWidgets.QGroupBox(self.centralwidget)
self.ReportGroup.setGeometry(QtCore.QRect(20, 210, 621, 211))
self.ReportGroup.setObjectName("ReportGroup")
self.ReportBox = QtWidgets.QPlainTextEdit(self.ReportGroup)
self.ReportBox.setGeometry(QtCore.QRect(50, 30, 531, 121))
self.ReportBox.setObjectName("ReportBox")
self.SaveButton = QtWidgets.QPushButton(self.ReportGroup)
self.SaveButton.setGeometry(QtCore.QRect(151, 160, 271, 31))
self.SaveButton.setObjectName("SaveButton")
self.SupportGroup = QtWidgets.QGroupBox(self.centralwidget)
self.SupportGroup.setGeometry(QtCore.QRect(20, 430, 621, 371))
self.SupportGroup.setObjectName("SupportGroup")
self.label = QtWidgets.QLabel(self.SupportGroup)
self.label.setGeometry(QtCore.QRect(100, 40, 121, 20))
self.label.setObjectName("label")
self.label_2 = QtWidgets.QLabel(self.SupportGroup)
self.label_2.setGeometry(QtCore.QRect(100, 90, 68, 19))
self.label_2.setObjectName("label_2")
self.label_3 = QtWidgets.QLabel(self.SupportGroup)
self.label_3.setGeometry(QtCore.QRect(100, 130, 68, 19))
self.label_3.setObjectName("label_3")
self.SupportNameBox = QtWidgets.QPlainTextEdit(self.SupportGroup)
self.SupportNameBox.setGeometry(QtCore.QRect(240, 40, 151, 31))
self.SupportNameBox.setObjectName("SupportNameBox")
self.NodeBox = QtWidgets.QPlainTextEdit(self.SupportGroup)
self.NodeBox.setGeometry(QtCore.QRect(240, 80, 151, 31))
self.NodeBox.setObjectName("NodeBox")
self.DirectionBox = QtWidgets.QPlainTextEdit(self.SupportGroup)
self.DirectionBox.setGeometry(QtCore.QRect(240, 120, 151, 31))
self.DirectionBox.setObjectName("DirectionBox")
self.PrintButton = QtWidgets.QPushButton(self.SupportGroup)
self.PrintButton.setGeometry(QtCore.QRect(210, 190, 201, 34))
self.PrintButton.setObjectName("PrintButton")
Ui_Dialog.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(Ui_Dialog)
self.menubar.setGeometry(QtCore.QRect(0, 0, 681, 31))
self.menubar.setObjectName("menubar")
self.menuTruss_Structural_Design = QtWidgets.QMenu(self.menubar)
self.menuTruss_Structural_Design.setObjectName("menuTruss_Structural_Design")
Ui_Dialog.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(Ui_Dialog)
self.statusbar.setObjectName("statusbar")
Ui_Dialog.setStatusBar(self.statusbar)
self.menubar.addAction(self.menuTruss_Structural_Design.menuAction())
self.retranslateUi(Ui_Dialog)
QtCore.QMetaObject.connectSlotsByName(Ui_Dialog)
def retranslateUi(self, Ui_Dialog):
_translate = QtCore.QCoreApplication.translate
Ui_Dialog.setWindowTitle(_translate("Ui_Dialog", "MainWindow"))
self.InputGroup.setTitle(_translate("Ui_Dialog", "Input"))
self.OpenButton.setText(_translate("Ui_Dialog", "Open and Read a Truss File"))
self.ReportGroup.setTitle(_translate("Ui_Dialog", "Report"))
self.SaveButton.setText(_translate("Ui_Dialog", "Save Report File"))
self.SupportGroup.setTitle(_translate("Ui_Dialog", "Support Properties"))
self.label.setText(_translate("Ui_Dialog", "Support Name"))
self.label_2.setText(_translate("Ui_Dialog", "Node"))
self.label_3.setText(_translate("Ui_Dialog", "Direction"))
self.PrintButton.setText(_translate("Ui_Dialog", "Print Support Data"))
self.menuTruss_Structural_Design.setTitle(_translate("Ui_Dialog", "Truss Structural Design"))
Useful Links
- Articles: https://python-commandments.org/
- PyQt: https://pythonpyqt.com/
- Tutorial: https://pythonprogramminglanguage.com/