Print like Python normally prints except route the output to a multiline element and also add colors if desired 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 color
(self, *args, end=None, sep=None, text_color=None, background_color=None, justification=None, font=None, colors=None, t=None, b=None, c=None,
autoscroll=True, image=None, image_subsample=None)
| 3934 | return value |
| 3935 | |
| 3936 | def print(self, *args, end=None, sep=None, text_color=None, background_color=None, justification=None, font=None, colors=None, t=None, b=None, c=None, |
| 3937 | autoscroll=True, image=None, image_subsample=None): |
| 3938 | """ |
| 3939 | Print like Python normally prints except route the output to a multiline element and also add colors if desired |
| 3940 | |
| 3941 | colors -(str, str) or str. A combined text/background color definition in a single parameter |
| 3942 | |
| 3943 | There are also "aliases" for text_color, background_color and colors (t, b, c) |
| 3944 | t - An alias for color of the text (makes for shorter calls) |
| 3945 | b - An alias for the background_color parameter |
| 3946 | c - (str, str) - "shorthand" way of specifying color. (foreground, backgrouned) |
| 3947 | c - str - can also be a string of the format "foreground on background" ("white on red") |
| 3948 | |
| 3949 | With the aliases it's possible to write the same print but in more compact ways: |
| 3950 | cprint('This will print white text on red background', c=('white', 'red')) |
| 3951 | cprint('This will print white text on red background', c='white on red') |
| 3952 | cprint('This will print white text on red background', text_color='white', background_color='red') |
| 3953 | cprint('This will print white text on red background', t='white', b='red') |
| 3954 | |
| 3955 | :param args: The arguments to print |
| 3956 | :type args: (Any) |
| 3957 | :param end: The end char to use just like print uses |
| 3958 | :type end: (str) |
| 3959 | :param sep: The separation character like print uses |
| 3960 | :type sep: (str) |
| 3961 | :param text_color: The color of the text |
| 3962 | :type text_color: (str) |
| 3963 | :param background_color: The background color of the line |
| 3964 | :type background_color: (str) |
| 3965 | :param justification: text justification. left, right, center. Can use single characters l, r, c. Sets only for this value, not entire element |
| 3966 | :type justification: (str) |
| 3967 | :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 args being printed |
| 3968 | :type font: (str or (str, int[, str]) or None) |
| 3969 | :param colors: Either a tuple or a string that has both the text and background colors. Or just the text color |
| 3970 | :type colors: (str) or (str, str) |
| 3971 | :param t: Color of the text |
| 3972 | :type t: (str) |
| 3973 | :param b: The background color of the line |
| 3974 | :type b: (str) |
| 3975 | :param c: Either a tuple or a string that has both the text and background colors or just tex color (same as the color parm) |
| 3976 | :type c: (str) or (str, str) |
| 3977 | :param autoscroll: If True the contents of the element will automatically scroll as more data added to the end |
| 3978 | :type autoscroll: (bool) |
| 3979 | :param image: Insert this image inline with text. Can be Raw or Base64 representation of the image or filename of image |
| 3980 | :type image: (str | bytes) |
| 3981 | :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 |
| 3982 | :type image_subsample: (int) |
| 3983 | """ |
| 3984 | |
| 3985 | kw_text_color = text_color or t |
| 3986 | kw_background_color = background_color or b |
| 3987 | dual_color = colors or c |
| 3988 | try: |
| 3989 | if isinstance(dual_color, tuple): |
| 3990 | kw_text_color = dual_color[0] |
| 3991 | kw_background_color = dual_color[1] |
| 3992 | elif isinstance(dual_color, str): |
| 3993 | if ' on ' in dual_color: # if has "on" in the string, then have both text and background |
no test coverage detected