I'm not sure why the aboutToShow signal didn't work for you. It works just
fine for me:

        ...
        menu = QtGui.QMenu(self)
        self.setMenu(menu)
        menu.aboutToShow.connect(self._updateMenu)

    def _updateMenu(self):
        menu = self.menu()
        menu.clear()
        allCams = cmds.ls(type='camera', visible=True)
        if not allCams:
            return
        camLs = cmds.listRelatives(allCams, p=True)
        for item in camLs:
            menu.addAction(item)

​

On Tue, Oct 7, 2014 at 11:14 PM, likage <[email protected]> wrote:

> I think I may have done it wrong or what as the signal *'aboutToShow'*
> does not seems to be generating any sorts of effects... Likewise if I tried
> to set the *setCameraBtn* to have a '*clicked*' signal
>
> But if I were to incorporate the following into my *createConnections*,
> the menu did managed to get updated but there is a laggy-ness in it, where
> I will need to press the button twice before I am getting the correct list
> of cameras.
> self.connect(self.setCameraBtn, SIGNAL("pressed()"), self.camMenu)
>
>
>
>
> On Friday, October 3, 2014 1:34:42 PM UTC+8, Justin Israel wrote:
>>
>> You have a couple ways to go about it. Either your camMenu function gets
>> called whenever you need to trigger an update, and it will replace the
>> button menu with a new one. Or it can edit the same menu over and over. Or,
>> you can create the menu once and connect it's aboutToShow signal to a
>> function that will update it.
>>
>> I actually would prefer the last one. You can just clear and repopulate
>> the menu each time they click it, which means that you don't need to keep
>> the menu updated at any other time.
>>  On 3/10/2014 4:21 PM, "likage" <[email protected]> wrote:
>>
>>> Hi Justin, thank you for the reply.
>>> Based on what you have mentioned, can I actually placed the updating
>>> within the *camMenu* function? Or should I re-define it as another
>>> function?
>>>
>>> --
>>> 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/9a5730d9-e73c-4fd3-85b8-
>>> 21282c2f6536%40googlegroups.com
>>> <https://groups.google.com/d/msgid/python_inside_maya/9a5730d9-e73c-4fd3-85b8-21282c2f6536%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/18628e12-5447-49a3-80ae-8fcf9383d730%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/18628e12-5447-49a3-80ae-8fcf9383d730%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/CAPGFgA2K7ts_r4W0tvSJqVhgrRY%2BRQf2fN0Gq%2Bi-5CmjEAML%3DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to