Мне надо сделать так, чтобы при нажатии кнопки запускалась загрузка и её процесс отображался в progress bar.
files_rcm.py
# Resource object code (Python 3)
# Created by: object code
# Created by: The Resource Compiler for Qt version 6.3.0
# WARNING! All changes made in this file will be lost!
from PySide6 import QtCore
qt_resource_data = b"\
\x00\x00\x00\xf9\
\x00\
\x00\x09\x9ex\x9c\xed\x96?\x0e\x820\x14\x87\x7f,\x1a\
'7\xc3\xc8\xe8h\xe4\x00vg\xe2\x06\x8c\xdcB\xd8\
\xb8\x05\x9b\xdc\xc0\xd9\xc4+x\x00\x8f\xc0\xe0H\xac\xef\
AQB\x80T\x8a\x93\xbc\xe6\x83\xd2?_Rx\x05\
\x00\x8b\x8am\x83\x8e\x0e\x92\x15\xb0\x01\xb0%\xa8\x09;\
T\xedeP\xdf\x09\x15uH)\xf9\x94\x11\x05_N\
\x04\xbb2\xe5\xdeO\xe8m\xc3n\xf1C\xbfh\xf9/\
\xbc&\x13\xd8\xf1\x8f~\x8a%qV,\xbe\xf0;D\
\xa4\x08z\xe6X\xa8\xd2\xba\x9e\xc7u\xabgl\xd0\xf0\
9\x9akN:r#1\xbd\x97\xca\x1d\x0e\xe4_h\
\xe8\xf60\xbc\xaf\xb9\xcf\x1b\xe9v\x89\x87\xc6\x1e\xe21\
\xee\x08\xffMs\x8f2\xb7\x11~\x9f8*\xd2\x0eg\
\xda\xe8\xf7\x0d\x9f\x83\xe8\xf0\x8b)\xf2g\xf6\xcf\xfe\xd9\
_\xfe\xea\xdc\x1bn\xae\xdb:s\xa3\xf2\xd3Q\xc5Z\
\xe6\x1f\xaeD\x9cC\xc64\x8e\xca\x93^\x03\x05\x0eo\
\xcav\x0d^w\x22\xdb\x90\
"
qt_resource_name = b"\
\x00\x05\
\x00o\xa6S\
\x00i\
\x00c\x00o\x00n\x00s\
\x00\x0c\
\x08\x1a\x85\xff\
\x00d\
\x00o\x00w\x00n\x00l\x00o\x00a\x00d\x00.\x00i\x00c\x00o\
"
qt_resource_struct = b"\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\
\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\
\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x03\
\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\x10\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\
\x00\x00\x01\x81.\xc2\x14B\
"
def qInitResources():
QtCore.qRegisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data)
def qCleanupResources():
QtCore.qUnregisterResourceData(0x03, qt_resource_struct, qt_resource_name, qt_resource_data)
qInitResources()
design2.py
# -*- coding: utf-8 -*-
################################################################################
## Form generated from reading UI file 'design-2.ui'
##
## Created by: Qt User Interface Compiler version 6.3.0
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
QMetaObject, QObject, QPoint, QRect,
QSize, QTime, QUrl, Qt)
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
QFont, QFontDatabase, QGradient, QIcon,
QImage, QKeySequence, QLinearGradient, QPainter,
QPalette, QPixmap, QRadialGradient, QTransform)
from PySide6.QtWidgets import (QApplication, QLabel, QMainWindow, QProgressBar,
QPushButton, QSizePolicy, QWidget)
import files_rcm
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
if not MainWindow.objectName():
MainWindow.setObjectName(u"MainWindow")
MainWindow.resize(402, 138)
icon = QIcon()
icon.addFile(u":/icons/icons/download.ico", QSize(), QIcon.Normal, QIcon.Off)
MainWindow.setWindowIcon(icon)
MainWindow.setStyleSheet(u"QMainWindow {\n"
" background-color:rgb(85, 0, 127)\n"
"}")
self.centralwidget = QWidget(MainWindow)
self.centralwidget.setObjectName(u"centralwidget")
self.pushButton = QPushButton(self.centralwidget)
self.pushButton.setObjectName(u"pushButton")
self.pushButton.setGeometry(QRect(10, 110, 381, 23))
sizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Maximum)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.pushButton.sizePolicy().hasHeightForWidth())
self.pushButton.setSizePolicy(sizePolicy)
self.progressBar = QProgressBar(self.centralwidget)
self.progressBar.setObjectName(u"progressBar")
self.progressBar.setGeometry(QRect(10, 80, 381, 21))
sizePolicy1 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum)
sizePolicy1.setHorizontalStretch(0)
sizePolicy1.setVerticalStretch(0)
sizePolicy1.setHeightForWidth(self.progressBar.sizePolicy().hasHeightForWidth())
self.progressBar.setSizePolicy(sizePolicy1)
self.progressBar.setStyleSheet(u"QProgressBar {\n"
" color:rgb(0, 255, 255);\n"
"}")
self.progressBar.setValue(0)
self.label = QLabel(self.centralwidget)
self.label.setObjectName(u"label")
self.label.setGeometry(QRect(9, 14, 391, 31))
sizePolicy2 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum)
sizePolicy2.setHorizontalStretch(0)
sizePolicy2.setVerticalStretch(0)
sizePolicy2.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth())
self.label.setSizePolicy(sizePolicy2)
font = QFont()
font.setPointSize(10)
self.label.setFont(font)
self.label.setStyleSheet(u"QLabel {\n"
" color:rgb(0, 255, 255);\n"
"}")
self.label_2 = QLabel(self.centralwidget)
self.label_2.setObjectName(u"label_2")
self.label_2.setGeometry(QRect(10, 20, 341, 51))
sizePolicy3 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)
sizePolicy3.setHorizontalStretch(0)
sizePolicy3.setVerticalStretch(0)
sizePolicy3.setHeightForWidth(self.label_2.sizePolicy().hasHeightForWidth())
self.label_2.setSizePolicy(sizePolicy3)
self.label_2.setFont(font)
self.label_2.setStyleSheet(u"QLabel {\n"
" color:rgb(0, 255, 255);\n"
"}")
MainWindow.setCentralWidget(self.centralwidget)
self.retranslateUi(MainWindow)
QMetaObject.connectSlotsByName(MainWindow)
# setupUi
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"Installer", None))
self.pushButton.setText(QCoreApplication.translate("MainWindow", u"\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c", None))
self.label.setText(QCoreApplication.translate("MainWindow", u"\u0412\u043e \u0432\u0440\u0435\u043c\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043d\u0435 \u0440\u0435\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0442\u0440\u043e\u0433\u0430\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u043b\u0438\u0431\u043e ", None))
self.label_2.setText(QCoreApplication.translate("MainWindow", u"\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043d\u0430 \u0432\u0430\u0448\u0435\u043c \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0435", None))
# retranslateUi
main.py
import sys
from PySide6.QtWidgets import QApplication, QMainWindow
from PySide6.QtGui import QFontDatabase
from PyQt5.QtCore import QThread, pyqtSignal
import urllib.request
import design2
class MainWindow(QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
self.ui = design2.Ui_MainWindow()
self.ui.setupUi(self)
self.ui.pushButton.clicked.connect(self.download)
if __name__ == '__main__':
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec())