[QGIS-Developer] Problems accessing Dockwidget Features

Luís Miguel Royo Pérez luis.miguel.royo at gmail.com
Fri Dec 29 07:21:07 PST 2017


 It worked!

self.dockwidget = MyDockWidget()

That's the way it worked for me!

Thanks a lot !! ^^




2017-12-29 13:05 GMT+01:00 Richard Duivenvoorde <rdmailings at duif.net>:

> Hi,
>
> Apparently you do not declare the self.dockwidget anywhere?
> As everwhere where you try to USE that it appears to be None.
>
> Normally in the 'initGui' function you create your dialog or dockwidget
> using something like:
>
> self.dlg = MyDialog(self.iface)
> or in your case there should be:
> self.dockwidget = MyDockWidget(self.iface)   <= your constructor
>
> my feeling is that you miss that step (or have a small naming error)
>
> HTH
>
> Richard Duivenvoorde
>
> On 29-12-17 12:58, Luís Miguel Royo Pérez wrote:
> > Hello, 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.
> >
> > |defrun(self):"""Run method that loads and starts the
> > plugin"""self.dockwidget.comboBox.clear()fori
> > inrange(9):self.dockwidget.comboBox.addItem(str(i))
> ifnotself.pluginIsActive:self.pluginIsActive
> > =True#print "** STARTING PruebaExp"# dockwidget may not exist if:# first
> > run of plugin# removed on close (see self.onClosePlugin
> > method)ifself.dockwidget ==None:# Create the dockwidget (after
> > translation) and keep referenceself.dockwidget =PruebaExpDockWidget()#
> > connect to provide cleanup on closing of
> > dockwidgetself.dockwidget.closingPlugin.connect(self.onClosePlugin)#
> > show the dockwidget# TODO: fix to allow choice of dock
> > locationself.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 "/home/luismi/.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.
> >
> >
> >
> > --
> > Luís Miguel Royo Pérez.
> > Analista-Programador GIS
> > Av. Blasco Ibañez nº 1. Manises (Valencia)
> > Teléfono: 679846103
> > web: inisig.com <http://inisig.com>
> >
> >
> >
> > _______________________________________________
> > QGIS-Developer mailing list
> > QGIS-Developer at lists.osgeo.org
> > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> >
>
>


-- 
Luís Miguel Royo Pérez.
Analista-Programador GIS
Av. Blasco Ibañez nº 1. Manises (Valencia)
Teléfono: 679846103
web: inisig.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20171229/136813ba/attachment.html>


More information about the QGIS-Developer mailing list