本文整理汇总了Python中gramps.gui.listmodel.ListModel.get_object方法的典型用法代码示例。如果您正苦于以下问题:Python ListModel.get_object方法的具体用法?Python ListModel.get_object怎么用?Python ListModel.get_object使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gramps.gui.listmodel.ListModel
的用法示例。
在下文中一共展示了ListModel.get_object方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ShowMatches
# 需要导入模块: from gramps.gui.listmodel import ListModel [as 别名]
# 或者: from gramps.gui.listmodel.ListModel import get_object [as 别名]
class ShowMatches(ManagedWindow):
def __init__(self, dbstate, uistate, track, the_list, the_map, callback):
ManagedWindow.__init__(self,uistate,track,self.__class__)
self.dellist = {}
self.list = the_list
self.map = the_map
self.length = len(self.list)
self.update = callback
self.db = dbstate.db
self.dbstate = dbstate
self.uistate = uistate
top = Glade(toplevel="mergelist")
window = top.toplevel
self.set_window(window, top.get_object('title'),
_('Potential Merges'))
self.mlist = top.get_object("mlist")
top.connect_signals({
"destroy_passed_object" : self.close,
"on_do_merge_clicked" : self.on_do_merge_clicked,
"on_help_show_clicked" : self.on_help_clicked,
"on_delete_show_event" : self.close,
"on_merge_ok_clicked" : self.__dummy,
"on_help_clicked" : self.__dummy,
"on_delete_merge_event" : self.__dummy,
"on_delete_event" : self.__dummy,
})
mtitles = [
(_('Rating'),3,75),
(_('First Person'),1,200),
(_('Second Person'),2,200),
('',-1,0)
]
self.list = ListModel(self.mlist,mtitles,
event_func=self.on_do_merge_clicked)
self.redraw()
self.show()
def build_menu_names(self, obj):
return (_("Merge candidates"),None)
def on_help_clicked(self, obj):
"""Display the relevant portion of GRAMPS manual"""
display_help(WIKI_HELP_PAGE , WIKI_HELP_SEC)
def redraw(self):
list = []
for p1key, p1data in self.map.items():
if p1key in self.dellist:
continue
(p2key,c) = p1data
if p1key == p2key:
continue
list.append((c,p1key,p2key))
self.list.clear()
for (c,p1key,p2key) in list:
c1 = "%5.2f" % c
c2 = "%5.2f" % (100-c)
p1 = self.db.get_person_from_handle(p1key)
p2 = self.db.get_person_from_handle(p2key)
if not p1 or not p2:
continue
pn1 = name_displayer.display(p1)
pn2 = name_displayer.display(p2)
self.list.add([c1, pn1, pn2,c2],(p1key,p2key))
def on_do_merge_clicked(self, obj):
store,iter = self.list.selection.get_selected()
if not iter:
return
(self.p1,self.p2) = self.list.get_object(iter)
MergePerson(self.dbstate, self.uistate, self.p1, self.p2,
self.on_update, True)
def on_update(self):
if self.db.has_person_handle(self.p1):
phoenix = self.p1
titanic = self.p2
else:
phoenix = self.p2
titanic = self.p1
self.dellist[titanic] = phoenix
for key, data in self.dellist.items():
if data == titanic:
self.dellist[key] = phoenix
self.update()
self.redraw()
def update_and_destroy(self, obj):
self.update(1)
self.close()
#.........这里部分代码省略.........