Show / hide panels in the QGIS Python console

I want to operate the panel from the QGIS python plugin. Examined.

I referred to the following exchanges. https://gis.stackexchange.com/questions/317058/how-to-add-dockwidget-above-the-layer-panel-using-pyqgis

If you can switch the layer panel in the Python console It's easy to implement in a plugin, isn't it?

So start the Python console and run the following command

from PyQt4.QtGui import QDockWidget

#Get layer panel (return value is array)
layersPanel = [x for x in iface.mainWindow().findChildren(QDockWidget) if x.objectName() == 'Layers']

#I'll show you
layersPanel[0].setVisible(True)

#I'll erase it
layersPanel[0].setVisible(False)

did it. How to find the name specified in objectName by displaying it in the above loop. From the QGIS repository "qgisapp.cpp" to mLayerTreeDock-> setObjectName (" Layers "); I think you'll find what you're adding to.

that's all

Recommended Posts

Show / hide panels in the QGIS Python console
Show pyramids in Python
Show decimal point in Python
Download the file in Python
Find the difference in Python
[Python] Show multiple windows in Tkinter
Getting the arXiv API in Python
Python in the browser: Brython's recommendation
Save the binary file in Python
Hit the Sesami API in Python
Hide websockets async / await in Python3
Get the desktop path in Python
Get the script path in Python
In the python command python points to python3.8
Implement the Singleton pattern in Python
Hit the web API in Python
I wrote the queue in Python
Calculate the previous month in Python
Examine the object's class in python
Get the desktop path in Python
Get the host name in Python
Access the Twitter API in Python
The first step in Python Matplotlib
I wrote the stack in Python
Master the weakref module in Python
Make the Python console covered with UNKO
Learn the design pattern "Prototype" in Python
Learn the design pattern "Builder" in Python
Load the remote Python SDK in IntelliJ
[Python] View dataframe in VScode debug console
Try using the Wunderlist API in Python
Check the behavior of destructor in Python
Learn the design pattern "Flyweight" in Python
Try using the Kraken API in Python
How to hide the command prompt when running python in visual studio 2015
Learn the design pattern "Observer" in Python
Learn the design pattern "Memento" in Python
Learn the design pattern "Proxy" in Python
Write the test in a python docstring
Learn the design pattern "Command" in Python
OR the List in Python (zip function)
Display Python 3 in the browser with MAMP
Tweet using the Twitter API in Python
Learn the design pattern "Visitor" in Python
Learn the design pattern "Bridge" in Python
Check if the URL exists in Python
Learn the design pattern "Mediator" in Python
Associate the table set in python models.py
Learn the design pattern "Decorator" in Python
Run the Python interpreter in a script
The result of installing python in Anaconda
What is "mahjong" in the Python library? ??
Read the file line by line in Python
Read the file line by line in Python
MongoDB for the first time in Python
Learn the design pattern "Iterator" in Python
The basics of running NoxPlayer in Python
Learn the design pattern "Strategy" in Python
Learn the design pattern "Composite" in Python
Solve the maximum subarray problem in Python
In search of the fastest FizzBuzz in Python