我正在尝试在以下代码中将image_name
变量从第一页传递到第二页
def image_button_clicked(self):
#filter = "Images (*.png)"
included_extensions = ['jpg','jpeg', 'bmp', 'png', 'gif']
image_name,_ = QFileDialog.getOpenFileName(None, "Select an image", "", "Image Files (*.png *.jpg *.bmp)")
def FirstPage(self):
select_imageLabel = QLabel("Image")
select_imageEdit = QLineEdit()
select_image_button=QPushButton("Browse")
select_image_button.clicked.connect(self.image_button_clicked)
def SecondPage(self):
pixmap = QPixmap(image_name)
smaller_pixmap = pixmap.scaled(220,220, Qt.KeepAspectRatio, Qt.FastTransformation)
labelImage.setPixmap(smaller_pixmap)
所以,我试图从第一页读取image_name
并在第二页中打印图像,但是什么也没显示。
在image_name
之前将global image_name
定义为image_name,_ = QFileDialog.getOpenFileName(None, "Select an image", "", "Image Files (*.png *.jpg *.bmp)")