diff --git a/DemoPrograms/Demo_Multiline_cprint_Printing.py b/DemoPrograms/Demo_Multiline_cprint_Printing.py index 5cbbd0e0..aac861de 100644 --- a/DemoPrograms/Demo_Multiline_cprint_Printing.py +++ b/DemoPrograms/Demo_Multiline_cprint_Printing.py @@ -21,30 +21,45 @@ import PySimpleGUI as sg def main(): MLINE_KEY = '-ML-'+sg.WRITE_ONLY_KEY # multiline element's key. Indicate it's an output only element + MLINE_KEY2 = '-ML2-'+sg.WRITE_ONLY_KEY # multiline element's key. Indicate it's an output only element + MLINE_KEY3 = '-ML3-'+sg.WRITE_ONLY_KEY # multiline element's key. Indicate it's an output only element + + output_key = MLINE_KEY + layout = [ [sg.Text('Multiline Color Print Demo', font='Any 18')], - [sg.Multiline(size=(80,20), key=MLINE_KEY)], + [sg.Multiline('Multiline\n', size=(80,20), key=MLINE_KEY)], + [sg.Multiline('Multiline2\n', size=(80,20), key=MLINE_KEY2)], [sg.Text('Text color:'), sg.Combo(list(color_map.keys()), size=(12,20), key='-TEXT COLOR-'), - sg.Text('Background color:'), sg.Combo(list(color_map.keys()), size=(12,20), key='-BG COLOR-')], + sg.Text('on Background color:'), sg.Combo(list(color_map.keys()), size=(12,20), key='-BG COLOR-')], [sg.Input('Type text to output here', size=(80,1), key='-IN-')], [sg.Button('Print', bind_return_key=True), sg.Button('Print short'), - sg.Button('Use Input for colors'), sg.Button('Exit')] ] + sg.Button('Force 1'), sg.Button('Force 2'), + sg.Button('Use Input for colors'), sg.Button('Toggle Output Location'), sg.Button('Exit')] ] window = sg.Window('Window Title', layout) - sg.cprint_set_output_destination(window, MLINE_KEY) + sg.cprint_set_output_destination(window, output_key) while True: # Event Loop event, values = window.read() if event == sg.WIN_CLOSED or event == 'Exit': break - sg.cprint(event, values, colors='white on red') if event == 'Print': sg.cprint(values['-IN-'], text_color=values['-TEXT COLOR-'], background_color=values['-BG COLOR-']) elif event == 'Print short': sg.cprint(values['-IN-'], c=(values['-TEXT COLOR-'], values['-BG COLOR-'])) elif event.startswith('Use Input'): sg.cprint(values['-IN-'], colors=values['-IN-']) + elif event.startswith('Toggle'): + output_key = MLINE_KEY if output_key == MLINE_KEY2 else MLINE_KEY2 + sg.cprint_set_output_destination(window, output_key) + sg.cprint('Switched to this output element', c='white on red') + elif event == 'Force 1': + sg.cprint(values['-IN-'], c=(values['-TEXT COLOR-'], values['-BG COLOR-']), key=MLINE_KEY) + elif event == 'Force 2': + sg.cprint(values['-IN-'], c=(values['-TEXT COLOR-'], values['-BG COLOR-']), key=MLINE_KEY2) + window.close() diff --git a/PySimpleGUI.py b/PySimpleGUI.py index 312e8152..20f92275 100644 --- a/PySimpleGUI.py +++ b/PySimpleGUI.py @@ -1,6 +1,6 @@ #!/usr/bin/python3 -version = __version__ = "4.21.0.1 Unreleased\n cprint expanded using optional key and optional window" +version = __version__ = "4.22.0 Released 28-Jun-2020" port = 'PySimpleGUI' @@ -11609,7 +11609,7 @@ class QuickMeter(object): :param orientation: 'horizontal' or 'vertical' ('h' or 'v' work) (Default value = 'vertical' / 'v') :type orientation: (str) :param bar_color: color of a bar line - :type bar_color: str + :type bar_color: Tuple[str, str] :param button_color: button color (foreground, background) :type button_color: Tuple[str, str] :param size: (w,h) w=characters-wide, h=rows-high (Default value = DEFAULT_PROGRESS_BAR_SIZE) @@ -11964,22 +11964,32 @@ def cprint_set_output_destination(window, multiline_key): def cprint(*args, **kwargs): """ Color print to a multiline element in a window of your choice. - Must have called cprint_set_output_destination prior ot making this call so that the - window and element key can be saved and used here to route the output + 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 function to specicy these items. + + args is a variable number of things you want to print. + kwargs can be any of these keywords: end - The end char to use just like print uses sep - The separation character like print uses text_color - The color of the text - t - An alias for color of the text (makes for shorter calls) + key - overrides the previously defined Multiline key + window - overrides the previously defined window to output to background_color - The color of the background + colors -(str, str) or str. A combined text/background color definition in a single parameter + + There are also "aliases" for text_color, background_color and colors (t, b, c) + t - An alias for color of the text (makes for shorter calls) b - An alias for the background_color parameter c - Tuple[str, str] - "shorthand" way of specifying color. (foreground, backgrouned) str - can also be a string of the format "foreground on background" ("white on red") - With these aliases it's possible to write the same print but in more compact ways: + + With the aliases it's possible to write the same print but in more compact ways: cprint('This will print white text on red background', c=('white', 'red')) cprint('This will print white text on red background', c='white on red') - cprint('This will print white text on red background', text_color='red', background_color='white') - cprint('This will print white text on red background', t='red', b='white') + cprint('This will print white text on red background', text_color='white', background_color='red') + cprint('This will print white text on red background', t='white', b='red') :param *args: stuff to output :type *args: (Any) @@ -12001,21 +12011,19 @@ def cprint(*args, **kwargs): :type sep: (str) :param key: key of multiline to output to (if you want to override the one previously set) :type key: (Any) - :param window: key of multiline to output to (if you want to override the one previously set) + :param window: Window containing the multiline to output to (if you want to override the one previously set) :type window: (Window) """ - destination_key = CPRINT_DESTINATION_MULTILINE_ELMENT_KEY window = CPRINT_DESTINATION_WINDOW - if window is None or destination_key is None: - if 'key' not in kwargs and 'window' not in kwargs: - print('** Warning ** Attempting to perform a cprint without first setting up the output window and element', - 'Will instead print on Console', - 'You can also use the window, key arguments to route the output') - print(*args) - return + if (window is None and 'window' not in kwargs) or (destination_key is None and 'key' not in kwargs): + print('** Warning ** Attempting to perform a cprint without a valid window & key', + 'Will instead print on Console', + 'You can specify window and key in this cprint call, or set ahead of time using cprint_set_output_destination') + print(*args) + return diff --git a/docs/call reference.md b/docs/call reference.md index f6fc65cd..e7e433fc 100644 --- a/docs/call reference.md +++ b/docs/call reference.md @@ -170,7 +170,7 @@ Parameter Descriptions: |Type|Name|Meaning| |--|--|--| -| Mike_please_insert_type_here | bind_string | The string tkinter expected in its bind function | +| str | bind_string | The string tkinter expected in its bind function | ### click @@ -307,6 +307,12 @@ Removes a previously bound tkinter event from an Element. unbind(bind_string) ``` +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| str | bind_string | The string tkinter expected in its bind function | + ### unhide_row Unhides (makes visible again) the row container that the Element is located on. @@ -459,7 +465,7 @@ Parameter Descriptions: |Type|Name|Meaning| |--|--|--| -| Mike_please_insert_type_here | bind_string | The string tkinter expected in its bind function | +| str | bind_string | The string tkinter expected in its bind function | ### expand @@ -563,6 +569,12 @@ Removes a previously bound tkinter event from an Element. unbind(bind_string) ``` +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| str | bind_string | The string tkinter expected in its bind function | + ### set_vscroll_position Attempts to set the vertical scroll postition for an element's Widget @@ -680,7 +692,7 @@ Parameter Descriptions: |Type|Name|Meaning| |--|--|--| -| Mike_please_insert_type_here | bind_string | The string tkinter expected in its bind function | +| str | bind_string | The string tkinter expected in its bind function | ### expand @@ -794,6 +806,12 @@ Removes a previously bound tkinter event from an Element. unbind(bind_string) ``` +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| str | bind_string | The string tkinter expected in its bind function | + ### unhide_row Unhides (makes visible again) the row container that the Element is located on. @@ -921,7 +939,7 @@ Parameter Descriptions: |Type|Name|Meaning| |--|--|--| -| Mike_please_insert_type_here | bind_string | The string tkinter expected in its bind function | +| str | bind_string | The string tkinter expected in its bind function | ### expand @@ -1035,6 +1053,12 @@ Removes a previously bound tkinter event from an Element. unbind(bind_string) ``` +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| str | bind_string | The string tkinter expected in its bind function | + ### unhide_row Unhides (makes visible again) the row container that the Element is located on. @@ -1203,7 +1227,7 @@ Parameter Descriptions: |Type|Name|Meaning| |--|--|--| -| Mike_please_insert_type_here | bind_string | The string tkinter expected in its bind function | +| str | bind_string | The string tkinter expected in its bind function | ### expand @@ -1322,6 +1346,12 @@ Removes a previously bound tkinter event from an Element. unbind(bind_string) ``` +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| str | bind_string | The string tkinter expected in its bind function | + ### set_vscroll_position Attempts to set the vertical scroll postition for an element's Widget @@ -1481,7 +1511,7 @@ Parameter Descriptions: |Type|Name|Meaning| |--|--|--| -| Mike_please_insert_type_here | bind_string | The string tkinter expected in its bind function | +| str | bind_string | The string tkinter expected in its bind function | ### expand @@ -1596,6 +1626,12 @@ Removes a previously bound tkinter event from an Element. unbind(bind_string) ``` +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| str | bind_string | The string tkinter expected in its bind function | + ### unhide_row Unhides (makes visible again) the row container that the Element is located on. @@ -1774,7 +1810,7 @@ Parameter Descriptions: |Type|Name|Meaning| |--|--|--| -| Mike_please_insert_type_here | bind_string | The string tkinter expected in its bind function | +| str | bind_string | The string tkinter expected in its bind function | ### expand @@ -1893,6 +1929,12 @@ Removes a previously bound tkinter event from an Element. unbind(bind_string) ``` +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| str | bind_string | The string tkinter expected in its bind function | + ### unhide_row Unhides (makes visible again) the row container that the Element is located on. @@ -2369,7 +2411,7 @@ Parameter Descriptions: |Type|Name|Meaning| |--|--|--| -| Mike_please_insert_type_here | bind_string | The string tkinter expected in its bind function | +| str | bind_string | The string tkinter expected in its bind function | ### bring_figure_to_front @@ -2837,6 +2879,12 @@ Removes a previously bound tkinter event from an Element. unbind(bind_string) ``` +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| str | bind_string | The string tkinter expected in its bind function | + ### unhide_row Unhides (makes visible again) the row container that the Element is located on. @@ -2918,7 +2966,7 @@ Parameter Descriptions: |Type|Name|Meaning| |--|--|--| -| Mike_please_insert_type_here | bind_string | The string tkinter expected in its bind function | +| str | bind_string | The string tkinter expected in its bind function | ### expand @@ -3022,6 +3070,12 @@ Removes a previously bound tkinter event from an Element. unbind(bind_string) ``` +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| str | bind_string | The string tkinter expected in its bind function | + ### unhide_row Unhides (makes visible again) the row container that the Element is located on. @@ -3142,7 +3196,7 @@ Parameter Descriptions: |Type|Name|Meaning| |--|--|--| -| Mike_please_insert_type_here | bind_string | The string tkinter expected in its bind function | +| str | bind_string | The string tkinter expected in its bind function | ### expand @@ -3246,6 +3300,12 @@ Removes a previously bound tkinter event from an Element. unbind(bind_string) ``` +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| str | bind_string | The string tkinter expected in its bind function | + ### unhide_row Unhides (makes visible again) the row container that the Element is located on. @@ -3442,7 +3502,7 @@ Parameter Descriptions: |Type|Name|Meaning| |--|--|--| -| Mike_please_insert_type_here | bind_string | The string tkinter expected in its bind function | +| str | bind_string | The string tkinter expected in its bind function | ### expand @@ -3556,6 +3616,12 @@ Removes a previously bound tkinter event from an Element. unbind(bind_string) ``` +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| str | bind_string | The string tkinter expected in its bind function | + ### unhide_row Unhides (makes visible again) the row container that the Element is located on. @@ -3741,7 +3807,7 @@ Parameter Descriptions: |Type|Name|Meaning| |--|--|--| -| Mike_please_insert_type_here | bind_string | The string tkinter expected in its bind function | +| str | bind_string | The string tkinter expected in its bind function | ### expand @@ -3904,6 +3970,12 @@ Removes a previously bound tkinter event from an Element. unbind(bind_string) ``` +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| str | bind_string | The string tkinter expected in its bind function | + ### unhide_row Unhides (makes visible again) the row container that the Element is located on. @@ -4035,7 +4107,7 @@ Parameter Descriptions: |Type|Name|Meaning| |--|--|--| -| Mike_please_insert_type_here | bind_string | The string tkinter expected in its bind function | +| str | bind_string | The string tkinter expected in its bind function | ### expand @@ -4139,6 +4211,12 @@ Removes a previously bound tkinter event from an Element. unbind(bind_string) ``` +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| str | bind_string | The string tkinter expected in its bind function | + ### unhide_row Unhides (makes visible again) the row container that the Element is located on. @@ -4298,7 +4376,7 @@ Parameter Descriptions: |Type|Name|Meaning| |--|--|--| -| Mike_please_insert_type_here | bind_string | The string tkinter expected in its bind function | +| str | bind_string | The string tkinter expected in its bind function | ### expand @@ -4449,6 +4527,12 @@ Removes a previously bound tkinter event from an Element. unbind(bind_string) ``` +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| str | bind_string | The string tkinter expected in its bind function | + ### unhide_row Unhides (makes visible again) the row container that the Element is located on. @@ -4588,7 +4672,7 @@ Parameter Descriptions: |Type|Name|Meaning| |--|--|--| -| Mike_please_insert_type_here | bind_string | The string tkinter expected in its bind function | +| str | bind_string | The string tkinter expected in its bind function | ### expand @@ -4706,6 +4790,12 @@ Removes a previously bound tkinter event from an Element. unbind(bind_string) ``` +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| str | bind_string | The string tkinter expected in its bind function | + ### unhide_row Unhides (makes visible again) the row container that the Element is located on. @@ -4843,7 +4933,7 @@ Parameter Descriptions: |Type|Name|Meaning| |--|--|--| -| Mike_please_insert_type_here | bind_string | The string tkinter expected in its bind function | +| str | bind_string | The string tkinter expected in its bind function | ### expand @@ -4970,6 +5060,12 @@ Removes a previously bound tkinter event from an Element. unbind(bind_string) ``` +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| str | bind_string | The string tkinter expected in its bind function | + ### unhide_row Unhides (makes visible again) the row container that the Element is located on. @@ -5085,7 +5181,7 @@ Parameter Descriptions: |Type|Name|Meaning| |--|--|--| -| Mike_please_insert_type_here | bind_string | The string tkinter expected in its bind function | +| str | bind_string | The string tkinter expected in its bind function | ### expand @@ -5189,6 +5285,12 @@ Removes a previously bound tkinter event from an Element. unbind(bind_string) ``` +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| str | bind_string | The string tkinter expected in its bind function | + ### unhide_row Unhides (makes visible again) the row container that the Element is located on. @@ -5318,7 +5420,7 @@ Parameter Descriptions: |Type|Name|Meaning| |--|--|--| -| Mike_please_insert_type_here | bind_string | The string tkinter expected in its bind function | +| str | bind_string | The string tkinter expected in its bind function | ### expand @@ -5422,6 +5524,12 @@ Removes a previously bound tkinter event from an Element. unbind(bind_string) ``` +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| str | bind_string | The string tkinter expected in its bind function | + ### unhide_row Unhides (makes visible again) the row container that the Element is located on. @@ -5582,7 +5690,7 @@ Parameter Descriptions: |Type|Name|Meaning| |--|--|--| -| Mike_please_insert_type_here | bind_string | The string tkinter expected in its bind function | +| str | bind_string | The string tkinter expected in its bind function | ### expand @@ -5704,6 +5812,12 @@ Removes a previously bound tkinter event from an Element. unbind(bind_string) ``` +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| str | bind_string | The string tkinter expected in its bind function | + ### unhide_row Unhides (makes visible again) the row container that the Element is located on. @@ -5844,7 +5958,7 @@ Parameter Descriptions: |Type|Name|Meaning| |--|--|--| -| Mike_please_insert_type_here | bind_string | The string tkinter expected in its bind function | +| str | bind_string | The string tkinter expected in its bind function | ### expand @@ -5948,6 +6062,12 @@ Removes a previously bound tkinter event from an Element. unbind(bind_string) ``` +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| str | bind_string | The string tkinter expected in its bind function | + ### unhide_row Unhides (makes visible again) the row container that the Element is located on. @@ -6092,7 +6212,7 @@ Parameter Descriptions: |Type|Name|Meaning| |--|--|--| -| Mike_please_insert_type_here | bind_string | The string tkinter expected in its bind function | +| str | bind_string | The string tkinter expected in its bind function | ### expand @@ -6208,6 +6328,12 @@ Removes a previously bound tkinter event from an Element. unbind(bind_string) ``` +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| str | bind_string | The string tkinter expected in its bind function | + ### unhide_row Unhides (makes visible again) the row container that the Element is located on. @@ -6342,7 +6468,7 @@ Parameter Descriptions: |Type|Name|Meaning| |--|--|--| -| Mike_please_insert_type_here | bind_string | The string tkinter expected in its bind function | +| str | bind_string | The string tkinter expected in its bind function | ### expand @@ -6446,6 +6572,12 @@ Removes a previously bound tkinter event from an Element. unbind(bind_string) ``` +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| str | bind_string | The string tkinter expected in its bind function | + ### unhide_row Unhides (makes visible again) the row container that the Element is located on. @@ -6843,7 +6975,7 @@ Parameter Descriptions: |Type|Name|Meaning| |--|--|--| -| Mike_please_insert_type_here | bind_string | The string tkinter expected in its bind function | +| str | bind_string | The string tkinter expected in its bind function | ### expand @@ -6969,6 +7101,12 @@ Removes a previously bound tkinter event from an Element. unbind(bind_string) ``` +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| str | bind_string | The string tkinter expected in its bind function | + ### unhide_row Unhides (makes visible again) the row container that the Element is located on. @@ -7111,7 +7249,7 @@ Parameter Descriptions: |Type|Name|Meaning| |--|--|--| -| Mike_please_insert_type_here | bind_string | The string tkinter expected in its bind function | +| str | bind_string | The string tkinter expected in its bind function | ### expand @@ -7257,6 +7395,12 @@ Removes a previously bound tkinter event from an Element. unbind(bind_string) ``` +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| str | bind_string | The string tkinter expected in its bind function | + ### unhide_row Unhides (makes visible again) the row container that the Element is located on. @@ -7417,7 +7561,7 @@ Parameter Descriptions: |Type|Name|Meaning| |--|--|--| -| Mike_please_insert_type_here | bind_string | The string tkinter expected in its bind function | +| str | bind_string | The string tkinter expected in its bind function | ### expand @@ -7533,6 +7677,12 @@ Removes a previously bound tkinter event from an Element. unbind(bind_string) ``` +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| str | bind_string | The string tkinter expected in its bind function | + ### unhide_row Unhides (makes visible again) the row container that the Element is located on. @@ -7685,7 +7835,7 @@ Parameter Descriptions: |Type|Name|Meaning| |--|--|--| -| Mike_please_insert_type_here | bind_string | The string tkinter expected in its bind function | +| str | bind_string | The string tkinter expected in its bind function | ### expand @@ -7799,6 +7949,12 @@ Removes a previously bound tkinter event from an Element. unbind(bind_string) ``` +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| str | bind_string | The string tkinter expected in its bind function | + ### unhide_row Unhides (makes visible again) the row container that the Element is located on. @@ -7976,7 +8132,7 @@ Parameter Descriptions: |Type|Name|Meaning| |--|--|--| -| Mike_please_insert_type_here | bind_string | The string tkinter expected in its bind function | +| str | bind_string | The string tkinter expected in its bind function | ### expand @@ -8094,6 +8250,12 @@ Removes a previously bound tkinter event from an Element. unbind(bind_string) ``` +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| str | bind_string | The string tkinter expected in its bind function | + ### unhide_row Unhides (makes visible again) the row container that the Element is located on. @@ -8255,7 +8417,7 @@ Parameter Descriptions: |Type|Name|Meaning| |--|--|--| -| Mike_please_insert_type_here | bind_string | The string tkinter expected in its bind function | +| str | bind_string | The string tkinter expected in its bind function | ### expand @@ -8359,6 +8521,12 @@ Removes a previously bound tkinter event from an Element. unbind(bind_string) ``` +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| str | bind_string | The string tkinter expected in its bind function | + ### unhide_row Unhides (makes visible again) the row container that the Element is located on. @@ -11754,6 +11922,7 @@ Parameter Descriptions: | bool | keep_on_top | If True the window will remain above all current windows | | Tuple[int, int] | location | Location of upper left corner of the window | | bool | do_not_reroute_stdout | do not reroute stdout | +| | **RETURN** | Close a previously opened EasyPrint window @@ -11797,6 +11966,7 @@ Parameter Descriptions: | bool | keep_on_top | If True the window will remain above all current windows | | Tuple[int, int] | location | Location of upper left corner of the window | | bool | do_not_reroute_stdout | do not reroute stdout | +| | **RETURN** | Works like a "print" statement but with windowing options. Routes output to the "Debug Window" @@ -11834,6 +12004,7 @@ Parameter Descriptions: | bool | keep_on_top | If True the window will remain above all current windows | | Tuple[int, int] | location | Location of upper left corner of the window | | bool | do_not_reroute_stdout | do not reroute stdout | +| | **RETURN** | Close a previously opened EasyPrint window @@ -11877,6 +12048,7 @@ Parameter Descriptions: | bool | keep_on_top | If True the window will remain above all current windows | | Tuple[int, int] | location | Location of upper left corner of the window | | bool | do_not_reroute_stdout | do not reroute stdout | +| | **RETURN** | Close a previously opened EasyPrint window @@ -11920,6 +12092,7 @@ Parameter Descriptions: | bool | keep_on_top | If True the window will remain above all current windows | | Tuple[int, int] | location | Location of upper left corner of the window | | bool | do_not_reroute_stdout | do not reroute stdout | +| | **RETURN** | Close a previously opened EasyPrint window @@ -11930,22 +12103,32 @@ PrintClose() ## Color Printing to Multiline Element of a Window Color print to a multiline element in a window of your choice. -Must have called cprint_set_output_destination prior ot making this call so that the -window and element key can be saved and used here to route the output +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 function to specicy these items. + +args is a variable number of things you want to print. + kwargs can be any of these keywords: end - The end char to use just like print uses sep - The separation character like print uses text_color - The color of the text -t - An alias for color of the text (makes for shorter calls) +key - overrides the previously defined Multiline key +window - overrides the previously defined window to output to background_color - The color of the background +colors -(str, str) or str. A combined text/background color definition in a single parameter + +There are also "aliases" for text_color, background_color and colors (t, b, c) +t - An alias for color of the text (makes for shorter calls) b - An alias for the background_color parameter c - Tuple[str, str] - "shorthand" way of specifying color. (foreground, backgrouned) str - can also be a string of the format "foreground on background" ("white on red") -With these aliases it's possible to write the same print but in more compact ways: + +With the aliases it's possible to write the same print but in more compact ways: cprint('This will print white text on red background', c=('white', 'red')) cprint('This will print white text on red background', c='white on red') -cprint('This will print white text on red background', text_color='red', background_color='white') -cprint('This will print white text on red background', t='red', b='white') +cprint('This will print white text on red background', text_color='white', background_color='red') +cprint('This will print white text on red background', t='white', b='red') ``` cprint(args=*<1 or N object>, kwargs) @@ -11958,13 +12141,14 @@ Parameter Descriptions: | Any | *args | stuff to output | | str | text_color | Color of the text | | str | background_color | The background color of the line | +| str) or Tuple[str, str] | colors | Either a tuple or a string that has both the text and background colors | | str | t | Color of the text | | str | b | The background color of the line | -| str | b | The background color of the line | | str) or Tuple[str, str] | c | Either a tuple or a string that has both the text and background colors | | str | end | end character | | str | sep | separator character | -| | **RETURN** | +| Any | key | key of multiline to output to (if you want to override the one previously set) | +| Window | window | Window containing the multiline to output to (if you want to override the one previously set) | Sets up the color print (cprint) output destination @@ -14327,6 +14511,12 @@ Shows the large main debugger window show_debugger_window(location=(None, None), args=*<1 or N object>) ``` +Parameter Descriptions: + +|Type|Name|Meaning| +|--|--|--| +| Tuple[int, int] | location | Locations (x,y) on the screen to place upper left corner of the window | + ## Themes Sets / Gets the current Theme. If none is specified then returns the current theme. diff --git a/docs/index.md b/docs/index.md index ce7727c8..8aa69cf5 100644 --- a/docs/index.md +++ b/docs/index.md @@ -7264,6 +7264,15 @@ Horizontal Separator, cprint, docstrings * Added default_path to popup_get_file when there is no window * Fix for removing too many PySimpleGUI installs when using the GitHub upgrade tooltip +## 4.22.0 PySimpleGUI 28-Jun-2020 + +More cprint stuff + +* Additional window and key parameter to cprint + * May seem like a small change, but the results are powerful + * Can now easily "print" to anywhere, in color! + + ### Upcoming There will always be overlapping work as the ports will never actually be "complete" as there's always something new that can be built. However there's a definition for the base functionality for PySimpleGUI. This is what is being strived for with the current ports that are underway. diff --git a/readme.md b/readme.md index ce7727c8..8aa69cf5 100644 --- a/readme.md +++ b/readme.md @@ -7264,6 +7264,15 @@ Horizontal Separator, cprint, docstrings * Added default_path to popup_get_file when there is no window * Fix for removing too many PySimpleGUI installs when using the GitHub upgrade tooltip +## 4.22.0 PySimpleGUI 28-Jun-2020 + +More cprint stuff + +* Additional window and key parameter to cprint + * May seem like a small change, but the results are powerful + * Can now easily "print" to anywhere, in color! + + ### Upcoming There will always be overlapping work as the ports will never actually be "complete" as there's always something new that can be built. However there's a definition for the base functionality for PySimpleGUI. This is what is being strived for with the current ports that are underway.