当前位置: 首页>>代码示例>>Python>>正文


Python listmodel.ListModel类代码示例

本文整理汇总了Python中gramps.gui.listmodel.ListModel的典型用法代码示例。如果您正苦于以下问题:Python ListModel类的具体用法?Python ListModel怎么用?Python ListModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ListModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, dbstate, user, options_class, name, callback=None):
        uistate = user.uistate
        self.label = _("Gender Statistics tool")
        tool.Tool.__init__(self, dbstate, options_class, name)

        stats_list = []
        for name, value in dbstate.db.genderStats.stats.items():
            stats_list.append(
                (name,)
                + value
                + (_GENDER[dbstate.db.genderStats.guess_gender(name)],)
                )

        if uistate:
            ManagedWindow.__init__(self, uistate, [], self.__class__)

            titles = [(_('Name'), 0, 100),
                      (_('Male'), 1, 70, INTEGER),
                      (_('Female'), 2, 70, INTEGER),
                      (_('Unknown'), 3, 90, INTEGER),
                      (_('Guess'), 4, 70)]

            treeview = Gtk.TreeView()
            model = ListModel(treeview, titles)
            for entry in sorted(stats_list):
                model.add(entry, entry[0])

            s = Gtk.ScrolledWindow()
            s.add(treeview)
            dialog = Gtk.Dialog()
            dialog.add_button(_('_Close'), Gtk.ResponseType.CLOSE)
            dialog.connect('response', self._response)
            dialog.vbox.pack_start(s, expand=True, fill=True, padding=0)
            self.set_window(dialog, None, self.label)
            self.setup_configs('interface.dumpgenderstats', 420, 300)
            self.show()

        else:
            if len(_('Name')) < 16:
                print('%s%s%s' % (_('Name'),
                                  " " * (16 - len(_('Name'))),
                                  _('Male')),
                      '\t%s'*3 % (_('Female'), _('Unknown'), _('Guess')))
            else:
                print(_('Name'), '\t%s'*4 % (_('Male'), _('Female'),
                                             _('Unknown'), _('Guess')))
            print()
            for entry in sorted(stats_list):
                if len(entry[0]) < 16:
                    print('%s%s%s' % (entry[0],
                                      " " * (16 - len(entry[0])),
                                      entry[1]),
                          '\t%s'*3 % (entry[2:]))
                else:
                    print(entry[0], '\t%s'*4 % (entry[1:]))
开发者ID:SNoiraud,项目名称:gramps,代码行数:55,代码来源:dumpgenderstats.py

示例2: Backlinks

class Backlinks(Gramplet):
    """
    Displays the back references for an object.
    """
    def init(self):
        self.gui.WIDGET = self.build_gui()
        self.gui.get_container_widget().remove(self.gui.textview)
        self.gui.get_container_widget().add(self.gui.WIDGET)
        self.gui.WIDGET.show()

    def build_gui(self):
        """
        Build the GUI interface.
        """
        top = Gtk.TreeView()
        titles = [(_('Type'), 1, 100),
                  (_('Name'), 2, 100),
                  ('', 3, 1), #hidden column for the handle
                  ('', 4, 1)] #hidden column for non-localized object type 
        self.model = ListModel(top, titles, event_func=self.cb_double_click)
        return top
        
    def display_backlinks(self, active_handle):
        """
        Display the back references for an object.
        """
        for classname, handle in \
                        self.dbstate.db.find_backlink_handles(active_handle):
            name = navigation_label(self.dbstate.db, classname, handle)[0]
            self.model.add((_(classname), name, handle, classname))
        self.set_has_data(self.model.count > 0)

    def get_has_data(self, active_handle):
        """
        Return True if the gramplet has data, else return False.
        """
        if active_handle is None:
            return False
        for handle in self.dbstate.db.find_backlink_handles(active_handle):
            return True
        return False
        
    def cb_double_click(self, treeview):
        """
        Handle double click on treeview.
        """
        (model, iter_) = treeview.get_selection().get_selected()
        if not iter_:
            return

        (objclass, handle) = (model.get_value(iter_, 3), 
                              model.get_value(iter_, 2))

        edit_object(self.dbstate, self.uistate, objclass, handle)
