mekasu0124

Untitled

Mar 15th, 2024
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.52 KB | None | 0 0
  1. import sys
  2.  
  3. from PySide6 import QtCore as qtc
  4. from PySide6 import QtWidgets as qtw
  5. from PySide6 import QtGui as qtg
  6.  
  7. from SplashScreen.UI.splash_screen import Ui_SplashScreen
  8.  
  9. COUNTER = 0
  10.  
  11.  
  12. class SplashScreen(qtw.QMainWindow, Ui_SplashScreen):
  13.     load_success = qtc.Signal()
  14.  
  15.     def __init__(self):
  16.         super().__init__()
  17.  
  18.         self.setupUi(self)
  19.         self.setWindowFlag(qtc.Qt.FramelessWindowHint)
  20.         self.setAttribute(qtc.Qt.WA_TranslucentBackground)
  21.  
  22.         pixmap = qtg.QPixmap("../Icons/app_logo.png")
  23.         self.lb_LogoImage.setPixmap(pixmap)
  24.         self.lb_LogoImage.setScaledContents(True)
  25.  
  26.         self.timer = qtc.QTimer()
  27.         self.timer.timeout.connect(self.progress)
  28.         self.timer.start(35)
  29.  
  30.         self.loading_text = [
  31.             "Starting Application...",
  32.             "Playing With Ducks...",
  33.             "Who Knows? ..."
  34.         ]
  35.  
  36.         self.index = 0
  37.  
  38.         self.message = self.loading_text[self.index]
  39.  
  40.     def progress(self):
  41.         global COUNTER
  42.  
  43.         self.progressBar.setValue(COUNTER)
  44.         self.lb_Percentage.setText(f"{self.message}")
  45.  
  46.         if COUNTER > 100:
  47.             self.timer.stop()
  48.             self.load_success.emit()
  49.  
  50.         COUNTER += 0.5
  51.         self.index += 1
  52.  
  53.         if self.index == len(self.loading_text):
  54.             self.index = 0
  55.  
  56. # uncomment this for testing
  57. # if __name__ == "__main__":
  58. #     app = qtw.QApplication(sys.argv)
  59.  
  60. #     window = SplashScreen()
  61. #     window.show()
  62.  
  63. #     sys.exit(app.exec())
Advertisement
Add Comment
Please, Sign In to add comment