Skip to content

Commit 4c96b03

Browse files
committed
Change some styles to show off different options
1 parent 44a71ae commit 4c96b03

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

examples/rich_theme.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ def __init__(self, *args, **kwargs):
2121

2222
# Create a custom theme
2323
custom_theme = {
24-
Cmd2Style.SUCCESS: Style(color=Color.CYAN),
25-
Cmd2Style.WARNING: Style(color=Color.MAGENTA),
26-
Cmd2Style.ERROR: Style(color=Color.BRIGHT_RED),
27-
Cmd2Style.HELP_HEADER: Style(color=Color.YELLOW),
28-
Cmd2Style.HELP_LEADER: Style(color=Color.DARK_VIOLET, bgcolor=Color.BRIGHT_WHITE),
24+
Cmd2Style.SUCCESS: Style(color=Color.GREEN),
25+
Cmd2Style.WARNING: Style(color=Color.ORANGE1),
26+
Cmd2Style.ERROR: Style(color=Color.PINK1),
27+
Cmd2Style.HELP_HEADER: Style(color=Color.CYAN, bgcolor="#44475a"),
28+
Cmd2Style.HELP_LEADER: Style(color="#f8f8f2", bgcolor="#282a36"),
2929
Cmd2Style.TABLE_BORDER: Style(color=Color.LIGHT_SKY_BLUE1),
3030
"argparse.args": Style(color=Color.AQUAMARINE3, underline=True),
3131
"inspect.attr": Style(color=Color.DARK_GOLDENROD, bold=True),
@@ -35,10 +35,12 @@ def __init__(self, *args, **kwargs):
3535
@cmd2.with_category("Theme Commands")
3636
def do_theme_show(self, _: cmd2.Statement):
3737
"""Showcases the custom theme by printing messages with different styles."""
38+
# NOTE: Using soft_wrap=False will ensure display looks correct when background colors are part of the style
3839
self.poutput("This is a basic output message.")
39-
self.psuccess("This is a success message.")
40-
self.pwarning("This is a warning message.")
41-
self.perror("This is an error message.")
40+
self.psuccess("This is a success message.", soft_wrap=False)
41+
self.pwarning("This is a warning message.", soft_wrap=False)
42+
self.perror("This is an error message.", soft_wrap=False)
43+
self.pexcept(ValueError("This is a dummy ValueError exception."))
4244

4345

4446
if __name__ == "__main__":

0 commit comments

Comments
 (0)