コード例 #1
0
 def add(self,w,value=None):
     """Add a widget and associated value to the dropdown box."""
     
     if type(w) == str: w = Label(w,cls=self.cls+".option.label")
     
     w.style.align = -1
     btn = Button(w,cls=self.cls+".option")
     btn.connect(CLICK,self._setvalue,w)
     
     self.options.tr()
     self.options.add(btn)
     
     if (not self.firstOption):
         self.firstOption = btn
     
     if value != None: w._value = value
     else: w._value = w
     if self.value == w._value:
         self.top_selected.value = w
     self.values.append(w)
コード例 #2
0
    def add(self, w, value=None):
        """Add a widget, value item to the Select.
        
        <pre>Select.add(widget,value=None)</pre>
        
        <dl>
        <dt>widget<dd>Widget or string to represent the item
        <dt>value<dd>value for this item
        </dl>
        
        <strong>Example</strong>
        <code>
        w = Select()
        w.add("Goat") #adds a Label
        w.add("Goat","goat") #adds a Label with the value goat
        w.add(gui.Label("Cuzco"),"goat") #adds a Label with value goat
        </code>
        """

        if type(w) == str: w = Label(w, cls=self.cls + ".option.label")

        w.style.align = -1
        btn = Button(w, cls=self.cls + ".option")
        btn.connect(CLICK, self._setvalue, w)

        self.options.tr()
        self.options.add(btn)

        if (not self.firstOption):
            self.firstOption = btn

        if value != None: w._value = value
        else: w._value = w
        if self.value == w._value:
            self.top_selected.value = w
        self.values.append(w)