开发者ID:nblock,项目名称:gramps,代码行数:54,代码来源:backlinks.py

示例3: Attributes

class Attributes(Gramplet):
    """
    Displays the attributes of an object.
    """
    def init(self):
        self.gui.WIDGET = self.build_gui()
        self.gui.get_container_widget().remove(self.gui.textview)
        self.gui.get_container_widget().add(self.gui.WIDGET)
        self.gui.WIDGET.show()

    def build_gui(self):
        """
        Build the GUI interface.
        """
        tip = _('Double-click on a row to view a quick report showing '
                'all people with the selected attribute.')
        self.set_tooltip(tip)
        top = Gtk.TreeView()
        titles = [(_('Key'), 1, 100),
                  (_('Value'), 2, 100)]
        self.model = ListModel(top, titles, event_func=self.display_report)
        return top

    def display_attributes(self, obj):
        """
        Display the attributes of an object.
        """
        for attr in obj.get_attribute_list():
            self.model.add((str(attr.get_type()), attr.get_value()))
        self.set_has_data(self.model.count > 0)

    def display_report(self, treeview):
        """
        Display the quick report for matching attribute key.
        """
        model, iter_ = treeview.get_selection().get_selected()
        if iter_:
            key = model.get_value(iter_, 0)
            run_quick_report_by_name(self.dbstate,
                                     self.uistate,
                                     'attribute_match',
                                     key)

    def get_has_data(self, obj):
        """
        Return True if the gramplet has data, else return False.
        """
        if obj is None:
            return False
        if obj.get_attribute_list():
            return True
        return False
开发者ID:belissent,项目名称:gramps,代码行数:52,代码来源:attributes.py

示例4: __init__

    def __init__(self, dbstate, user, options_class, name, callback=None):
        uistate = user.uistate
        self.label = _("Associations state tool")
        tool.Tool.__init__(self, dbstate, options_class, name)
        if uistate:
            ManagedWindow.__init__(self,uistate,[],
                                                 self.__class__)

        stats_list = []

        plist = dbstate.db.get_person_handles(sort_handles=True)

        for handle in plist:
            person = dbstate.db.get_person_from_handle(handle)
            name1 = name_displayer.display(person)
            refs = person.get_person_ref_list()
            if refs:
                for ref in person.serialize()[-1]:
                    (a, b, c, two, value) = ref
                    person2 = dbstate.db.get_person_from_handle(two)
                    name2 = name_displayer.display(person2)
                    stats_list.append((name1, value, name2))

        if uistate:
            titles = [
                (_('Name'), 0, 200),
                (_('Type of link'), 1, 200),
                (_('Of'), 2, 200),
                ]

            treeview = Gtk.TreeView()
            model = ListModel(treeview, titles)
            for entry in stats_list:
                model.add(entry, entry[0])

            window = Gtk.Window()
            window.set_default_size(800, 600)
            s = Gtk.ScrolledWindow()
            s.add(treeview)
            window.add(s)
            window.show_all()
            self.set_window(window, None, self.label)
            self.show()

        else:
            print('\t%s'*3 % ('Name','Type of link','Of'))
            print()
            for entry in stats_list:
                print('\t%s'*3 % entry)
开发者ID:belissent,项目名称:addons-source,代码行数:49,代码来源:associationstool.py

