[Qgis-developer] deactivating toolbar with plugin

Larry Shaffer larrys at dakotacarto.com
Mon Apr 2 17:13:20 EDT 2012


Hi Aaron,

On Mon, Apr 2, 2012 at 2:16 PM, SJWC GIS <sjwcgis at gmail.com> wrote:
> Hello all,
>
> I'm creating a qgis python plugin.  One of the functions of the plugin is to
> customize the qgis interface by turning off a few toolbars.  For most
> toolbars, this isn't a problem, but for some reason I can't find a way to
> shut off the "Label" toolbar.  For most toolbars, the following statements
> are working...
>
> self.iface.digitizeToolBar().setVisible(False)
>
> But I can't find a labelToolBar() object that I can do this operation with.
>  Does anyone have any guidance on why this is different?  I'm not noticing
> any plugins that might be influencing this...  Thanks!

Seems there is no method in the QgisInterface class for accessing the
new label toolbar yet.

Try...

    iface.mainWindow().findChild(QToolBar,"mLabelToolBar").setVisible(False)

I found the object name for the label toolbar using:

    toolbars = iface.mainWindow().findChildren(QToolBar)

    for toolbar in toolbars:
        print toolbar.objectName()

Which returned this on my QGIS setup:

    mFileToolBar mLayerToolBar mDigitizeToolBar
mAdvancedDigitizeToolBar mMapNavToolBar mAttributesToolBar
mPluginToolBar mHelpToolBar mRasterToolBar mLabelToolBar OpenStreetMap


There's probably a more direct solution than the 'findChild()' method.

Regards,

Larry Shaffer
Dakota Cartography
Black Hills, South Dakota


More information about the Qgis-developer mailing list