我面临的问题可能很“容易”,但我看不到解决方案
我有这个Python代码。
首先,我在加载设置,客户,销售等时打开QMainWindow作为启动屏幕。
但是当我关闭启动画面并打开主屏幕时,任务栏的详细信息就消失了!
这是代码:
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.uic import loadUiType
import os
import sys
import time
class ThreadProgress(QThread):
mysignal = pyqtSignal(int, str)
def __init__(self, parent=None):
QThread.__init__(self, parent)
def run(self):
i = 0
while i < 102:
time.sleep(0.02)
self.mysignal.emit(i, "txt")
i += 1
class Main(QMainWindow):
def __init__(self, parent=None):
super(Main, self).__init__(parent)
self.Label = QLabel("Second Gui")
self.mainLayout = QVBoxLayout()
self.mainLayout.addWidget(self.Label)
self.centralWidget = QWidget()
self.centralWidget.setLayout(self.mainLayout)
self.setCentralWidget(self.centralWidget)
class Splash(QMainWindow):
def __init__(self, parent=None):
super(Splash, self).__init__(parent)
self.progressBar = QProgressBar()
self.SubText = QLabel("test")
self.mainLayout = QVBoxLayout()
self.mainLayout.addWidget(self.progressBar)
self.mainLayout.addWidget(self.SubText)
self.centralWidget = QWidget()
self.centralWidget.setLayout(self.mainLayout)
self.setCentralWidget(self.centralWidget)
progress = ThreadProgress(self)
progress.mysignal.connect(self.progress)
progress.start()
@pyqtSlot(int, str)
def progress(self, i, txt):
if i == 101:
self.close()
self.setStyleSheet("")
main = Main(self)
main.show()
self.progressBar.setValue(i)
self.SubText.setText(txt)
def main():
app = QApplication(sys.argv)
splash = Splash()
splash.show()
app.exec_()
if __name__ == '__main__':
try:
main()
except Exception as why:
print(why)