Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/pynxc/waxy/dropdownbox.py
blob: 345351a05d9cbf737f3d7df740aef95b8931ca9f (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
30
31
32
33
34
35
36
37
38
39
40
# dropdownbox.py

# todo: styles... if any?

import wx
import containers
import waxyobject
import styles

class DropDownBox(wx.Choice, waxyobject.WaxyObject):

    __events__ = {
        'Select': wx.EVT_CHOICE,
    }

    def __init__(self, parent, choices=[], size=None, **kwargs):
        style = 0
        style |= styles.window(kwargs)
        wx.Choice.__init__(self, parent, wx.NewId(), choices=choices,
         size=size or (-1,-1), style=style)

        self.BindEvents()
        styles.properties(self, kwargs)

    def SetItems(self, items):
        """ Clear the internal list of items, and set new items.  <items> is
            a list of 2-tuples (string, data). """
        self.Clear()
        for s, data in items:
            self.Append(s, data)

    def GetItems(self):
        """ Return a list of 2-tuples (string, data). """
        items = []
        for i in range(self.GetCount()):
            s = self.GetString(i)
            data = self.GetClientData(i)
            items.append((s, data))
        return items