Pls help on this code, cuz i don't really get the concept. I start a dialog by clicking a button on a qwidget. I also would like to display an image on the aforementiond qdialog by clicking on a different button (img_btn) on the dialog . I have added some code below:
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys
class BasicWidget(QWidget):
def __init__(self, parent=None):
super(BasicWidget, self).__init__()
layout = QVBoxLayout()
self.btn = QPushButton('Show Dialog')
layout.addWidget(self.btn)
self.setLayout(layout)
self.show()
self.btn.clicked.connect(self.showpic)
def showpic(self):
imgshow = PaintPicture()
class PaintPicture(QDialog):
def __init__(self, parent=None):
super(PaintPicture, self).__init__()
layout = QVBoxLayout()
self.img_btn = QPushButton('Enter')
layout.addWidget(self.img_btn)
filename = r'\\some\basic\picture.jpg'
image = QImage(filename )
self.imageLabel = QLabel()
self.imageLabel.setPixmap(QPixmap.fromImage(image))
layout.addWidget(self.imageLabel)
self.setLayout(layout)
self.show()
if __name__ =="__main__":
app = QApplication(sys.argv)
widget = BasicWidget()
sys.exit(app.exec_())