Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Using PyQT6 on Debian 13 and about 50% of the time, when I run by script, I get no window drawn?

Using PyQT6 on Debian 13 and about 50% of the time, when I run by script, I get no window drawn?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 364 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jibun-no-Kage
    wrote on last edited by
    #1

    Using PyQT6 on Debian 13 and about 50% of the time, when I run by script, I get no window drawn? An application icon appears on the dash/dock (using GNOME), and the icon menu works, I can close the application from there, but again no window ever appears. This happens completely randomly. I can close the application wait a second or two and it will work, repeat the sequence and it will not work. Must confusing. Below is the code, it is pretty simple, or so I think.

    LED Module...

    import sys
    from PyQt6.QtWidgets import QWidget, QVBoxLayout, QLabel, QApplication, QPushButton, QHBoxLayout, QFrame
    from PyQt6.QtGui import QPainter, QColor, QPen
    from PyQt6.QtCore import Qt, QSize
    
    class LEDWidget(QFrame):
        """
        A custom QFrame widget to display a square LED with a label.
        """
        def __init__(self, label_text, parent=None):
            super().__init__(parent)
            self.setFixedSize(100, 80) # Fixed size for the whole widget
            self.setFrameShape(QFrame.Shape.StyledPanel)
            self.setLineWidth(1)
    
            layout = QVBoxLayout()
            layout.setAlignment(Qt.AlignmentFlag.AlignCenter)
    
            # Custom LED indicator area (a QWidget that will be custom drawn)
            self._led = QWidget(self)
            self._led.setFixedSize(40, 40)
            # Set a styled background for the LED itself, including a border
            self._led.setStyleSheet("""
                QWidget {
                    border: 2px solid black;
                    border-radius: 5px; /* Optional: for slightly rounded corners */
                }
            """)
    
            # Label for the LED
            self._label = QLabel(label_text, self)
            self._label.setAlignment(Qt.AlignmentFlag.AlignCenter)
    
            layout.addWidget(self._led, alignment=Qt.AlignmentFlag.AlignCenter)
            layout.addWidget(self._label, alignment=Qt.AlignmentFlag.AlignCenter)
            self.setLayout(layout)
    
            self._is_on = False
            self._update_led_color()
    
        def is_on(self):
            return self._is_on
    
        def set_on(self, state):
            self._is_on = state
            self._update_led_color()
    
        def toggle(self):
            self._is_on = not self._is_on
            self._update_led_color()
    
        def _update_led_color(self):
            # Update the background color using stylesheets
            color = "gray" if (self._is_on is None) else ("green" if self._is_on else "red")
            self._led.setStyleSheet(f"""
                QWidget {{
                    border: 2px solid black;
                    border-radius: 5px;
                    background-color: {color};
                }}
            """)
    

    Main...

    mport sys
    from PyQt6.QtWidgets import QApplication, QMainWindow, QWidget, QVBoxLayout, QHBoxLayout, QPushButton
    from PyQt6.QtCore import QSize
    from led_widget import LEDWidget
    
    class MainWindow(QMainWindow):
        def __init__(self):
            super().__init__()
            self.setWindowTitle("On Air Monitor")
            self.setGeometry(0, 0, 100, 250)
    
            central_widget = QWidget()
            main_layout = QVBoxLayout()
    
            # Layout for LEDs
            leds_layout = QHBoxLayout()
            self.led1 = LEDWidget("Booth")
            self.led2 = LEDWidget("Production")
            self.led3 = LEDWidget("Signs")
            self.led4 = LEDWidget("Alive")
            self.led5 = LEDWidget("Stream")
            self.led6 = LEDWidget("Switcher")
    
            leds_layout.addWidget(self.led1)
            leds_layout.addWidget(self.led2)
            leds_layout.addWidget(self.led3)
            leds_layout.addWidget(self.led4)
            leds_layout.addWidget(self.led5)
            leds_layout.addWidget(self.led6)
    
            self.led1.set_on(None)
            self.led2.set_on(None)
            self.led3.set_on(None)
            self.led4.set_on(None)
            self.led5.set_on(None)
            self.led6.set_on(None)
    
            # Layout for buttons
            buttons_layout = QHBoxLayout()
            #self.toggle_button = QPushButton("Toggle All LEDs")
            #self.toggle_button.clicked.connect(self.toggle_all_leds)
    
            self.close_button = QPushButton("OK")
            self.close_button.setFixedSize(QSize(100,30))
            self.close_button.clicked.connect(self.close)
    
            #buttons_layout.addWidget(self.toggle_button)
            buttons_layout.addWidget(self.close_button)
    
            main_layout.addLayout(leds_layout)
            main_layout.addLayout(buttons_layout)
            central_widget.setLayout(main_layout)
            self.setCentralWidget(central_widget)
    
        #def toggle_all_leds(self):
            # Example of how to turn LEDs on and off
            #if self.led1.is_on():
                #self.led1.set_on(False)
                #self.led2.set_on(False)
                #self.led3.set_on(False)
            #else:
                #self.led1.set_on(True)
                #self.led2.set_on(True)
                #self.led3.set_on(True)
    
    if __name__ == "__main__":
        app = QApplication(sys.argv)
        window = MainWindow()
        window.show()
        sys.exit(app.exec())
    

    The Qt environment does throw a few warnings... but none of these seem to be material, since they are consistently presented both when the window appears and fails to appear.

    # /root/Test/bin/python3 Test4.py
    Failed to create wl_display (No such file or directory)
    qt.qpa.plugin: Could not load the Qt platform plugin "wayland" in "" even though it was found.
    qt.qpa.theme.dbus: Session DBus not running.
    qt.qpa.theme.dbus: Application will not react to setting changes.
     Check your DBus installation.
    qt.qpa.theme.gnome: dbus connection failed. Last error:  QDBusError("org.freedesktop.DBus.Error.NoReply", "Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.")
    qt.qpa.theme.dbus: Session DBus not running.
    qt.qpa.theme.dbus: Application will not react to setting changes.
     Check your DBus installation.
    qt.qpa.theme.gnome: dbus connection failed. Last error:  QDBusError("org.freedesktop.DBus.Error.NoReply", "Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.")
    

    When window fails to appear...

    # /root/Test/bin/python3 Test4.py
    Failed to create wl_display (No such file or directory)
    qt.qpa.plugin: Could not load the Qt platform plugin "wayland" in "" even though it was found.
    qt.qpa.theme.dbus: Session DBus not running.
    qt.qpa.theme.dbus: Application will not react to setting changes.
     Check your DBus installation.
    qt.qpa.theme.gnome: dbus connection failed. Last error:  QDBusError("org.freedesktop.DBus.Error.NoReply", "Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.")
    qt.qpa.theme.dbus: Session DBus not running.
    qt.qpa.theme.dbus: Application will not react to setting changes.
     Check your DBus installation.
    qt.qpa.theme.gnome: dbus connection failed. Last error:  QDBusError("org.freedesktop.DBus.Error.NoReply", "Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.")
    

    Any help appreciated! Any more details required?

    jsulmJ I 2 Replies Last reply
    0
    • J Jibun-no-Kage

      Using PyQT6 on Debian 13 and about 50% of the time, when I run by script, I get no window drawn? An application icon appears on the dash/dock (using GNOME), and the icon menu works, I can close the application from there, but again no window ever appears. This happens completely randomly. I can close the application wait a second or two and it will work, repeat the sequence and it will not work. Must confusing. Below is the code, it is pretty simple, or so I think.

      LED Module...

      import sys
      from PyQt6.QtWidgets import QWidget, QVBoxLayout, QLabel, QApplication, QPushButton, QHBoxLayout, QFrame
      from PyQt6.QtGui import QPainter, QColor, QPen
      from PyQt6.QtCore import Qt, QSize
      
      class LEDWidget(QFrame):
          """
          A custom QFrame widget to display a square LED with a label.
          """
          def __init__(self, label_text, parent=None):
              super().__init__(parent)
              self.setFixedSize(100, 80) # Fixed size for the whole widget
              self.setFrameShape(QFrame.Shape.StyledPanel)
              self.setLineWidth(1)
      
              layout = QVBoxLayout()
              layout.setAlignment(Qt.AlignmentFlag.AlignCenter)
      
              # Custom LED indicator area (a QWidget that will be custom drawn)
              self._led = QWidget(self)
              self._led.setFixedSize(40, 40)
              # Set a styled background for the LED itself, including a border
              self._led.setStyleSheet("""
                  QWidget {
                      border: 2px solid black;
                      border-radius: 5px; /* Optional: for slightly rounded corners */
                  }
              """)
      
              # Label for the LED
              self._label = QLabel(label_text, self)
              self._label.setAlignment(Qt.AlignmentFlag.AlignCenter)
      
              layout.addWidget(self._led, alignment=Qt.AlignmentFlag.AlignCenter)
              layout.addWidget(self._label, alignment=Qt.AlignmentFlag.AlignCenter)
              self.setLayout(layout)
      
              self._is_on = False
              self._update_led_color()
      
          def is_on(self):
              return self._is_on
      
          def set_on(self, state):
              self._is_on = state
              self._update_led_color()
      
          def toggle(self):
              self._is_on = not self._is_on
              self._update_led_color()
      
          def _update_led_color(self):
              # Update the background color using stylesheets
              color = "gray" if (self._is_on is None) else ("green" if self._is_on else "red")
              self._led.setStyleSheet(f"""
                  QWidget {{
                      border: 2px solid black;
                      border-radius: 5px;
                      background-color: {color};
                  }}
              """)
      

      Main...

      mport sys
      from PyQt6.QtWidgets import QApplication, QMainWindow, QWidget, QVBoxLayout, QHBoxLayout, QPushButton
      from PyQt6.QtCore import QSize
      from led_widget import LEDWidget
      
      class MainWindow(QMainWindow):
          def __init__(self):
              super().__init__()
              self.setWindowTitle("On Air Monitor")
              self.setGeometry(0, 0, 100, 250)
      
              central_widget = QWidget()
              main_layout = QVBoxLayout()
      
              # Layout for LEDs
              leds_layout = QHBoxLayout()
              self.led1 = LEDWidget("Booth")
              self.led2 = LEDWidget("Production")
              self.led3 = LEDWidget("Signs")
              self.led4 = LEDWidget("Alive")
              self.led5 = LEDWidget("Stream")
              self.led6 = LEDWidget("Switcher")
      
              leds_layout.addWidget(self.led1)
              leds_layout.addWidget(self.led2)
              leds_layout.addWidget(self.led3)
              leds_layout.addWidget(self.led4)
              leds_layout.addWidget(self.led5)
              leds_layout.addWidget(self.led6)
      
              self.led1.set_on(None)
              self.led2.set_on(None)
              self.led3.set_on(None)
              self.led4.set_on(None)
              self.led5.set_on(None)
              self.led6.set_on(None)
      
              # Layout for buttons
              buttons_layout = QHBoxLayout()
              #self.toggle_button = QPushButton("Toggle All LEDs")
              #self.toggle_button.clicked.connect(self.toggle_all_leds)
      
              self.close_button = QPushButton("OK")
              self.close_button.setFixedSize(QSize(100,30))
              self.close_button.clicked.connect(self.close)
      
              #buttons_layout.addWidget(self.toggle_button)
              buttons_layout.addWidget(self.close_button)
      
              main_layout.addLayout(leds_layout)
              main_layout.addLayout(buttons_layout)
              central_widget.setLayout(main_layout)
              self.setCentralWidget(central_widget)
      
          #def toggle_all_leds(self):
              # Example of how to turn LEDs on and off
              #if self.led1.is_on():
                  #self.led1.set_on(False)
                  #self.led2.set_on(False)
                  #self.led3.set_on(False)
              #else:
                  #self.led1.set_on(True)
                  #self.led2.set_on(True)
                  #self.led3.set_on(True)
      
      if __name__ == "__main__":
          app = QApplication(sys.argv)
          window = MainWindow()
          window.show()
          sys.exit(app.exec())
      

      The Qt environment does throw a few warnings... but none of these seem to be material, since they are consistently presented both when the window appears and fails to appear.

      # /root/Test/bin/python3 Test4.py
      Failed to create wl_display (No such file or directory)
      qt.qpa.plugin: Could not load the Qt platform plugin "wayland" in "" even though it was found.
      qt.qpa.theme.dbus: Session DBus not running.
      qt.qpa.theme.dbus: Application will not react to setting changes.
       Check your DBus installation.
      qt.qpa.theme.gnome: dbus connection failed. Last error:  QDBusError("org.freedesktop.DBus.Error.NoReply", "Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.")
      qt.qpa.theme.dbus: Session DBus not running.
      qt.qpa.theme.dbus: Application will not react to setting changes.
       Check your DBus installation.
      qt.qpa.theme.gnome: dbus connection failed. Last error:  QDBusError("org.freedesktop.DBus.Error.NoReply", "Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.")
      

      When window fails to appear...

      # /root/Test/bin/python3 Test4.py
      Failed to create wl_display (No such file or directory)
      qt.qpa.plugin: Could not load the Qt platform plugin "wayland" in "" even though it was found.
      qt.qpa.theme.dbus: Session DBus not running.
      qt.qpa.theme.dbus: Application will not react to setting changes.
       Check your DBus installation.
      qt.qpa.theme.gnome: dbus connection failed. Last error:  QDBusError("org.freedesktop.DBus.Error.NoReply", "Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.")
      qt.qpa.theme.dbus: Session DBus not running.
      qt.qpa.theme.dbus: Application will not react to setting changes.
       Check your DBus installation.
      qt.qpa.theme.gnome: dbus connection failed. Last error:  QDBusError("org.freedesktop.DBus.Error.NoReply", "Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.")
      

      Any help appreciated! Any more details required?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Jibun-no-Kage Do you use Wayland?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • J Jibun-no-Kage

        Using PyQT6 on Debian 13 and about 50% of the time, when I run by script, I get no window drawn? An application icon appears on the dash/dock (using GNOME), and the icon menu works, I can close the application from there, but again no window ever appears. This happens completely randomly. I can close the application wait a second or two and it will work, repeat the sequence and it will not work. Must confusing. Below is the code, it is pretty simple, or so I think.

        LED Module...

        import sys
        from PyQt6.QtWidgets import QWidget, QVBoxLayout, QLabel, QApplication, QPushButton, QHBoxLayout, QFrame
        from PyQt6.QtGui import QPainter, QColor, QPen
        from PyQt6.QtCore import Qt, QSize
        
        class LEDWidget(QFrame):
            """
            A custom QFrame widget to display a square LED with a label.
            """
            def __init__(self, label_text, parent=None):
                super().__init__(parent)
                self.setFixedSize(100, 80) # Fixed size for the whole widget
                self.setFrameShape(QFrame.Shape.StyledPanel)
                self.setLineWidth(1)
        
                layout = QVBoxLayout()
                layout.setAlignment(Qt.AlignmentFlag.AlignCenter)
        
                # Custom LED indicator area (a QWidget that will be custom drawn)
                self._led = QWidget(self)
                self._led.setFixedSize(40, 40)
                # Set a styled background for the LED itself, including a border
                self._led.setStyleSheet("""
                    QWidget {
                        border: 2px solid black;
                        border-radius: 5px; /* Optional: for slightly rounded corners */
                    }
                """)
        
                # Label for the LED
                self._label = QLabel(label_text, self)
                self._label.setAlignment(Qt.AlignmentFlag.AlignCenter)
        
                layout.addWidget(self._led, alignment=Qt.AlignmentFlag.AlignCenter)
                layout.addWidget(self._label, alignment=Qt.AlignmentFlag.AlignCenter)
                self.setLayout(layout)
        
                self._is_on = False
                self._update_led_color()
        
            def is_on(self):
                return self._is_on
        
            def set_on(self, state):
                self._is_on = state
                self._update_led_color()
        
            def toggle(self):
                self._is_on = not self._is_on
                self._update_led_color()
        
            def _update_led_color(self):
                # Update the background color using stylesheets
                color = "gray" if (self._is_on is None) else ("green" if self._is_on else "red")
                self._led.setStyleSheet(f"""
                    QWidget {{
                        border: 2px solid black;
                        border-radius: 5px;
                        background-color: {color};
                    }}
                """)
        

        Main...

        mport sys
        from PyQt6.QtWidgets import QApplication, QMainWindow, QWidget, QVBoxLayout, QHBoxLayout, QPushButton
        from PyQt6.QtCore import QSize
        from led_widget import LEDWidget
        
        class MainWindow(QMainWindow):
            def __init__(self):
                super().__init__()
                self.setWindowTitle("On Air Monitor")
                self.setGeometry(0, 0, 100, 250)
        
                central_widget = QWidget()
                main_layout = QVBoxLayout()
        
                # Layout for LEDs
                leds_layout = QHBoxLayout()
                self.led1 = LEDWidget("Booth")
                self.led2 = LEDWidget("Production")
                self.led3 = LEDWidget("Signs")
                self.led4 = LEDWidget("Alive")
                self.led5 = LEDWidget("Stream")
                self.led6 = LEDWidget("Switcher")
        
                leds_layout.addWidget(self.led1)
                leds_layout.addWidget(self.led2)
                leds_layout.addWidget(self.led3)
                leds_layout.addWidget(self.led4)
                leds_layout.addWidget(self.led5)
                leds_layout.addWidget(self.led6)
        
                self.led1.set_on(None)
                self.led2.set_on(None)
                self.led3.set_on(None)
                self.led4.set_on(None)
                self.led5.set_on(None)
                self.led6.set_on(None)
        
                # Layout for buttons
                buttons_layout = QHBoxLayout()
                #self.toggle_button = QPushButton("Toggle All LEDs")
                #self.toggle_button.clicked.connect(self.toggle_all_leds)
        
                self.close_button = QPushButton("OK")
                self.close_button.setFixedSize(QSize(100,30))
                self.close_button.clicked.connect(self.close)
        
                #buttons_layout.addWidget(self.toggle_button)
                buttons_layout.addWidget(self.close_button)
        
                main_layout.addLayout(leds_layout)
                main_layout.addLayout(buttons_layout)
                central_widget.setLayout(main_layout)
                self.setCentralWidget(central_widget)
        
            #def toggle_all_leds(self):
                # Example of how to turn LEDs on and off
                #if self.led1.is_on():
                    #self.led1.set_on(False)
                    #self.led2.set_on(False)
                    #self.led3.set_on(False)
                #else:
                    #self.led1.set_on(True)
                    #self.led2.set_on(True)
                    #self.led3.set_on(True)
        
        if __name__ == "__main__":
            app = QApplication(sys.argv)
            window = MainWindow()
            window.show()
            sys.exit(app.exec())
        

        The Qt environment does throw a few warnings... but none of these seem to be material, since they are consistently presented both when the window appears and fails to appear.

        # /root/Test/bin/python3 Test4.py
        Failed to create wl_display (No such file or directory)
        qt.qpa.plugin: Could not load the Qt platform plugin "wayland" in "" even though it was found.
        qt.qpa.theme.dbus: Session DBus not running.
        qt.qpa.theme.dbus: Application will not react to setting changes.
         Check your DBus installation.
        qt.qpa.theme.gnome: dbus connection failed. Last error:  QDBusError("org.freedesktop.DBus.Error.NoReply", "Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.")
        qt.qpa.theme.dbus: Session DBus not running.
        qt.qpa.theme.dbus: Application will not react to setting changes.
         Check your DBus installation.
        qt.qpa.theme.gnome: dbus connection failed. Last error:  QDBusError("org.freedesktop.DBus.Error.NoReply", "Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.")
        

        When window fails to appear...

        # /root/Test/bin/python3 Test4.py
        Failed to create wl_display (No such file or directory)
        qt.qpa.plugin: Could not load the Qt platform plugin "wayland" in "" even though it was found.
        qt.qpa.theme.dbus: Session DBus not running.
        qt.qpa.theme.dbus: Application will not react to setting changes.
         Check your DBus installation.
        qt.qpa.theme.gnome: dbus connection failed. Last error:  QDBusError("org.freedesktop.DBus.Error.NoReply", "Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.")
        qt.qpa.theme.dbus: Session DBus not running.
        qt.qpa.theme.dbus: Application will not react to setting changes.
         Check your DBus installation.
        qt.qpa.theme.gnome: dbus connection failed. Last error:  QDBusError("org.freedesktop.DBus.Error.NoReply", "Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.")
        

        Any help appreciated! Any more details required?

        I Offline
        I Offline
        IgKh
        wrote on last edited by
        #3

        @Jibun-no-Kage why are you running the application as root?

        1 Reply Last reply
        2

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved