Skip to content

Commit b658f7d

Browse files
committed
Add progress bar minimum duration (fix #68)
1 parent dc014c7 commit b658f7d

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

cdl/utils/qthelpers.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,19 @@ def try_or_log_error(context: str) -> Generator[None, None, None]:
182182

183183
@contextmanager
184184
def create_progress_bar(
185-
parent: QW.QWidget, label: str, max_: int
185+
parent: QW.QWidget, label: str, max_: int, show_after: int = 1000
186186
) -> Generator[QW.QProgressDialog, None, None]:
187-
"""Create modal progress bar"""
187+
"""Create modal progress bar
188+
189+
Args:
190+
parent: Parent widget
191+
label: Progress dialog title
192+
max_: Maximum progress value
193+
show_after: Delay before showing the progress dialog (ms, default: 1000)
194+
"""
188195
prog = QW.QProgressDialog(label, _("Cancel"), 0, max_, parent, QC.Qt.SplashScreen)
189196
prog.setWindowModality(QC.Qt.WindowModal)
190-
prog.show()
197+
prog.setMinimumDuration(show_after)
191198
try:
192199
yield prog
193200
finally:

0 commit comments

Comments
 (0)