【发布时间】:2017-09-07 17:57:07
【问题描述】:
我正在尝试在 QLabel 上显示连续图像 图像编号从 0000000 到 0000199 问题是 num 变量打印空字符串
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys, time
class Animation(QMainWindow):
def __init__(self, parent=None):
super(Animation, self).__init__(parent)
self.resize(QSize(720, 480))
self.imageViewer = QLabel(self)
self.setCentralWidget(self.imageViewer)
startBtn = QPushButton("start", self)
startBtn.clicked.connect(self.start)
self.statusBar().addWidget(startBtn)
def start(self):
i = 0
while 1:
num = ("0" * (len(str(i)) - 7)) + str(i)
name = "frame" + num + ".png"
print ("0" * (len(str(i)) - 7))
self.imageViewer.setPixmap(QPixmap(name))
if i == 199:
break
i += 1
time.sleep(1)
app = QApplication(sys.argv)
test = Animation()
test.show()
app.exec_()
请帮忙
【问题讨论】:
-
不,我改变主意了
标签: python python-2.7 pyqt pyqt4 qpixmap