Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Authentication Rejected: No auth protocols/host-based auth failed



  • I am new to PyQt and am trying to learn the basics for GUI building. I am following a tutorial to build a window and a button that displays text, but I keep encountering this error. I am running a Manjaro distro with latest kernel.
    qt5ct: using qt5ct plugin
    Qt: Session management error: Authentication Rejected, reason : None of the authentication protocols specified are supported and host-based authentication failed

    #!/usr/bin/python3
    # -*- coding: utf:8 -*-
    
    import sys
    from PyQt5.QtWidgets import (QWidget, QToolTip, 
        QPushButton, QApplication)
    from PyQt5.QtGui import QFont    
    
    
    class Example(QWidget):
        
        def __init__(self):
            super().__init__()
            
            self.initUI()
            
            
        def initUI(self):
            
            QToolTip.setFont(QFont('SansSerif', 10))
            
            self.setToolTip('This is a <b>QWidget</b> widget')
            
            btn = QPushButton('Button', self)
            btn.setToolTip('This is a <b>QPushButton</b> widget')
            btn.resize(btn.sizeHint())
            btn.move(50, 50)       
            
            self.setGeometry(300, 300, 300, 200)
            self.setWindowTitle('Tooltips')    
            self.show()
            
    if __name__ == '__main__':
        
        app = QApplication(sys.argv)
        ex = Example()
        sys.exit(app.exec_())
    

  • Banned

    In looking into this I actually found the example you pulled your version from and I suggest you do not use any more examples by that individual as they obviously do not know much about coding in python-qt

    from PyQt5.QtCore    import pyqtSlot
    from PyQt5.QtGui     import QFont
    from PyQt5.QtWidgets import QApplication, QWidget, QToolTip
    from PyQt5.QtWidgets import QHBoxLayout, QVBoxLayout, QPushButton
    
    # Note always import everything else after your PyQt imports
    
    class Example(QWidget):
        def __init__(self):
          # First do not use super( ) unless you are fully aware of what 3 major issues 
          # you must code for in conjunction with using it and the actual rare issue 
          # that it is meant to solve. Note this rare issue is rare and unless you are 
          # doing some complicated inheritance you will most likely never run into that
          # issue -- however the 3 major issues it creates by using it you are much more 
          # likely to run into than the rare issue its meant for
          #
          # Further this implementation of super() was incorrect
          #  super().__init__()
            QWidget.__init__(self)
    
          # It is always best to keep like things grouped and in some sort of order
          # layout for easier readability
            Top=300; Left=300; Width=250; Hight=100
            self.setGeometry(Left, Top, Width, Hight)
            self.setWindowTitle('Tooltips')    
            
            MyFont = QFont('SansSerif', 10)
            QToolTip.setFont(MyFont)
            self.setToolTip('This is a <b>QWidget</b> object')
            
            self.btnPush = QPushButton('Button', self)
            self.btnPush.setToolTip('This is a <b>QPushButton</b> object')
            self.btnPush.resize(self.btnPush.sizeHint())
          # Normally you want one of these of some sort associated with your button
            self.btnPush.clicked.connect(self.ButtonPushed)
          # Windows are dynamic thus static placement is usually bad but sometimes
          # sometimes you want granular control in which case you use QGridLayout
          # self.btnPush.move(50, 50) 
    
          # This handles adding the Button to a Dynamic Horizontal container
            HBox = QHBoxLayout()
            HBox.addWidget(self.btnPush)
            HBox.addStretch(1)
            
          # This handles adding the Dynamic Horizontal container into a 
          # Dynamic Vertical container
            VBox = QVBoxLayout()
            VBox.addLayout(HBox)
            VBox.addStretch(1)
    
          # Note: The combination of the HBox and VBox is used to put the
          # QPushbutton in the upper left corner of the QWidget window and
          # this can be adjusted based on placement preferences
    
          # Finally this is required if you want it displayed within your QWidget        
            self.setLayout(VBox)
    
        @pyqtSlot()
        def ButtonPushed(self):
            print('*** Oh my are you not a pushy one. ***')
            
    if __name__ == "__main__":
      # If you are not using Command Line objects then you do not need sys.argv
      # However if you are using Command Line objects you should look into 
      # argparser library as it handles them much cleaner and more intuitively
      # app = QApplication(sys.argv)
        MainEventHandler = QApplication([])
    
        application = Example()
        application.show()
        
      # This is the old PyQt4 method of calling this
      # sys.exit(app.exec_())
      # This is the current PyQt5 method of calling this
        MainEventHandler.exec()
    
      # If anyone wants more extensive free help I run an online lab-like classroom-like 
      # message server feel free and drop by you will not be able to post until I clear 
      # you as a student as this prevents spammers so if interested here is the invite
      # https://discord.gg/3D8huKC
    

Log in to reply