Add CheckListPrompt to quickly.prompt

Bug #560335 reported by Rick Spencer
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Quickly Widgets
New
Undecided
Rick Spencer

Bug Description

This is generally useful code, should be built in:
class CheckListPrompt(Prompt):
    def __init__(self, title = "Input String", text = "Input a String:", default_value = None):

        Prompt.__init__(self, title, text)
        if default_value is None:
            default_value = {}
        self._vbox = gtk.VBox(True,5)
        self._vbox.show()
        keys = sorted(default_value)
        for k in keys:
            cb = gtk.CheckButton(k)
            cb.set_active(default_value[k])
            cb.show()
            self._vbox.pack_start(cb)
        self.content_box.pack_end(self._vbox, True, True, 5)

    def get_value(self):
        return_dict = {}
        for c in self._vbox.get_children():
            return_dict[c.get_label()] = c.get_active()
        return return_dict

def checklist(title = "Input String", text = "Input a String:", default_value = None):
    clp = CheckListPrompt(title, text, default_value)
    response = clp.run()
    val = clp.get_value()
    clp.destroy()
    return (response, val)

Changed in quidgets:
assignee: nobody → Rick Spencer (rick-rickspencer3)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.