我正在用Eric4和PyQt4创建一个应用程序。在
我有两个对话框,一个作为线程运行,另一个是一个标准对话框,里面有一个标签,我想把它改成一个图像。在
每次主窗口线程运行时,我都希望它将对话框中显示的当前图像更改为新图像。一切正常,除了每次线程运行时,它都会创建一个新的对话框,里面有新的图像——我想让它改变当前打开的对话框中的图像。在
包含图像的对话框:
class SubWindow(QDialog, Ui_subWindow):
def __init__(self, parent = None):
QDialog.__init__(self, parent)
self.setupUi(self)
self.show()
def main(self, img):
pic = self.imgView
pic.setPixmap(QtGui.QPixmap(os.getcwd() + img))
改变图像的线程:
^{pr2}$我没有包括我所有的代码,只有相关的部分。在
问题似乎是每次您希望更改图像时都会创建一个新的
SubWindow
。我建议在MainWindiw.__init__
函数中将SubWindow
创建为MainWindow
的属性:相关问题 更多 >
编程相关推荐