Always on top Python script in MacOS

Dear smartest friends,
I have python script, it showing gif in window and brings this window to top over all other opened windows (or the windows which will be opened in future). It works perfectly in Windows operation system, but in MacOS if I’m watching video in full screen or have some application in full screen when this script runs, the video is exiting from full screen and the window also exiting from full screen. And I see 2 windows next to each other, but I want one on top of the other. If the other windows not in full mode it’s OK, the problem only with full mode. Here is the very simple Python script:

import sys
import os
import subprocess
import time
from PyQt6 import QtWidgets, QtGui, QtCore

class LoadingGif(QtWidgets.QWidget):
    def __init__(self):
        super().__init__()
        
        self.setGeometry(0, 0, 200, 200)
        base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
        imagePath = os.path.join(base_path, "earth.gif")

        self.movie = QtGui.QMovie(imagePath)
        self.movie.setScaledSize(QtCore.QSize(200, 200))

        self.label = QtWidgets.QLabel(self)
        self.label.setGeometry(QtCore.QRect(0, 0, 200, 200))
        self.label.setMovie(self.movie)
        self.label.mousePressEvent = self.CloseWindow
        self.movie.start()
        
        self.setWindowFlag(QtCore.Qt.WindowType.WindowStaysOnTopHint)

    def CloseWindow(self, event):
        sys.exit()

if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)

    window = LoadingGif()
    window.show()
    sys.exit(app.exec())

I’ve tried to add some WindowFlag attributes, but I didn’t found the right one.

I’ll be very appreciated for any help or hint!

Hey Arthur I think this should boil down to how Mac handles app launching esp, when opening full screen. launching and resizing of different windows in Windows env is much more fluid.

self.setWindowFlag(QtCore.Qt.WindowType.WindowStaysOnTopHint)

if you could find a way around this flag… maybe flag off or deactivate any existing windos then activate your intended window to take precedence… just a thought