MCPcopy
hub / github.com/PySimpleGUI/PySimpleGUI / cprint

Function cprint

PySimpleGUI/PySimpleGUI.py:18548–18654  ·  view source on GitHub ↗

Color print to a multiline element in a window of your choice. Must have EITHER called cprint_set_output_destination prior to making this call so that the window and element key can be saved and used here to route the output, OR used the window and key parameters to the cprint funct

(*args, end=None, sep=' ', text_color=None, font=None, t=None, background_color=None, b=None, colors=None, c=None, window=None, key=None,
           justification=None, autoscroll=True, image=None, image_subsample=None, erase_all=False)

Source from the content-addressed store, hash-verified

18546
18547
18548def cprint(*args, end=None, sep=' ', text_color=None, font=None, t=None, background_color=None, b=None, colors=None, c=None, window=None, key=None,
18549 justification=None, autoscroll=True, image=None, image_subsample=None, erase_all=False):
18550 """
18551 Color print to a multiline element in a window of your choice.
18552 Must have EITHER called cprint_set_output_destination prior to making this call so that the
18553 window and element key can be saved and used here to route the output, OR used the window
18554 and key parameters to the cprint function to specicy these items.
18555
18556 args is a variable number of things you want to print.
18557
18558 end - The end char to use just like print uses
18559 sep - The separation character like print uses
18560 text_color - The color of the text
18561 key - overrides the previously defined Multiline key
18562 window - overrides the previously defined window to output to
18563 background_color - The color of the background
18564 colors -(str, str) or str. A combined text/background color definition in a single parameter
18565
18566 There are also "aliases" for text_color, background_color and colors (t, b, c)
18567 t - An alias for color of the text (makes for shorter calls)
18568 b - An alias for the background_color parameter
18569 c - (str, str) - "shorthand" way of specifying color. (foreground, backgrouned)
18570 c - str - can also be a string of the format "foreground on background" ("white on red")
18571
18572 With the aliases it's possible to write the same print but in more compact ways:
18573 cprint('This will print white text on red background', c=('white', 'red'))
18574 cprint('This will print white text on red background', c='white on red')
18575 cprint('This will print white text on red background', text_color='white', background_color='red')
18576 cprint('This will print white text on red background', t='white', b='red')
18577
18578 :param *args: stuff to output
18579 :type *args: (Any)
18580 :param text_color: Color of the text
18581 :type text_color: (str)
18582 :param font: specifies the font family, size, etc. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike for the value being updated
18583 :type font: (str or (str, int[, str]) or None)
18584 :param background_color: The background color of the line
18585 :type background_color: (str)
18586 :param colors: Either a tuple or a string that has both the text and background colors "text on background" or just the text color
18587 :type colors: (str) or (str, str)
18588 :param t: Color of the text
18589 :type t: (str)
18590 :param b: The background color of the line
18591 :type b: (str)
18592 :param c: Either a tuple or a string. Same as the color parm
18593 :type c: (str) or (str, str)
18594 :param end: end character
18595 :type end: (str)
18596 :param sep: separator character
18597 :type sep: (str)
18598 :param key: key of multiline to output to (if you want to override the one previously set)
18599 :type key: (Any)
18600 :param window: Window containing the multiline to output to (if you want to override the one previously set)
18601 :type window: (Window)
18602 :param justification: text justification. left, right, center. Can use single characters l, r, c. Sets only for this value, not entire element
18603 :type justification: (str)
18604 :param autoscroll: If True the contents of the element will automatically scroll as more data added to the end
18605 :type autoscroll: (bool)

Callers

nothing calls this directly

Calls 3

find_elementMethod · 0.80
updateMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected