3

I want to run python script. I don't know the name of toolbar in python script language : menu toolbar, browser panel toolbar, and label toolbar. The screenshots of the toolbars for which I don't know the python names of are:

enter image description here

enter image description here

enter image description here

To test the name of toolbar is true, I try to type in python script like this :

iface.menuToolBar().setVisible(False)
iface.browserpanelToolBar().setVisible(False)
iface.labelToolBar().setVisible(False)

But, the toolbar is still be visible. So the name of these toolbar is false. So, what the name of these toolbar?

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Feb 10, 2017 at 8:33
1
  • If you direct the pointer to the edge of toolbar, it will give you the name. I give you screenshot the toolbar : 1drv.ms/f/s!Amfzr7zpdbRqjEBvvp8DkqD3F27m Commented Feb 12, 2017 at 23:43

1 Answer 1

5

Based on the answer and comments on this post: Tool Bar visibility in PyQGIS, we can determine the name of these objects and set their visibility to False. If you go to the menubar and select Settings > Customization, you can see the types of objects used. In your case:

So, we can find all the names of objects which fall under each of those object types by using:

from PyQt4.QtGui import QToolBar, QDockWidget, QMenuBar
# Get list of all ToolBars
for x in iface.mainWindow().findChildren(QToolBar): 
 print x.objectName()
# Get list of all Dockwidgets
for x in iface.mainWindow().findChildren(QDockWidget): 
 print x.objectName()
# Get name of MenuBar
for x in iface.mainWindow().findChildren(QMenuBar): 
 print x.objectName()

Once we have determined the names of the objects you are interested in, we can hide them:

  • Menu Toolbar: iface.mainWindow().menuBar().setVisible(False)
  • Browser Panel: iface.mainWindow().findChild(QDockWidget,'Browser').setVisible(False)
  • Label Toolbar: iface.mainWindow().findChild(QToolBar,'mLabelToolBar').setVisible(False)
answered Feb 13, 2017 at 10:54
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.