Example #1
0
    def __init__(self,
                 entity,
                 *args,
                 widget=True,
                 selected=None,
                 open_button=None,
                 select_entities=None):
        """Search result widget in 'open new entity' dialog

            Args:
                entity (dict): havig keys "URI, "Label", "Description" and "Data".
                selected (list): keep track of entity's selected status
        """
        CheckButton.__init__(self, *args)

        self.entity = entity

        if widget:
            self.label.set_text(entity['Label'])
            self.description.set_text(entity['Description'])
            self.URI.set_text(entity['URI'])
        else:
            self.label.destroy()
            self.description.destroy()
            self.URI.destroy()

        #TODO: implement selected as signal in cointaining listbox
        if selected != None:
            if entity["URI"] in (v["URI"] for v in selected):
                self.set_active(True)
            args = [self.toggled_cb, selected]
            if open_button: args = args + [open_button]
            if select_entities: args = args + [select_entities]
            self.connect("toggled", *args)
        self.show_all()