MCPcopy Index your code
hub / github.com/PySimpleGUI/PySimpleGUI / shell_with_animation

Function shell_with_animation

PySimpleGUI/PySimpleGUI.py:22205–22267  ·  view source on GitHub ↗

Execute a "shell command" (anything capable of being launched using subprocess.run) and while the command is running, show an animated popup so that the user knows that a long-running command is being executed. Without this mechanism, the GUI appears locked up. :param command:

(command, args=None, image_source=DEFAULT_BASE64_LOADING_GIF, message=None, background_color=None, text_color=None, font=None,
                         no_titlebar=True, grab_anywhere=True, keep_on_top=True, location=(None, None), alpha_channel=None, time_between_frames=100,
                         transparent_color=None)

Source from the content-addressed store, hash-verified

22203
22204
22205def shell_with_animation(command, args=None, image_source=DEFAULT_BASE64_LOADING_GIF, message=None, background_color=None, text_color=None, font=None,
22206 no_titlebar=True, grab_anywhere=True, keep_on_top=True, location=(None, None), alpha_channel=None, time_between_frames=100,
22207 transparent_color=None):
22208 """
22209 Execute a "shell command" (anything capable of being launched using subprocess.run) and
22210 while the command is running, show an animated popup so that the user knows that a long-running
22211 command is being executed. Without this mechanism, the GUI appears locked up.
22212
22213 :param command: The command to run
22214 :type command: (str)
22215 :param args: List of arguments
22216 :type args: List[str]
22217 :param image_source: Either a filename or a base64 string.
22218 :type image_source: str | bytes
22219 :param message: An optional message to be shown with the animation
22220 :type message: (str)
22221 :param background_color: color of background
22222 :type background_color: (str)
22223 :param text_color: color of the text
22224 :type text_color: (str)
22225 :param font: specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
22226 :type font: str | tuple
22227 :param no_titlebar: If True then the titlebar and window frame will not be shown
22228 :type no_titlebar: (bool)
22229 :param grab_anywhere: If True then you can move the window just clicking anywhere on window, hold and drag
22230 :type grab_anywhere: (bool)
22231 :param keep_on_top: If True then Window will remain on top of all other windows currently shownn
22232 :type keep_on_top: (bool)
22233 :param location: (x,y) location on the screen to place the top left corner of your window. Default is to center on screen
22234 :type location: (int, int)
22235 :param alpha_channel: Window transparency 0 = invisible 1 = completely visible. Values between are see through
22236 :type alpha_channel: (float)
22237 :param time_between_frames: Amount of time in milliseconds between each frame
22238 :type time_between_frames: (int)
22239 :param transparent_color: This color will be completely see-through in your window. Can even click through
22240 :type transparent_color: (str)
22241 :return: The resulting string output from stdout
22242 :rtype: (str)
22243 """
22244
22245 global __shell_process__
22246
22247 real_args = [command]
22248 if args is not None:
22249 for arg in args:
22250 real_args.append(arg)
22251 # real_args.append(args)
22252 thread = threading.Thread(target=_process_thread, args=real_args, daemon=True)
22253 thread.start()
22254
22255 # Poll to see if the thread is still running. If so, then continue showing the animation
22256 while True:
22257 popup_animated(image_source=image_source, message=message, time_between_frames=time_between_frames, transparent_color=transparent_color,
22258 text_color=text_color, background_color=background_color, font=font, no_titlebar=no_titlebar, grab_anywhere=grab_anywhere,
22259 keep_on_top=keep_on_top, location=location, alpha_channel=alpha_channel)
22260 thread.join(timeout=time_between_frames / 1000)
22261 if not thread.is_alive():
22262 break

Callers

nothing calls this directly

Calls 3

popup_animatedFunction · 0.85
startMethod · 0.80
__str__Method · 0.80

Tested by

no test coverage detected