Hi Ruchit,

I am not sure exactly what you are asking for. Do you want to create a Qt 
UI that performs some maya command. Here is a small snippet that creates a 
label and a small window.

Everything you see in the videos is all custom layouts built in Qt.

from maya import OpenMayaUI as omui
from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWidgets import *
from shiboken2 import wrapInstance  # << TODO: READ UP ABOUT

mayaMainWindowPtr = omui.MQtUtil.mainWindow()
mayaWindow = wrapInstance(long(mayaMainWindowPtr), QWidget)

hello = QLabel("test", parent=mayaWindow)
hello.setObjectName("test")
hello.setWindowFlags(Qt.Window) # makes the widget a standalone window even 
though it is parented
hello.show()


Here is some old code that creates a button adds it to a layout. you will 
have to add or set the layout for the active QWidget/QWindow
btn = QtGui.QButton("Button Name")
layout = QHBoxLayout()
layout.addWidget(btn)

To make the button execute some maya code:
btn.clicked.connect(clickedButton)

def clickedButton():
    # Maya code here

I hope that makes some sense. Qt is an extremely large API and you can make 
it do a ton of things, best would be to get a widget to appear and a 
button, and make the button perform something, and build on it from there.

Help 
Docs: 
http://help.autodesk.com/view/MAYAUL/2017/ENU/?guid=__files_GUID_13434252_F0BF_4AC0_B47B_09BD626B0881_htm

Once you have got a widget displaying, look at the Qt help docs to start 
adding more widgets and 
customisations: http://doc.qt.io/qt-5/qtgui-module.html

I hope that helps,
Cheers

On Wednesday, 6 September 2017 20:18:18 UTC+10, Ruchit Bhatt wrote:
>
> Hi, 
> can i get example code to add / Modify / Remove Maya UI element in Qt way 
> using python API ?
>
> For example
> 1) set position of selected node in nodeEditor    (
> https://www.youtube.com/watch?v=pPfCM1T9IHM)
> 2) Attribute control      (https://vimeo.com/161801793)
>
> Thank you
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/1538f660-19e1-497c-a390-1c7ac7ee203c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to