summaryrefslogtreecommitdiff
path: root/asciifarm/client/display/switcher.py
blob: 035aea3a1a559732a12bba4200e31f0799326db8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29


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
        self.change()
        newWid = self.getSelectedItem()
        newWid.hidden = False
        newWid.change()
    
    def itemName(self, item):
        return item.getImpl().title