'What does the Qt.Popup window flag entail?

I'm using PyQT5 to create a GUI. Basically, what I want is a transparent window that extends the entire width and height of the screen (including the toolbar and dock on MacOS)

The code I am using to achieve this is like so:

class Gui(QWidget):
    def __init__(self):

    #Initialize the QApp/QWidget things
        super().__init__()

    #Add a default rectangle
        self.rectangle = QRect(0, 0, 0, 0)

    #Build the window in a method to keep the init clean
        self.buildWindow()

    #Build the window
        def buildWindow(self):

    #Make the window transparent
        self.setWindowFlags(self.windowFlags() | Qt.FramelessWindowHint | Qt.Popup)
        self.setAttribute(Qt.WA_TranslucentBackground)
    #Maximize the window
        self.resize(1920, 1080)
    #Enable mouse tracking
        self.setMouseTracking(True)
    #Render the window
        self.show()

I open the GUI like so:

#Instantiate our app and Gui stuff.
    app = QApplication(sys.argv)
    gui = Gui()
#Make the cursor the "cross cursor" for effect
    app.setOverrideCursor(QCursor(Qt.CrossCursor))
#Exit when our app exits
    sys.exit(app.exec_())

The issue is that the GUI opens, renders for a second, and disappears immediately. If I remove Qt.Popup from the window flags, it will do exactly what I want it to do (but it will not extend past the dock or the toolbar on MacOS)

I've heard that this problem is causes (generally) by a widget being rendered and leaving the scope due to Python's garbage collection system, but I'm unsure if that is the problem here because it will actually render if I remove the Qt.Popup

Anyone who has experience with QT and could help would be awesome.. I've been trying to figure out this bug for a couple days.

EDIT: If you can't tell already, I am developing this on MacOS



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source