文章标题

在ubuntu上用pyqt做图片的循环显示,程序如下:

import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import time

class Window(QWidget):

def __init__(self, parent = None):

    QWidget.__init__(self, parent)    

    self.thread = Worker()  
print "iiiiiiiii"          
    self.startButton = QPushButton(self.tr("&Start"))
    self.viewer = QLabel()
    self.viewer.setFixedSize(300, 300)
    self.connect(self.thread, SIGNAL("finished()"), self.updateUi)
    self.connect(self.thread, SIGNAL("terminated()"), self.updateUi)
    self.connect(self.thread, SIGNAL("output(QRect,QPixmap)"), self.addImage)
print "eeeeeeeeee"
    self.connect(self.startButton, SIGNAL("clicked()"), self.makePicture)
print "fffffff"

    layout = QGridLayout()


    layout.addWidget(self.startButton, 0, 2)
    layout.addWidget(self.viewer, 1, 0, 1, 3)
    self.setLayout(layout)

    self.setWindowTitle(self.tr("Simple Threading Example"))

def makePicture(self):

    print "mmmmmmmmmm"
    self.startButton.setEnabled(True)
print "pppppppp"
    #pixmap = QPixmap('1.jpg')
    #self.viewer.setPixmap(pixmap)
    self.thread.run()
print "gggggggg"



def addImage(self,rect,pixmap):


    self.viewer.setPixmap(pixmap)
print "aaaaaaaaaaaaa"
    self.viewer.update(rect)
self.update()



def updateUi(self):

    self.startButton.setEnabled(True)

class Worker(QThread):

def __init__(self, parent = None):

    QThread.__init__(self, parent)
    self.exiting = False



def __del__(self):
    self.exiting = True
    self.wait()


def run(self):#

    while not self.exiting:
    i=0
    img=['1.jpg','2.jpg','3.jpg','4.jpg']
    for i in img:
        pixmap=QPixmap(i)
            self.emit(SIGNAL("output(QRect,QPixmap)"),QRect(300,300,300,300),pixmap)
        print "run............"
            time.sleep(0.2)
        #del Window.addImage()

if name == “main“:

app = QApplication(sys.argv)
window = Window()
print "ddd"
window.show()
print "cccc"
sys.exit(app.exec_())

显示不出来照片,但是后台运行,每按下一次ctrl+c就显示一张图片,是什么问题呢?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值