Skip to content

Instantly share code, notes, and snippets.

@yamahigashi
Last active September 15, 2023 03:31
Show Gist options
  • Save yamahigashi/a842cb265215311975e0324914187ad7 to your computer and use it in GitHub Desktop.
Save yamahigashi/a842cb265215311975e0324914187ad7 to your computer and use it in GitHub Desktop.
Add corner widget to maya main menu bar.
from Qt import QtWidgets
def getMayaMainWindow():
# type: () -> QtWidgets.QWidget
for obj in QtWidgets.qApp.topLevelWidgets():
if obj.objectName() == 'MayaWindow':
return obj
else:
raise Exception("Maya main window not found")
def injectWidgetToMainMenuCorner(myWidget):
# type: (QtWidgets.QWidget) -> None
for kid in getMayaMainWindow().children():
if isinstance(kid, QtWidgets.QMenuBar):
menuBar = kid
break
else:
raise Exception("menuBar not found")
corner = menuBar.cornerWidget()
layout = corner.layout()
layout.addWidget(myWidget)
layout.update()
@yamahigashi
Copy link
Author

add_corner_widget

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment