Skip to content

Commit 1992ccc

Browse files
committed
Use colors from cmd2.colors.Color
1 parent a821cb0 commit 1992ccc

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

examples/rich_tables.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from rich.table import Table
1212

1313
import cmd2
14+
from cmd2.colors import Color
1415

1516
CITY_HEADERS = ['Flag', 'City', 'Country', '2025 Population']
1617
CITY_DATA = [
@@ -102,16 +103,16 @@ def do_countries(self, _: cmd2.Statement) -> None:
102103
table.add_row(*str_row)
103104

104105
# Make Population column blue
105-
table.columns[2].header_style = "bold blue"
106-
table.columns[2].style = "blue"
106+
table.columns[2].header_style = Color.BRIGHT_BLUE
107+
table.columns[2].style = Color.BLUE
107108

108109
# Make Density column red
109-
table.columns[4].header_style = "bold red"
110-
table.columns[4].style = "red"
110+
table.columns[4].header_style = Color.BRIGHT_RED
111+
table.columns[4].style = Color.RED
111112

112113
# Make GDB per capita column green
113-
table.columns[6].header_style = "bold green"
114-
table.columns[6].style = "green"
114+
table.columns[6].header_style = Color.BRIGHT_GREEN
115+
table.columns[6].style = Color.GREEN
115116

116117
self.poutput(table)
117118

0 commit comments

Comments
 (0)