def _iterate_Qt(self): if self.ready: if not self._widget_shown: w = self._width h = self._height self._widget_shown = True self.widget.resize(w + 20, h + 20) self.widget._vnc_container.setGeometry(10, 10, w, h) self.widget.show() self.lock.acquire() data = str( self.data) # trick is to copy, then it becomes threadsafe self.ready = False self.lock.release() qimage = QtGui.QImage(data, self._width, self._height, QtGui.QImage.Format_RGB32) pix = QtGui.QPixmap.fromImage(qimage) self.widget._vnc_container.setPixmap(pix) #t = time.time() #d = t-self.lastredraw; self.deltas.append( d ) #self.lastredraw = t #if len(self.deltas)==100: print( 'avg', sum(self.deltas)/100.0 ); self.deltas=[] #if d > 0.001: print d if not naali: app.processEvents() if time.time() - self._lastupdate > self._refresh: self._lastupdate = time.time() _rfbclient_.SendPointerEvent(self.clientPtr, self.mouse['x'], self.mouse['y'], self.mouse['buttonMask'])
def showImage(filename): ''' Returns a QLabel displaying the image contents of given filename. Make sure to assign the label, it will destruct when it goes out of scope. ''' image = QtGui.QImage(filename) assert not image.isNull() imageLabel = QtGui.QLabel() imageLabel.setPixmap(QtGui.QPixmap.fromImage(image)) imageLabel.setScaledContents(True) imageLabel.resize(imageLabel.pixmap.size()) imageLabel.setWindowTitle(os.path.basename(filename)) imageLabel.show()