popup progress dialog
-
Hello,
I would like to display a popup dialog that shows progress then closes when finished without interacting with the user.
Is this possible? Thank you. -
Hello,
I would like to display a popup dialog that shows progress then closes when finished without interacting with the user.
Is this possible? Thank you.@explorer100 yes, Qt provides QProgressDialog for this:
import sys from PyQt6.QtCore import QTimer from PyQt6.QtWidgets import QApplication, QProgressDialog app = QApplication(sys.argv) # Create the QProgressDialog progress_dialog = QProgressDialog("Operation in progress...", "Cancel", 0, 100) progress_dialog.setWindowTitle("Progress") progress_dialog.setWindowModality(True) progress_dialog.setMinimumDuration(0) progress_dialog.setAutoReset(True) progress_dialog.setAutoClose(True) # Simulated work process without using sleep progress_value = 0 def update_progress(): global progress_value progress_value += 1 # Update the progress bar progress_dialog.setValue(progress_value) # Check if the user clicked the Cancel button if progress_dialog.wasCanceled(): timer.stop() # Close dialog when it reaches 100 if progress_value >= 100: timer.stop() progress_dialog.close() # Set up a timer to simulate work being done timer = QTimer() timer.timeout.connect(update_progress) timer.start(50) # Calls the update_progress function every 50ms sys.exit(app.exec()) -
That worked great!! thank you very much.