Pop up window showing image
-
Hello, I have built an application with GUI on PyQt5. I need to display pop up window when press a button. This pop up window should show image. How can I achieve that? From a little google search I see that pop up windows show only text... Is there any other class suitable for what I want to achieve?
-
Hi,
Create a QDialog based class that will show the image. You can use a QLabel to show it.
-
At that part:
https://www.tutorialspoint.com/pyqt/pyqt_qdialog_class.htm
I connect the window() method to the pressed button of the central GUI right instead of calling it at the end, right?
-
Hello, I have built an application with GUI on PyQt5. I need to display pop up window when press a button. This pop up window should show image. How can I achieve that? From a little google search I see that pop up windows show only text... Is there any other class suitable for what I want to achieve?
@john_hobbyist Demo:
from PyQt5 import QtGui, QtWidgets def handle_clicked(): dialog = QtWidgets.QDialog() lay = QtWidgets.QVBoxLayout(dialog) label = QtWidgets.QLabel() lay.addWidget(label) pixmap = QtGui.QPixmap("/path/of/image") label.setPixmap(pixmap) dialog.exec_() def main(): app = QtWidgets.QApplication([]) w = QtWidgets.QPushButton("Press me") w.clicked.connect(handle_clicked) # w.resize(640, 480) w.show() app.exec_() if __name__ == "__main__": main()