Ah yes, of course, findChildren is much nicer than iterating over all of them.
And using setCurrentWidget is easier than using the index as well.
I don't seem to need stacked_widget.activateWindow() though.

Nice one, thanks Matthieu!


On 31/01/17 1:49 AM, Matthieu Cadet wrote:
Mmm, this will work better in your case no ?:

the_widget = qwindow.findChildren(QtGui.QWidget,'com.nukepedia.nuBridge')

stacked_widget =  the_widget.parentWidget()

stacked_widget.setCurrentWidget(the_widget)

stacked_widget.activateWindow() # to refresh the UI so current tab highlight change


On Mon, Jan 30, 2017 at 12:08 PM, Matthieu Cadet <matthieu.ca...@gmail.com <mailto:matthieu.ca...@gmail.com>> wrote:

    I think you can shorten a bit your code
    to get your main widget:

    from PySide import QtGui

    qwindow = QtGui.qApp.activeWindow()

    my_widget_found=qwindow.findChildren(MyModule.submodule.TheWidgetClassName)

    # Result: [<MyModule.submodule.TheWidgetClassName object at
    0x5b8cbd8>]

    this was my 2cents of something that will definitely not help you
    to get your Panel as floating panel :P

    sorry

    On Mon, Jan 30, 2017 at 12:28 AM, Frank Rueter|OHUfx
    <fr...@ohufx.com <mailto:fr...@ohufx.com>> wrote:

        Looks like this does the trick, though it seems somewhat brute
        force:

        from PySide import QtGui for widget in
        QtGui.QApplication.allWidgets(): name = widget.objectName() if
        name == 'com.nukepedia.nuBridge': stackedWidget =
        widget.parentWidget()
        stackedWidget.setCurrentIndex(stackedWidget.indexOf(widget))
        break

        I will roll with that for now but if anybody has a more
        elegant solution I'm all ears.

        Cheers, frank
        On 30/01/17 11:09 AM, Frank Rueter|OHUfx wrote:
        Hi all, does anybody know if it's possible to float a docked
        QT panel via python? E.g. the equivalent of ctrl+click on the
        tab? I am just working on the nuBridge
        <https://vimeo.com/channels/nukepedia/165747936> again and
        would like to make it so that the user can call it from the
        help menu as well as create a custom panel as part of the
        workspace. I got all that in place but the challenge arises
        when trying to only use one instance of the panel (i.e.
        singleton). In that case, when the panel is already docked
        somewhere, and the user calls it from the help menu, I want
        the panel to either float, or at least come to the foreground
        (if it's a background tab at that point). Any ideas how to do
        that? I can't find native nuke commands for this so will try
        and dig into the QT widgets to see if I can force this
        behaviour. Cheers, frank
-- ohufxLogo 50x50 <http://www.ohufx.com> *vfx compositing
        <http://ohufx.com/compositing.html> | *workflow customisation
        and consulting <http://ohufx.com/customising.html>* *

        _______________________________________________
        Nuke-python mailing list
        Nuke-python@support.thefoundry.co.uk
        <mailto:Nuke-python@support.thefoundry.co.uk>,http://forums.thefoundry.co.uk/ 
<http://forums.thefoundry.co.uk/>
        http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
        <http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python>
        _______________________________________________ Nuke-python
        mailing list Nuke-python@support.thefoundry.co.uk
        <mailto:Nuke-python@support.thefoundry.co.uk>,
        http://forums.thefoundry.co.uk/
        <http://forums.thefoundry.co.uk/>
        http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
        <http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python>


-- Matthieu Cadet Compositor Artist & TD,
    nWave Digital matthieu.ca...@gmail.com
    <mailto:matthieu.ca...@gmail.com>

--
Matthieu Cadet Compositor Artist & TD,
nWave Digital matthieu.ca...@gmail.com <mailto:matthieu.ca...@gmail.com>

_______________________________________________
Nuke-python mailing list
Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________
Nuke-python mailing list
Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to