Article Outline
Python pyqt (gui) example 'ui mainwindow'
ui mainwindow
Python pyqt example: ui mainwindow
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'mainwindow.ui'
#
# Created: Fri Jul 26 06:46:58 2013
# by: PyQt5 UI code generator 5.0.1-snapshot-2a99e59669ee
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(812, 605)
self.centralWidget = QtWidgets.QWidget(MainWindow)
self.centralWidget.setObjectName("centralWidget")
self.hboxlayout = QtWidgets.QHBoxLayout(self.centralWidget)
self.hboxlayout.setContentsMargins(0, 0, 0, 0)
self.hboxlayout.setSpacing(6)
self.hboxlayout.setObjectName("hboxlayout")
self.Frame3 = QtWidgets.QFrame(self.centralWidget)
self.Frame3.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.Frame3.setFrameShadow(QtWidgets.QFrame.Sunken)
self.Frame3.setObjectName("Frame3")
self.vboxlayout = QtWidgets.QVBoxLayout(self.Frame3)
self.vboxlayout.setContentsMargins(1, 1, 1, 1)
self.vboxlayout.setSpacing(0)
self.vboxlayout.setObjectName("vboxlayout")
self.WebBrowser = QAxContainer.QAxWidget(self.Frame3)
self.WebBrowser.setFocusPolicy(QtCore.Qt.StrongFocus)
self.WebBrowser.setControl("{8856F961-340A-11D0-A96B-00C04FD705A2}")
self.WebBrowser.setObjectName("WebBrowser")
self.vboxlayout.addWidget(self.WebBrowser)
self.hboxlayout.addWidget(self.Frame3)
MainWindow.setCentralWidget(self.centralWidget)
self.tbNavigate = QtWidgets.QToolBar(MainWindow)
self.tbNavigate.setOrientation(QtCore.Qt.Horizontal)
self.tbNavigate.setObjectName("tbNavigate")
MainWindow.addToolBar(4, self.tbNavigate)
self.tbAddress = QtWidgets.QToolBar(MainWindow)
self.tbAddress.setOrientation(QtCore.Qt.Horizontal)
self.tbAddress.setObjectName("tbAddress")
MainWindow.addToolBar(4, self.tbAddress)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 812, 26))
self.menubar.setObjectName("menubar")
self.PopupMenu = QtWidgets.QMenu(self.menubar)
self.PopupMenu.setObjectName("PopupMenu")
self.FileNewGroup_2 = QtWidgets.QMenu(self.PopupMenu)
self.FileNewGroup_2.setObjectName("FileNewGroup_2")
self.unnamed = QtWidgets.QMenu(self.menubar)
self.unnamed.setObjectName("unnamed")
MainWindow.setMenuBar(self.menubar)
self.actionGo = QtWidgets.QAction(MainWindow)
icon = QtGui.QIcon()
icon.addFile(":/icons/image0.xpm")
self.actionGo.setIcon(icon)
self.actionGo.setObjectName("actionGo")
self.actionBack = QtWidgets.QAction(MainWindow)
icon1 = QtGui.QIcon()
icon1.addFile(":/icons/image1.xpm")
self.actionBack.setIcon(icon1)
self.actionBack.setObjectName("actionBack")
self.actionForward = QtWidgets.QAction(MainWindow)
icon2 = QtGui.QIcon()
icon2.addFile(":/icons/image2.xpm")
self.actionForward.setIcon(icon2)
self.actionForward.setObjectName("actionForward")
self.actionStop = QtWidgets.QAction(MainWindow)
icon3 = QtGui.QIcon()
icon3.addFile(":/icons/image3.xpm")
self.actionStop.setIcon(icon3)
self.actionStop.setObjectName("actionStop")
self.actionRefresh = QtWidgets.QAction(MainWindow)
icon4 = QtGui.QIcon()
icon4.addFile(":/icons/image4.xpm")
self.actionRefresh.setIcon(icon4)
self.actionRefresh.setObjectName("actionRefresh")
self.actionHome = QtWidgets.QAction(MainWindow)
icon5 = QtGui.QIcon()
icon5.addFile(":/icons/image5.xpm")
self.actionHome.setIcon(icon5)
self.actionHome.setObjectName("actionHome")
self.actionFileClose = QtWidgets.QAction(MainWindow)
self.actionFileClose.setObjectName("actionFileClose")
self.actionSearch = QtWidgets.QAction(MainWindow)
icon6 = QtGui.QIcon()
icon6.addFile(":/icons/image6.xpm")
self.actionSearch.setIcon(icon6)
self.actionSearch.setObjectName("actionSearch")
self.actionAbout = QtWidgets.QAction(MainWindow)
self.actionAbout.setObjectName("actionAbout")
self.actionAboutQt = QtWidgets.QAction(MainWindow)
self.actionAboutQt.setObjectName("actionAboutQt")
self.FileNewGroup = QtWidgets.QActionGroup(MainWindow)
self.FileNewGroup.setObjectName("FileNewGroup")
self.actionNewWindow = QtWidgets.QAction(self.FileNewGroup)
self.actionNewWindow.setObjectName("actionNewWindow")
self.tbNavigate.addAction(self.actionBack)
self.tbNavigate.addAction(self.actionForward)
self.tbNavigate.addAction(self.actionStop)
self.tbNavigate.addAction(self.actionRefresh)
self.tbNavigate.addAction(self.actionHome)
self.tbNavigate.addSeparator()
self.tbNavigate.addAction(self.actionSearch)
self.tbAddress.addAction(self.actionGo)
self.FileNewGroup_2.addAction(self.actionNewWindow)
self.PopupMenu.addAction(self.FileNewGroup_2.menuAction())
self.PopupMenu.addSeparator()
self.PopupMenu.addAction(self.actionFileClose)
self.unnamed.addAction(self.actionAbout)
self.unnamed.addAction(self.actionAboutQt)
self.menubar.addAction(self.PopupMenu.menuAction())
self.menubar.addAction(self.unnamed.menuAction())
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "Qt WebBrowser"))
self.tbNavigate.setWindowTitle(_translate("MainWindow", "Navigation"))
self.tbAddress.setWindowTitle(_translate("MainWindow", "Address"))
self.PopupMenu.setTitle(_translate("MainWindow", "&File"))
self.FileNewGroup_2.setTitle(_translate("MainWindow", "New"))
self.unnamed.setTitle(_translate("MainWindow", "&Help"))
self.actionGo.setIconText(_translate("MainWindow", "Go"))
self.actionBack.setIconText(_translate("MainWindow", "Back"))
self.actionBack.setShortcut(_translate("MainWindow", "Backspace"))
self.actionForward.setIconText(_translate("MainWindow", "Forward"))
self.actionStop.setIconText(_translate("MainWindow", "Stop"))
self.actionRefresh.setIconText(_translate("MainWindow", "Refresh"))
self.actionHome.setIconText(_translate("MainWindow", "Home"))
self.actionFileClose.setText(_translate("MainWindow", "C&lose"))
self.actionFileClose.setIconText(_translate("MainWindow", "Close"))
self.actionSearch.setIconText(_translate("MainWindow", "Search"))
self.actionAbout.setIconText(_translate("MainWindow", "About"))
self.actionAboutQt.setIconText(_translate("MainWindow", "About Qt"))
self.actionNewWindow.setIconText(_translate("MainWindow", "Window"))
self.actionNewWindow.setShortcut(_translate("MainWindow", "Ctrl+N"))
from PyQt5 import QAxContainer
Useful links
- Learn PyQt: https://pythonbasics.org/pyqt-hello-world/
- Install PyQt: https://pythonbasics.org/install-pyqt/