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,
append=True)
| 4385 | pass |
| 4386 | |
| 4387 | 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, autoscroll=True, |
| 4388 | append=True): |
| 4389 | """ |
| 4390 | Print like Python normally prints except route the output to a multiline element and also add colors if desired |
| 4391 | |
| 4392 | colors -(str, str) or str. A combined text/background color definition in a single parameter |
| 4393 | |
| 4394 | There are also "aliases" for text_color, background_color and colors (t, b, c) |
| 4395 | t - An alias for color of the text (makes for shorter calls) |
| 4396 | b - An alias for the background_color parameter |
| 4397 | c - (str, str) - "shorthand" way of specifying color. (foreground, backgrouned) |
| 4398 | c - str - can also be a string of the format "foreground on background" ("white on red") |
| 4399 | |
| 4400 | With the aliases it's possible to write the same print but in more compact ways: |
| 4401 | cprint('This will print white text on red background', c=('white', 'red')) |
| 4402 | cprint('This will print white text on red background', c='white on red') |
| 4403 | cprint('This will print white text on red background', text_color='white', background_color='red') |
| 4404 | cprint('This will print white text on red background', t='white', b='red') |
| 4405 | |
| 4406 | :param args: The arguments to print |
| 4407 | :type args: (Any) |
| 4408 | :param end: The end char to use just like print uses |
| 4409 | :type end: (str) |
| 4410 | :param sep: The separation character like print uses |
| 4411 | :type sep: (str) |
| 4412 | :param text_color: The color of the text |
| 4413 | :type text_color: (str) |
| 4414 | :param background_color: The background color of the line |
| 4415 | :type background_color: (str) |
| 4416 | :param justification: text justification. left, right, center. Can use single characters l, r, c. Sets only for this value, not entire element |
| 4417 | :type justification: (str) |
| 4418 | :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 |
| 4419 | :type font: (str or (str, int[, str]) or None) |
| 4420 | :param colors: Either a tuple or a string that has both the text and background colors. Or just the text color |
| 4421 | :type colors: (str) or (str, str) |
| 4422 | :param t: Color of the text |
| 4423 | :type t: (str) |
| 4424 | :param b: The background color of the line |
| 4425 | :type b: (str) |
| 4426 | :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) |
| 4427 | :type c: (str) or (str, str) |
| 4428 | :param autoscroll: If True the contents of the element will automatically scroll as more data added to the end |
| 4429 | :type autoscroll: (bool) |
| 4430 | :param append: If True the contents of the element will automatically scroll as more data added to the end |
| 4431 | :type append: (bool) |
| 4432 | """ |
| 4433 | |
| 4434 | kw_text_color = text_color or t |
| 4435 | kw_background_color = background_color or b |
| 4436 | dual_color = colors or c |
| 4437 | try: |
| 4438 | if isinstance(dual_color, tuple): |
| 4439 | kw_text_color = dual_color[0] |
| 4440 | kw_background_color = dual_color[1] |
| 4441 | elif isinstance(dual_color, str): |
| 4442 | if ' on ' in dual_color: # if has "on" in the string, then have both text and background |
| 4443 | kw_text_color = dual_color.split(' on ')[0] |
| 4444 | kw_background_color = dual_color.split(' on ')[1] |
no test coverage detected