[Python] AttributeError: 'MainWindow' object has no attribute 'checkButtonGroup'

Discussão em 'Python' iniciado por Stack, Março 3, 2025.

  1. Stack

    Stack Membro Participativo

    While im doing my project to create a Desktop App using QT Design and PySide6, and run a python main.py, this error show up

    PS D:\Marleen\App Dev 2.0> python main.py
    Traceback (most recent call last):
    File "D:\Marleen\App Dev 2.0\main.py", line 70, in <module>
    window = MainWindow()
    ^^^^^^^^^^^^
    File "D:\Marleen\App Dev 2.0\main.py", line 42, in __init__
    loadJsonStyle(self, self.ui, jsonFiles = {
    File "C:\Users\mamam\AppData\Local\Programs\Python\Python311\Lib\site-packages\Custom_Widgets\JSonStyles\__init__.py", line 55, in loadJsonStyle
    applyJsonStyle(self, update = update)
    File "C:\Users\mamam\AppData\Local\Programs\Python\Python311\Lib\site-packages\Custom_Widgets\JSonStyles\__init__.py", line 253, in applyJsonStyle
    btn.clicked.connect(self.checkButtonGroup)
    ^^^^^^^^^^^^^^^^^^^^^
    AttributeError: 'MainWindow' object has no attribute 'checkButtonGroup'


    This is my main.py code

    import os
    import sys

    from Custom_Widgets import *
    from Custom_Widgets.QAppSettings import QAppSettings

    from src.ui_interface import *

    class MainWindow(QMainWindow):
    def __init__(self, parent=None):
    QMainWindow.__init__(self)
    self.ui = Ui_MainWindow()
    self.ui.setupUi(self)

    ########################################################################
    # APPLY JSON STYLESHEET
    ########################################################################
    # self = QMainWindow class
    # self.ui = Ui_MainWindow / user interface class
    #Use this if you only have one json file named "style.json" inside the root directory, "json" directory or "jsonstyles" folder.
    # loadJsonStyle(self, self.ui)

    # Use this to specify your json file(s) path/name
    loadJsonStyle(self, self.ui, jsonFiles = {
    "json-styles/style.json"
    })

    ########################################################################

    #######################################################################
    # SHOW WINDOW
    #######################################################################
    self.show()

    ########################################################################
    # UPDATE APP SETTINGS LOADED FROM JSON STYLESHEET
    # ITS IMPORTANT TO RUN THIS AFTER SHOWING THE WINDOW
    # THIS PROCESS WILL RUN ON A SEPARATE THREAD WHEN GENERATING NEW ICONS
    # TO PREVENT THE WINDOW FROM BEING UNRESPONSIVE
    ########################################################################
    # self = QMainWindow class
    QAppSettings.updateAppSettings(self)

    ########################################################################
    ## EXECUTE APP
    ########################################################################
    if __name__ == "__main__":
    app = QApplication(sys.argv)
    ########################################################################
    ##
    ########################################################################
    window = MainWindow()
    window.show()
    sys.exit(app.exec_())
    ########################################################################
    ## END===>
    ########################################################################



    Actually before theres no problem and everything is okay but somehow when i try to run the project again it showed up with this error. Pls help

    Continue reading...

Compartilhe esta Página