Dialogs question Accept/Cancel

Heads up! You've already completed this tutorial.

Claudiu_Garba | 2020-05-07 16:26:42 UTC | #1

Hi there, when I press either the accept or cancel, the app closed. How could I prevent this?

https://www.pythonguis.com/courses/start/dialogs/


nickDunder | 2020-10-07 20:01:44 UTC | #2

This is probably because you are simply running the widget. Once the response is returned, the serial process continues until the termination of your script. If you do not have .show() statement or further functionality in your UI, then you would have the ability to do is open, interact with, and close your dialog.

I recommend including the following script in your code to keep the main window open at runtime.

if name == 'main': app = QApplication(sys.argv) mw = MainWindow() mw.show() sys.exit(app.exec())

PyQt/PySide 1:1 Coaching with Martin Fitzpatrick — Save yourself time and frustration. Get one on one help with your Python GUI projects. Working together with you I'll identify issues and suggest fixes, from bugs and usability to architecture and maintainability.

Book Now 60 mins ($195)

Of course, you will need to import sys in order to make this whole thing work.

Packaging Python Applications with PyInstaller by Martin Fitzpatrick — This step-by-step guide walks you through packaging your own Python applications from simple examples to complete installers and signed executables.

More info Get the book


Over 15,000 developers have bought Create GUI Applications with Python & Qt!
Create GUI Applications with Python & Qt6
Take a look

Downloadable ebook (PDF, ePub) & Complete Source code

Also available from Leanpub and Amazon Paperback

[[ discount.discount_pc ]]% OFF for the next [[ discount.duration ]] [[discount.description ]] with the code [[ discount.coupon_code ]]

Purchasing Power Parity

Developers in [[ country ]] get [[ discount.discount_pc ]]% OFF on all books & courses with code [[ discount.coupon_code ]]
Well done, you've finished this tutorial! Mark As Complete
[[ user.completed.length ]] completed [[ user.streak+1 ]] day streak
Martin Fitzpatrick

Dialogs question Accept/Cancel was written by Martin Fitzpatrick .

Martin Fitzpatrick has been developing Python/Qt apps for 8 years. Building desktop applications to make data-analysis tools more user-friendly, Python was the obvious choice. Starting with Tk, later moving to wxWidgets and finally adopting PyQt. Martin founded PythonGUIs to provide easy to follow GUI programming tutorials to the Python community. He has written a number of popular Python books on the subject.