Hi all, I would like to attach a 'menu' when user left-mouse click onto the
QPushButton.
Not sure if there are any things that I am suppose to keep a lookout for
when integrating/ using Maya and PyQt stuff...
While I tried my code as follows, it works:
cmds.window()
cams = cmds.ls(camera = 1, visible =1)
createdCams = cmds.listRelatives(geos, parent=1)
cmds.popupMenu(button=1)
for cam in createdCams:
cmds.menuItem(cam)
cmds.showWindow()
However, as I tried to integrate it into this UI of mine, nothing (no menu
list for me to choose from) seems to be happening when I click on the
button 'Get current Cam', otherwise I may be getting an error -
*# Traceback (most recent call last):# File "<maya console>", line 32, in
getCamera# TypeError: Invalid flag 'camera'*
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import maya.cmds as cmds
import maya.mel as mel
class orientCameraUI(QDialog):
def __init__(self, parent=None):
super(orientCameraUI, self).__init__(parent)
self.resize(300,225)
self.initUI()
self.createConnections()
def initUI(self):
self.setWindowTitle('OrientControl UI')
self.getCurrentCamBtn = QPushButton('Get current CAM')
self.orientToCamBtn = QPushButton('Orient To Cam View')
#self.autoTrackBtn = QPushButton('Auto Track')
self.currentCamTxt = QLineEdit()
gridLayout = QGridLayout()
gridLayout.addWidget(self.getCurrentCamBtn, 0, 1)
gridLayout.addWidget(self.currentCamTxt, 0, 2)
self.setLayout(gridLayout)
def createConnections(self):
self.connect(self.getCurrentCamBtn, SIGNAL('clicked()'), self.
getCamera)
def getCamera(self):
cams = cmds.ls(camera = 1, visible =1)
createdCams = cmds.listRelatives(geos, parent=1)
cmds.popupMenu(button=1)
for cam in createdCams:
cmds.menuItem(cam)
def main():
global app
global form
app = qApp
form = orientCameraUI()
form.show()
if __name__ == '__main__':
main()
Any advices?
--
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/508eae5f-632c-4eac-8a73-f5f74acab9b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.