Hey there,
You want to get the camera that was selected from the QMenu? Then instead
of connecting to the button click, you probably want to watch the signals
on the actual QMenu, which will tell you exactly which action was selected.
Here is a simplified version:
def camMenu(self):
allCams = cmds.ls(type='camera', visible = 1)
camLs = cmds.listRelatives(allCams, p=1)
menu = QMenu("menu", self.camSelBtn)
for n in camLs:
menu.addAction(n)
self.camSelBtn.setMenu(menu)
menu.triggered.connect(self._camSelected)
def _camSelected(self, action):
self.currentCamTxt.setText(action.text())
On Tue, Sep 30, 2014 at 7:57 PM, likage <[email protected]> wrote:
> I am trying to get the selection that was listed in the qMenu and based on
> the user selection from the qMenu - camSelBtn, it will display the
> selection into a qLineEdit - currentCamTxt
>
> However while I am able to get the menu working, the grabbing of text of
> the selection is not working.
>
>
> def camMenu(self):
> allCams = cmds.ls(type='camera', visible = 1)
> camLs = cmds.listRelatives(allCams, p=1)
> menu = QMenu("menu", self.camSelBtn)
> for n in camLs:
> menu.addAction(QAction(n, menu))
> self.camSelBtn.setMenu(menu)
>
> def createConnections(self):
> self.connect(self.setCameraBtn, SIGNAL('clicked()'), self.setCamera)
>
> def setCamera(self):
> for sel in self.camMenu.menu():
> self.currentCamTxt.setText()
>
>
>
> --
> 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/2c9cdcc9-9263-4b8b-a7ce-47fbe9004cff%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/2c9cdcc9-9263-4b8b-a7ce-47fbe9004cff%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
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/CAPGFgA36S2spEGKgsG5mqB4yJjNJ15m%3DxdGBOimWGfuia%2BNj4Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.