Hiding individual tabs in a tab layout?

27 views
Skip to first unread message

Ravi Jagannadhan

unread,
Nov 14, 2023, 11:27:07 AM11/14/23
to python_in...@googlegroups.com
Hi all, is it possible to hide individual tabs in a tab layout? 

Ravi
“There are no dumb questions” - Carl Sagan

Marcus Ottosson

unread,
Nov 14, 2023, 5:07:54 PM11/14/23
to python_in...@googlegroups.com
It would depend on how the tabs are made, are they made via PySide or cmds?

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/BL3PR10MB61639DFE04B08ABB150636B5F6B2A%40BL3PR10MB6163.namprd10.prod.outlook.com.

Ravi Jagannadhan

unread,
Nov 14, 2023, 5:35:01 PM11/14/23
to python_in...@googlegroups.com
Alas, they're made via cmds.



--
Where we have strong emotions, we're liable to fool ourselves - Carl Sagan

Marcus Ottosson

unread,
Nov 15, 2023, 3:15:47 AM11/15/23
to python_in...@googlegroups.com

In that case, I can think of 2 options.

  1. See if there’s another command in cmds you could use to manipulate already-created tabs, I’m not familiar with this part myself so can’t say for sure
  2. Alternatively, whatever cmds does it is Qt that is ultimately drawing the tabs, which means you can access them via PySide to perform further manipulation

I suspect there is a method of converting a widget created via cmds to its corresponding Qt widget, from there you can navigate the widget via widget.parent() and widget.children() until you find the QTabWidget or whichever widget is doing the drawing of tabs. If there isn’t such a method, you can navigate from top-down via PySide.QWidgets.QApplication.instance() or by finding the Maya main window.


Juan Moraga

unread,
Nov 15, 2023, 4:31:45 AM11/15/23
to python_in...@googlegroups.com
You can generate a Qt class instance, from a cmds gui widget using wrapInstance from shiboken.
I have used this in the past:

from PySide2.QtWidgets import QMenu
from maya.OpenMayaUI import MQtUtil
from shiboken2 import wrapInstance
from maya import cmds

cmds_menu: str = cmds.menu(label="cmds_menu", parent="MayaWindow").split("|")[-1]
control: "SwigPyObject" = MQtUtil.findControl(str(cmds_menu))
qt_menu: QMenu = wrapInstance(int(control), QMenu)





--
Juan Moraga
Supervising Pipeline & Technical Direction @ MondoTV

Portfolio: https://juanmoraga.dev
LInkedin: https://www.linkedin.com/in/juanmoragamartin/
Reply all
Reply to author
Forward
0 new messages