JustPaste
HomeCategoriesAboutDonateContactTerms of UsePrivacy Policy
JustPaste

Free online notepad — write and share instantly

Navigate

  • Home
  • Timeline
  • Categories

Info

  • About
  • Donate
  • Contact

Legal

  • Terms of Use
  • Privacy Policy

© 2026 JustPaste.app. All rights reserved.

Made with ♥ by JustPaste

Fjrif | JustPaste.app
12 days ago8 views
👨‍💻Programming

Fjrif

import sys
from PyQt6.QtCore import Qt, QTimer, QPropertyAnimation, QEasingCurve
from PyQt6.QtGui import QFont
from PyQt6.QtWidgets import (QApplication, QMainWindow, QWidget, 
                             QVBoxLayout, QLabel, QStackedWidget, QGraphicsOpacityEffect)

class WindowsApp(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("My Application")
        self.resize(800, 600)
        
        # 1. Start out borderless/frameless so it looks exactly like a native Windows 10 splash
        self.setWindowFlags(Qt.WindowType.FramelessWindowHint)
        
        # Center the window on the user's monitor screen
        screen = QApplication.primaryScreen().geometry()
        self.move((screen.width() - self.width()) // 2, (screen.height() - self.height()) // 2)

        # Single Stacked Widget container ensures the splash is the EXACT size of the app window
        self.stacked_widget = QStackedWidget()
        self.setCentralWidget(self.stacked_widget)

        self.create_splash_page()
        self.create_main_page()

        self.stacked_widget.addWidget(self.splash_page)
        self.stacked_widget.addWidget(self.main_page)
        self.stacked_widget.setCurrentIndex(0)

        # Hold the splash screen for 2.5 seconds before starting the highly visible fade animation
        QTimer.singleShot(2500, self.start_fade_out)

    def create_splash_page(self):
        """Builds the fullscreen solid splash page view."""
        self.splash_page = QWidget()
        self.splash_page.setStyleSheet("background-color: #0078D7;") # Pure Windows Accent Blue
        
        layout = QVBoxLayout()
        icon_label = QLabel("❖", self.splash_page)
        icon_label.setFont(QFont("Arial", 72))
        icon_label.setStyleSheet("color: white;")
        icon_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
        
        layout.addWidget(icon_label)
        self.splash_page.setLayout(layout)

    def create_main_page(self):
        """Builds the core application workspace view."""
        self.main_page = QWidget()
        self.main_page.setStyleSheet("background-color: #FFFFFF;")
        
        layout = QVBoxLayout()
        label = QLabel("Welcome to the Main Application!", self.main_page)
        label.setFont(QFont("Arial", 22))
        label.setStyleSheet("color: #222222;")
        label.setAlignment(Qt.AlignmentFlag.AlignCenter)
        
        layout.addWidget(label)
        self.main_page.setLayout(layout)

    def start_fade_out(self):
        """Executes a highly noticeable, dramatic opacity fade transition."""
        self.opacity_effect = QGraphicsOpacityEffect(self.splash_page)
        self.splash_page.setGraphicsEffect(self.opacity_effect)

        self.animation = QPropertyAnimation(self.opacity_effect, b"opacity")
        self.animation.setDuration(800) # Increased to 800ms so you can clearly see the fading effect
        self.animation.setStartValue(1.0)
        self.animation.setEndValue(0.0)
        self.animation.setEasingCurve(QEasingCurve.Type.OutQuad)

        self.animation.finished.connect(self.show_main_content)
        self.animation.start()

    def show_main_content(self):
        """Removes splash, shows content, and dynamically restores desktop window frames."""
        self.stacked_widget.setCurrentIndex(1)
        
        # Restore standard Linux/Windows window borders, title bars, and close controls
        self.setWindowFlags(Qt.WindowType.Window)
        
        # Re-apply window configuration changes dynamically and render the finished view
        self.show()


def main():
    app = QApplication(sys.argv)
    window = WindowsApp()
    window.show()
    sys.exit(app.exec())

if __name__ == "__main__":
    main()
← Back to timeline