Print like Python normally prints except route the output to a multiline element and also add colors if desired :param multiline_element: The multiline element to be output to :type multiline_element: (Multiline) :param args: The arguments to print :type args:
(multiline_element, *args, end=None, sep=None, text_color=None, background_color=None, autoscroll=None, justification=None, font=None, image=None, image_subsample=None)
| 18659 | # ------------------------------------------------------------------------------------------------ # |
| 18660 | |
| 18661 | def _print_to_element(multiline_element, *args, end=None, sep=None, text_color=None, background_color=None, autoscroll=None, justification=None, font=None, image=None, image_subsample=None): |
| 18662 | """ |
| 18663 | Print like Python normally prints except route the output to a multiline element and also add colors if desired |
| 18664 | |
| 18665 | :param multiline_element: The multiline element to be output to |
| 18666 | :type multiline_element: (Multiline) |
| 18667 | :param args: The arguments to print |
| 18668 | :type args: List[Any] |
| 18669 | :param end: The end char to use just like print uses |
| 18670 | :type end: (str) |
| 18671 | :param sep: The separation character like print uses |
| 18672 | :type sep: (str) |
| 18673 | :param text_color: color of the text |
| 18674 | :type text_color: (str) |
| 18675 | :param background_color: The background color of the line |
| 18676 | :type background_color: (str) |
| 18677 | :param autoscroll: If True (the default), the element will scroll to bottom after updating |
| 18678 | :type autoscroll: (bool) |
| 18679 | :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 |
| 18680 | :type font: str | (str, int) |
| 18681 | :param image: Insert this image inline with text. Can be Raw or Base64 representation of the image or filename of image |
| 18682 | :type image: (str | bytes) |
| 18683 | :param image_subsample: amount to reduce the size of the image. Divides the size by this number. 2=1/2, 3=1/3, 4=1/4, etc |
| 18684 | :type image_subsample: (int) |
| 18685 | """ |
| 18686 | end_str = str(end) if end is not None else '\n' |
| 18687 | sep_str = str(sep) if sep is not None else ' ' |
| 18688 | |
| 18689 | outstring = '' |
| 18690 | num_args = len(args) |
| 18691 | for i, arg in enumerate(args): |
| 18692 | outstring += str(arg) |
| 18693 | if i != num_args - 1: |
| 18694 | outstring += sep_str |
| 18695 | outstring += end_str |
| 18696 | |
| 18697 | multiline_element.update(outstring, append=True, text_color_for_value=text_color, background_color_for_value=background_color, autoscroll=autoscroll, |
| 18698 | justification=justification, font_for_value=font, image=image, image_subsample=image_subsample) |
| 18699 | |
| 18700 | try: # if the element is set to autorefresh, then refresh the parent window |
| 18701 | if multiline_element.AutoRefresh: |
| 18702 | multiline_element.ParentForm.refresh() |
| 18703 | except: |
| 18704 | pass |
| 18705 | |
| 18706 | |
| 18707 | def _parse_colors_parm(colors): |