示例5: __init__

 def __init__(self, uistate, data, parent):
     super().__init__(uistate, [], self)
     self.window = Gtk.Dialog("Gramp")
     self.set_window(self.window, None, _("Database Information"))
     self.window.set_modal(True)
     self.ok = self.window.add_button(_("_OK"), Gtk.ResponseType.OK)
     self.ok.connect("clicked", self.on_ok_clicked)
     self.window.set_position(Gtk.WindowPosition.CENTER)
     self.window.set_default_size(600, 400)
     s = Gtk.ScrolledWindow()
     titles = [(_("Setting"), 0, 150), (_("Value"), 1, 400)]
     treeview = Gtk.TreeView()
     model = ListModel(treeview, titles)
     for key, value in sorted(data.items()):
         model.add((key, str(value)), key)
     s.add(treeview)
     self.window.vbox.pack_start(s, True, True, 0)
     self.show()
开发者ID:doczkal,项目名称:gramps,代码行数:18,代码来源:dbman.py

示例6: __init__

    def __init__(self, dbstate, user, options_class, name, callback=None):
        uistate = user.uistate
        self.label = _("Gender Statistics tool")
        tool.Tool.__init__(self, dbstate, options_class, name)
        if uistate:
            ManagedWindow.__init__(self,uistate,[],
                                                 self.__class__)

        stats_list = []
        for name, value in dbstate.db.genderStats.stats.items():
            stats_list.append(
                (name,)
                + value
                + (_GENDER[dbstate.db.genderStats.guess_gender(name)],)
                )

        if uistate:
            titles = [
                (_('Name'),0,100),
                (_('Male'),1,70,INTEGER),
                (_('Female'),2,70,INTEGER),
                (_('Unknown'),3,70,INTEGER),
                (_('Guess'),4,70)
                ]

            treeview = Gtk.TreeView()
            model = ListModel(treeview, titles)
            for entry in stats_list:
                model.add(entry, entry[0])

            window = Gtk.Window()
            window.set_default_size(400, 300)
            s = Gtk.ScrolledWindow()
            s.add(treeview)
            window.add(s)
            window.show_all()
            self.set_window(window, None, self.label)
            self.show()

        else:
            print('\t%s'*5 % ('Name','Male','Female','Unknown','Guess'))
            print()
            for entry in stats_list:
                print('\t%s'*5 % entry)
开发者ID:DaAwesomeP,项目名称:gramps,代码行数:44,代码来源:dumpgenderstats.py

示例7: __init__

 def __init__(self, uistate, data, track):
     super().__init__(uistate, track, self, modal=True)
     self.window = Gtk.Dialog()
     self.set_window(self.window, None, _("Database Information"))
     self.setup_configs('interface.information', 600, 400)
     self.ok = self.window.add_button(_('_OK'), Gtk.ResponseType.OK)
     self.ok.connect('clicked', self.on_ok_clicked)
     s = Gtk.ScrolledWindow()
     titles = [
         (_('Setting'), 0, 150),
         (_('Value'), 1, 400)
     ]
     treeview = Gtk.TreeView()
     model = ListModel(treeview, titles)
     for key, value in sorted(data.items()):
         model.add((key, str(value),), key)
     s.add(treeview)
     self.window.vbox.pack_start(s, True, True, 0)
     self.show()
开发者ID:ewongbb,项目名称:gramps,代码行数:19,代码来源:dbman.py

示例8: build_gui

 def build_gui(self):
     """
     Build the GUI interface.
     """
     tip = _("Double-click on a row to edit the selected source/citation.")
     self.set_tooltip(tip)
     top = Gtk.TreeView()
     titles = [("", NOSORT, 50), (_("Source/Citation"), 1, 350), (_("Author"), 2, 200), (_("Publisher"), 3, 150)]
     self.model = ListModel(top, titles, list_mode="tree", event_func=self.invoke_editor)
     return top
开发者ID:bigalexstrong,项目名称:gramps,代码行数:10,代码来源:citations.py

