Compare commits
3 Commits
58455be58a
...
3d1d2d5acd
Author | SHA1 | Date |
---|---|---|
Sebastian Lohff | 3d1d2d5acd | |
Sebastian Lohff | 58d6170a5c | |
Sebastian Lohff | 206dcc46df |
|
@ -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)
|
||||||
|
|
|
@ -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()
|
Loading…
Reference in New Issue