Skip to main content
added 261 characters in body
Source Link
Luismi
  • 1k
  • 9
  • 21

I'm writing a QGIS plugin but I'm facing some basic problems. The plugin is a dockwidget. I've built it with plugin Builder and then compiled the resources file.

When I try to access the comboBox to populate it with values, an error happens:

self.dockwidget.comboBox.clear() AttributeError: 'NoneType' object has no attribute 'comboBox'

I checked in the Qt _Designer the object name and it's comboBox. When I do the same with a dialog plugin, instead a dockwidget, everything seems to be right, and the comboBox is populated. This is the code for the run method.

def run(self):
    """Run method that loads and starts the plugin"""
    self.dockwidget.comboBox.clear()
    for i in range(9):            
        self.dockwidget.comboBox.addItem(str(i))

    if not self.pluginIsActive:
        self.pluginIsActive = True

        #print "** STARTING PruebaExp"

        # dockwidget may not exist if:
        #    first run of plugin
        #    removed on close (see self.onClosePlugin method)
        if self.dockwidget == None:
            # Create the dockwidget (after translation) and keep reference
            self.dockwidget = PruebaExpDockWidget()

        # connect to provide cleanup on closing of dockwidget
        self.dockwidget.closingPlugin.connect(self.onClosePlugin)

        # show the dockwidget
        # TODO: fix to allow choice of dock location
        self.iface.addDockWidget(Qt.LeftDockWidgetArea, self.dockwidget)
        self.dockwidget.show()

I don't know if it's related, but when I try to create a signal this error is show:

File "XXXXXXXXXXX/PruebaExp.py", line 176, in initGui self.dockwidget.signalBox.connect(self.enviadato) AttributeError: 'NoneType' object has no attribute 'signalBox'

Same error when I try to acces a pushButton:

File "/xxxx/xxxx/.qgis2/python/plugins/PruebaExp/PruebaExp.py", line 221, in run self.dockwidget.pushButton.clicked.connect(self.enviadato) AttributeError: 'NoneType' object has no attribute 'pushButton'

Maybe is due to something I missed during the building of the plugin. I'm using QGIS 2.18.14.

I'm writing a QGIS plugin but I'm facing some basic problems. The plugin is a dockwidget. I've built it with plugin Builder and then compiled the resources file.

When I try to access the comboBox to populate it with values, an error happens:

self.dockwidget.comboBox.clear() AttributeError: 'NoneType' object has no attribute 'comboBox'

I checked in the Qt _Designer the object name and it's comboBox. When I do the same with a dialog plugin, instead a dockwidget, everything seems to be right, and the comboBox is populated. This is the code for the run method.

def run(self):
    """Run method that loads and starts the plugin"""
    self.dockwidget.comboBox.clear()
    for i in range(9):            
        self.dockwidget.comboBox.addItem(str(i))

    if not self.pluginIsActive:
        self.pluginIsActive = True

        #print "** STARTING PruebaExp"

        # dockwidget may not exist if:
        #    first run of plugin
        #    removed on close (see self.onClosePlugin method)
        if self.dockwidget == None:
            # Create the dockwidget (after translation) and keep reference
            self.dockwidget = PruebaExpDockWidget()

        # connect to provide cleanup on closing of dockwidget
        self.dockwidget.closingPlugin.connect(self.onClosePlugin)

        # show the dockwidget
        # TODO: fix to allow choice of dock location
        self.iface.addDockWidget(Qt.LeftDockWidgetArea, self.dockwidget)
        self.dockwidget.show()

I don't know if it's related, but when I try to create a signal this error is show:

File "XXXXXXXXXXX/PruebaExp.py", line 176, in initGui self.dockwidget.signalBox.connect(self.enviadato) AttributeError: 'NoneType' object has no attribute 'signalBox'

Maybe is due to something I missed during the building of the plugin. I'm using QGIS 2.18.14.

