The viewer widget is a QGLWidget which does its painting asynchronously so
calling update() or repaint() doesn't really have an immediate effect.

You can use...

pixmap = QtGui.QPixmap.grabWindow(
  THE_VIEWER_WIDGET.winId()
)

This will grab the fully rendered pixmap of the widget from the window
system.  Take note that grabWindow(...) will also pickup any windows you
currently have over the widget.



On Tue, Oct 25, 2016 at 3:59 PM, Carl Schröter <[email protected]> wrote:

> I played around a bit and it seems like you both are right.
> You can grab the viewer-widget, but when I simply create a pixmap from it
> I get a white square with overlays (roto, roi, etc.)
>
>
> from PySide import QtGui, QtCore
>
> for i in QtGui.qApp.allWidgets():
>   # the panes are named!
>   if i.windowTitle() == 'Viewer1':
>     # 
> QtGui.QPixmap.grabWidget(i).save('T:\\nukeviewertests\\complete-viewer.png',
> 'png')
>     for id, child in enumerate(i.findChildren(QtGui.QWidget)):
>       # lazy way to figure out what's interesting
>       # QtGui.QPixmap.grabWidget(child).save('T:\\
> nukeviewertests\\'+str(id)+'.png', 'png')
>       if id == 0:
>         # this seems to be the viewer bbox starting at bottom left
>         print child
>         child.setStyleSheet("""QWidget { border: 2px solid green;}""")
>       elif id == 1:
>         # this seems to be the complete viewer area we are after
>         print child
>         child.setStyleSheet("""QWidget { border: 2px solid red;}""")
>
>
> Seems like there is more going on than simply drawing a widget.
> Did you try using *nukescripts.captureViewer*? Might be a more elegant
> solution.
>
> Best,
> Carl
>
>
>
> Mads Lund <[email protected]> schrieb am Di., 25. Okt. 2016 um
> 21:09 Uhr:
>
> Guess i don't remember correctly then...
>
> On Tue, Oct 25, 2016 at 9:41 PM, Nathan Dunsworth <
> [email protected]> wrote:
>
> Incorrect...
>
> You can grab the pixmap of the viewer if you do it correctly.
>
> On Tue, Oct 25, 2016 at 12:40 PM, Mads Lund <[email protected]> wrote:
>
> The viewer is a seperate GL thing if i remember correctly so in python it
> just appears all black sadly.
>
> On Tue, Oct 25, 2016 at 6:49 PM, Fredrik Averpil <
> [email protected]> wrote:
>
> I’m trying to figure out how I can find the viewer’s widget (and if you
> have more than one viewer, I’ll just settle with the first one).
>
> Does anyone have an idea on how it can be fetched?
>
> I’ve tried to loop over all widgets in QtGui.qApp.topLevelWidgets(),
> identified which ones are layouts and then iterated through their contents…
> but I haven’t found anything resembling a viewer.
>
> I need the widget object, as my goal is to be able to grab a screenshot of
> it using QtGui.QPixmap.grabWidget(widget):
>
> screenshot = QtGui.QPixmap.grabWidget(widget)
> filepath = os.path.expanduser("~/screenshot.png")
> screenshot.save(filepath, 'png')
>
> Any ideas?
>
> Regards,
> Fredrik
> ​
>
> _______________________________________________
> Nuke-python mailing list
> [email protected], http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>
>
>
> _______________________________________________
> Nuke-python mailing list
> [email protected], http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>
>
>
> _______________________________________________
> Nuke-python mailing list
> [email protected], http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>
>
> _______________________________________________
> Nuke-python mailing list
> [email protected], http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>
>
> _______________________________________________
> Nuke-python mailing list
> [email protected], http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>
>
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to