Play image sequence using Qt QMainWindow -
i have image sequence rendered out. want payback in simple qmainwindow or qdialog. have sofar. loads images qlabel, cant see label beingness updated, show lastly loaded image, , nil in between. maybe knows something?
from pyside import qtcore, qtgui import shiboken import maya.openmayaui apiui import time def getmayawindow(): """ main maya window qtgui.qmainwindow instance @return: qtgui.qmainwindow instance of top level maya windows """ ptr = apiui.mqtutil.mainwindow() if ptr not none: homecoming shiboken.wrapinstance(long(ptr), qtgui.qwidget) class viewer(qtgui.qmainwindow): def __init__(self, parent = getmayawindow()): super(viewer, self).__init__(parent) self.setgeometry(400, 600, 400, 300) self.setui() def setui(self): self.label = qtgui.qlabel() self.setcentralwidget(self.label) def showui(self): self.show() def loadimage(self, path): self.label.clear() image = qtgui.qimage(path) pp = qtgui.qpixmap.fromimage(image) self.label.setpixmap(pp.scaled( self.label.size(), qtcore.qt.keepaspectratio, qtcore.qt.smoothtransformation)) x = viewer() x.showui() in range(1, 11): x.loadimage("c://anim%03d.png" % i) time.sleep(0.5)
you alter pixmaps in loop , sleep (stop) gui
thread, that's why gui
freeze.
http://www.tutorialspoint.com/python/time_sleep.htm
it not correct. qlabel.repaint()
bad solution because still blocks gui
. of course of study can utilize processevents
bad approach too.
you should utilize qtimer
purpose, utilize timeout()
signal, create slot , alter pixmaps in slot. in case gui
not blocked because qtimer
works asynchronously , images successfuly changed.
same code loop , sleep
can help when code execute in thread (multi threading) not necessary because there special class qtimer
.
image qt sequence playback
Sleep() function actually suspends the processing of the thread in which it is called by the operating system, allowing other threads and processes to execute while it sleeps. With multiple threads and processes, sleep() suspends your thread - it uses next to zero processing power.
ReplyDelete