@@ -149,18 +149,25 @@ def progress(
149149 ) -> ProgressDialog :
150150 """Create and return a ProgressDialog from Core.dialogs.
151151
152- Uses Core.dialogs.ProgressDialog to ensure:
153- - Theme inheritance from the application
154- - Visual integration with the main application
155- - Thread safety
156-
157- Args:
158- title: Dialog title
159- text: Initial dialog text
160- maximum: Maximum value (0 = indeterminate)
161- cancelable: If True, show a Cancel button
162-
163- Returns:
164- ProgressDialog instance from Core.dialogs
152+ Uses Core.dialogs.ProgressDialog when GUI is available,
153+ otherwise returns a console-based fallback.
165154 """
155+ from PySide6 .QtWidgets import QApplication
156+ if QApplication .instance () is None :
157+ # Fallback for headless/sandbox mode
158+ class ConsoleProgress :
159+ def __init__ (self , title ):
160+ self .title = title
161+ self ._canceled = False
162+ def show (self ): print (f"[PROGRESS:START] { self .title } " )
163+ def set_message (self , msg ): print (f"[PROGRESS:MSG] { msg } " )
164+ def set_status (self , msg ): print (f"[PROGRESS:STATUS] { msg } " )
165+ def set_progress (self , val , total = None ):
166+ if total : print (f"[PROGRESS:VALUE] { val } /{ total } " )
167+ else : print (f"[PROGRESS:VALUE] { val } %" )
168+ def close (self ): print (f"[PROGRESS:END] { self .title } " )
169+ def is_canceled (self ): return False
170+
171+ return ConsoleProgress (title ) # type: ignore
172+
166173 return ProgressDialog (title = title , cancelable = cancelable )
0 commit comments