Compare commits

...

3 Commits

Author SHA1 Message Date
Sebastian Lohff 3d1d2d5acd Add theme example 2019-08-15 15:13:18 +02:00
Sebastian Lohff 58d6170a5c Add bold highlight style to defaults 2019-08-15 15:10:21 +02:00
Sebastian Lohff 206dcc46df Correct typo in var name 2019-08-15 15:10:07 +02:00
2 changed files with 19 additions and 2 deletions

View File

@ -68,10 +68,11 @@ class CliMenuTheme:
CYAN = CliMenuStyle('cyan', 'lightcyan', 'cyan') CYAN = CliMenuStyle('cyan', 'lightcyan', 'cyan')
BLUE = CliMenuStyle('ansiblue', 'ansired', 'ansiblue') BLUE = CliMenuStyle('ansiblue', 'ansired', 'ansiblue')
ANSI_CYAN = CliMenuStyle('ansicyan', 'ansibrightcyan', 'ansicyan') ANSI_CYAN = CliMenuStyle('ansicyan', 'ansibrightcyan', 'ansicyan')
BOLD_HIGHLIGHT = CliMenuStyle(header_style='bold', highlight_style='bold fg:black bg:white')
class CliMenu: class CliMenu:
default_stye = CliMenuTheme.BASIC default_style = CliMenuTheme.BASIC
default_cursor = CliMenuCursor.TRIANGLE default_cursor = CliMenuCursor.TRIANGLE
def __init__(self, options=None, header=None, cursor=None, style=None, def __init__(self, options=None, header=None, cursor=None, style=None,
@ -91,7 +92,7 @@ class CliMenu:
self._style = style self._style = style
if not self._style: if not self._style:
self._style = self.default_stye self._style = self.default_style
if header: if header:
self.add_header(header, indent=False) self.add_header(header, indent=False)

16
examples/theme1.py Normal file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env python3
from clintermission import CliMenu, CliMenuTheme
def main():
q = ["Foo", "Bar", "Baz baz baz baz baz"]
m = CliMenu(q, "Time to choose:\n", style=CliMenuTheme.BOLD_HIGHLIGHT)
if m.success:
print("You selected", m.get_selection())
else:
print("You aborted the selection")
if __name__ == '__main__':
main()