MCPcopy
hub / github.com/PySimpleGUI/PySimpleGUI / Print

Method Print

PySimpleGUI/PySimpleGUI.py:18343–18422  ·  view source on GitHub ↗
(self, *args, end=None, sep=None, text_color=None, background_color=None, erase_all=False, font=None, blocking=None)

Source from the content-addressed store, hash-verified

18341 do_not_reroute_stdout=self.do_not_reroute_stdout, resizable=self.resizable, echo_stdout=self.echo_stdout)
18342
18343 def Print(self, *args, end=None, sep=None, text_color=None, background_color=None, erase_all=False, font=None, blocking=None):
18344 global SUPPRESS_WIDGET_NOT_FINALIZED_WARNINGS
18345 suppress = SUPPRESS_WIDGET_NOT_FINALIZED_WARNINGS
18346 SUPPRESS_WIDGET_NOT_FINALIZED_WARNINGS = True
18347 sepchar = sep if sep is not None else ' '
18348 endchar = end if end is not None else '\n'
18349 self.reopen_window() # if needed, open the window again
18350
18351 timeout = 0 if not blocking else None
18352 if erase_all:
18353 self.output_element.update('')
18354
18355 if self.do_not_reroute_stdout:
18356 end_str = str(end) if end is not None else '\n'
18357 sep_str = str(sep) if sep is not None else ' '
18358
18359 outstring = ''
18360 num_args = len(args)
18361 for i, arg in enumerate(args):
18362 outstring += str(arg)
18363 if i != num_args - 1:
18364 outstring += sep_str
18365 outstring += end_str
18366 try:
18367 self.output_element.update(outstring, append=True, text_color_for_value=text_color, background_color_for_value=background_color, font_for_value=font)
18368 except:
18369 self.window = None
18370 self.reopen_window()
18371 self.output_element.update(outstring, append=True, text_color_for_value=text_color, background_color_for_value=background_color, font_for_value=font)
18372
18373 else:
18374 print(*args, sep=sepchar, end=endchar)
18375 # This is tricky....changing the button type depending on the blocking parm. If blocking, then the "Quit" button should become a normal button
18376 if blocking and not self.no_button:
18377 self.quit_button.BType = BUTTON_TYPE_READ_FORM
18378 try: # The window may be closed by user at any time, so have to protect
18379 self.quit_button.update(text='Click to continue...')
18380 except:
18381 self.window = None
18382 elif not self.no_button:
18383 self.quit_button.BType = BUTTON_TYPE_CLOSES_WIN_ONLY
18384 try: # The window may be closed by user at any time, so have to protect
18385 self.quit_button.update(text='Quit')
18386 except:
18387 self.window = None
18388
18389 try: # The window may be closed by user at any time, so have to protect
18390 if blocking and not self.no_button:
18391 self.window['-PAUSE-'].update(visible=False)
18392 elif not self.no_button:
18393 self.window['-PAUSE-'].update(visible=True)
18394 except:
18395 self.window = None
18396
18397 self.reopen_window() # if needed, open the window again
18398
18399 paused = None
18400 while True:

Callers 9

mini_launcherFunction · 0.80
execute_command_blockingFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
update_weatherMethod · 0.80
easy_printFunction · 0.80

Calls 4

reopen_windowMethod · 0.95
CloseMethod · 0.95
updateMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected