diff options
| author | troido <troido@protonmail.com> | 2018-09-06 18:51:15 +0200 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2018-09-06 18:51:15 +0200 |
| commit | 5bd11fd1914ea6744852b78047b207e521a304f1 (patch) | |
| tree | d60947313eb14470be2e91b1f4975ab933059278 /asciifarm/client/display/switcher.py | |
| parent | 6c3ff03ab92c2d4493355fdbb31a7ababbba97f4 (diff) | |
made menus switchable so not all menus need to be in view all the time
Diffstat (limited to 'asciifarm/client/display/switcher.py')
| -rw-r--r-- | asciifarm/client/display/switcher.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/asciifarm/client/display/switcher.py b/asciifarm/client/display/switcher.py new file mode 100644 index 0000000..196aa88 --- /dev/null +++ b/asciifarm/client/display/switcher.py @@ -0,0 +1,25 @@ + +from .widimp import WidImp +from .inventory import Inventory + +class Switcher(Inventory): + """An area that can contain multiple widgets but only shows one at a time. + There is a function to switch between the displayed widgets. + """ + + def __init__(self, widgets, initial=0): + Inventory.__init__(self, " ") + self.setInventory(widgets) + + for wid in widgets: + wid.hidden = True + + self.select(initial) + + def doSelect(self, value): + self.getSelectedItem().hidden = True + self.selector = value + newWid = self.getSelectedItem() + newWid.hidden = False + newWid.change() + |