I'm writing a QGIS plugin but I'm facing some basic problems. The plugin is a dockwidget. I've built it with plugin Builder and then compiled the resources file.

When I try to access the comboBox to populate it with values, an error happens:

self.dockwidget.comboBox.clear() AttributeError: 'NoneType' object has no attribute 'comboBox'

I checked in the Qt _Designer the object name and it's comboBox. When I do the same with a dialog plugin, instead a dockwidget, everything seems to be right, and the comboBox is populated. This is the code for the run method.

def run(self):
    """Run method that loads and starts the plugin"""
    self.dockwidget.comboBox.clear()
    for i in range(9):            
        self.dockwidget.comboBox.addItem(str(i))

    if not self.pluginIsActive:
        self.pluginIsActive = True

        #print "** STARTING PruebaExp"

        # dockwidget may not exist if:
        #    first run of plugin
        #    removed on close (see self.onClosePlugin method)
        if self.dockwidget == None:
            # Create the dockwidget (after translation) and keep reference
            self.dockwidget = PruebaExpDockWidget()

        # connect to provide cleanup on closing of dockwidget
        self.dockwidget.closingPlugin.connect(self.onClosePlugin)

        # show the dockwidget
        # TODO: fix to allow choice of dock location
        self.iface.addDockWidget(Qt.LeftDockWidgetArea, self.dockwidget)
        self.dockwidget.show()

I don't know if it's related, but when I try to create a signal this error is show:

File "XXXXXXXXXXX/PruebaExp.py", line 176, in initGui self.dockwidget.signalBox.connect(self.enviadato) AttributeError: 'NoneType' object has no attribute 'signalBox'

Same error when I try to acces a pushButton:

File "/xxxx/xxxx/.qgis2/python/plugins/PruebaExp/PruebaExp.py", line 221, in run self.dockwidget.pushButton.clicked.connect(self.enviadato) AttributeError: 'NoneType' object has no attribute 'pushButton'

Maybe is due to something I missed during the building of the plugin. I'm using QGIS 2.18.14.

Source Link
Luismi
  • 1k
  • 9
  • 21

Error Accessing Dockwidget ComboBox. QGIS Plugin. (pyqgis)

I'm writing a QGIS plugin but I'm facing some basic problems. The plugin is a dockwidget. I've built it with plugin Builder and then compiled the resources file.

When I try to access the comboBox to populate it with values, an error happens:

self.dockwidget.comboBox.clear() AttributeError: 'NoneType' object has no attribute 'comboBox'

I checked in the Qt _Designer the object name and it's comboBox. When I do the same with a dialog plugin, instead a dockwidget, everything seems to be right, and the comboBox is populated. This is the code for the run method.

def run(self):
    """Run method that loads and starts the plugin"""
    self.dockwidget.comboBox.clear()
    for i in range(9):            
        self.dockwidget.comboBox.addItem(str(i))

    if not self.pluginIsActive:
        self.pluginIsActive = True

        #print "** STARTING PruebaExp"

        # dockwidget may not exist if:
        #    first run of plugin
        #    removed on close (see self.onClosePlugin method)
        if self.dockwidget == None:
            # Create the dockwidget (after translation) and keep reference
            self.dockwidget = PruebaExpDockWidget()

        # connect to provide cleanup on closing of dockwidget
        self.dockwidget.closingPlugin.connect(self.onClosePlugin)

        # show the dockwidget
        # TODO: fix to allow choice of dock location
        self.iface.addDockWidget(Qt.LeftDockWidgetArea, self.dockwidget)
        self.dockwidget.show()

I don't know if it's related, but when I try to create a signal this error is show:

File "XXXXXXXXXXX/PruebaExp.py", line 176, in initGui self.dockwidget.signalBox.connect(self.enviadato) AttributeError: 'NoneType' object has no attribute 'signalBox'

Maybe is due to something I missed during the building of the plugin. I'm using QGIS 2.18.14.