Browse Source

Allow a default theme and cursor to be set

Sebastian Lohff 1 year ago
parent
commit
a28c76e001
1 changed files with 10 additions and 7 deletions
  1. 10
    7
      clintermission/climenu.py

+ 10
- 7
clintermission/climenu.py View File

@@ -75,6 +75,14 @@ class CliMenu:
75 75
     default_style = CliMenuTheme.BASIC
76 76
     default_cursor = CliMenuCursor.TRIANGLE
77 77
 
78
+    @classmethod
79
+    def set_default_style(cls, style):
80
+        cls.default_style = style
81
+
82
+    @classmethod
83
+    def set_default_cursor(cls, cursor):
84
+        cls.default_cursor = cursor
85
+
78 86
     def __init__(self, options=None, header=None, cursor=None, style=None,
79 87
                  indent=2, dedent_selection=False):
80 88
         self._items = []
@@ -86,13 +94,8 @@ class CliMenu:
86 94
         self._header_indent = indent
87 95
         self._dedent_selection = dedent_selection
88 96
 
89
-        self._cursor = cursor
90
-        if not self._cursor:
91
-            self._cursor = self.default_cursor
92
-
93
-        self._style = style
94
-        if not self._style:
95
-            self._style = self.default_style
97
+        self._cursor = cursor or self.default_cursor
98
+        self._style = style or self.default_style
96 99
 
97 100
         if header:
98 101
             self.add_text(header, indent=False)

Loading…
Cancel
Save