示例9: build_gui

 def build_gui(self):
     """
     Build the GUI interface.
     """
     tip = _("Double-click on a row to edit the selected event.")
     self.set_tooltip(tip)
     top = Gtk.TreeView()
     titles = [("", NOSORT, 50), (_("Date"), 1, 200), (_("Place"), 2, 200)]
     self.model = ListModel(top, titles, event_func=self.edit_event)
     return top
开发者ID:pat49,项目名称:gramps,代码行数:10,代码来源:personresidence.py

示例10: build_gui

 def build_gui(self):
     """
     Build the GUI interface.
     """
     top = Gtk.TreeView()
     titles = [(_('Type'), 1, 100),
               (_('Name'), 2, 100),
               ('', 3, 1), #hidden column for the handle
               ('', 4, 1)] #hidden column for non-localized object type 
     self.model = ListModel(top, titles, event_func=self.cb_double_click)
     return top
开发者ID:nblock,项目名称:gramps,代码行数:11,代码来源:backlinks.py

示例11: build_gui

 def build_gui(self):
     """
     Build the GUI interface.
     """
     tip = _('Double-click on a row to view a quick report showing '
             'all people with the selected attribute.')
     self.set_tooltip(tip)
     top = Gtk.TreeView()
     titles = [(_('Key'), 1, 100),
               (_('Value'), 2, 100)]
     self.model = ListModel(top, titles, event_func=self.display_report)
     return top
开发者ID:belissent,项目名称:gramps,代码行数:12,代码来源:attributes.py

示例12: build_gui

 def build_gui(self):
     """
     Build the GUI interface.
     """
     top = Gtk.HBox()
     self.photo = Photo()
     self.photo.show()
     view = Gtk.TreeView()
     titles = [(_("Object"), 1, 250)]
     self.model = ListModel(view, titles, list_mode="tree", select_func=self.row_selected)
     top.pack_start(view, True, True, 0)
     top.pack_start(self.photo, True, False, 5)
     top.show_all()
     return top
开发者ID:killes,项目名称:addons-source,代码行数:14,代码来源:MediaBrowser.py

示例13: build_gui

 def build_gui(self):
     """
     Build the GUI interface.
     """
     self.view = Gtk.TreeView()
     self.view.set_tooltip_column(3)
     titles = [(_('Name'), 0, 230),
               (_('Birth'), 2, 100),
               ('', NOSORT, 1),
               ('', NOSORT, 1), # tooltip
               ('', NOSORT, 100)] # handle
     self.model = ListModel(self.view, titles, list_mode="tree",
                            event_func=self.cb_double_click)
     return self.view
开发者ID:tester0077,项目名称:gramps,代码行数:14,代码来源:ancestor.py

示例14: build_gui

 def build_gui(self):
     """
     Build the GUI interface.
     """
     tip = _('Double-click on a row to edit the selected participant.')
     self.set_tooltip(tip)
     top = Gtk.TreeView()
     titles = [('', NOSORT, 50,),
               (_('Name'), 1, 250),
               (_('Role'), 2, 80),
               (_('Birth Date'), 3, 100),
               ('', 3, 100),
               (_('Spouses'), 4, 200)]
     self.model = ListModel(top, titles, event_func=self.edit_person)
     return top
开发者ID:SNoiraud,项目名称:addons-source,代码行数:15,代码来源:Participants.py

示例15: build_gui

 def build_gui(self):
     """
     Build the GUI interface.
     """
     tip = _('Double-click on a row to edit the selected place.')
     self.set_tooltip(tip)
     top = Gtk.TreeView()
     titles = [('', 0, 50),
               (_('Name'), 1, 300),
               (_('Type'), 2, 150),
               (_('Date'), 4, 150),
               ('', NOSORT, 50)]
     self.model = ListModel(top, titles, list_mode="tree",
                            event_func=self.edit_place)
     return top
开发者ID:DaAwesomeP,项目名称:gramps,代码行数:15,代码来源:locations.py


注:本文中的gramps.gui.listmodel.ListModel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。