本文整理汇总了Python中gramps.gen.simple.SimpleAccess.display方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleAccess.display方法的具体用法?Python SimpleAccess.display怎么用?Python SimpleAccess.display使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gramps.gen.simple.SimpleAccess
的用法示例。
在下文中一共展示了SimpleAccess.display方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_tooltip_from_link
# 需要导入模块: from gramps.gen.simple import SimpleAccess [as 别名]
# 或者: from gramps.gen.simple.SimpleAccess import display [as 别名]
def make_tooltip_from_link(self, link_tag):
"""
Return a string useful for a tooltip given a LinkTag object.
"""
from gramps.gen.simple import SimpleAccess
win_obj = find_parent_with_attr(self, attr="dbstate")
display = link_tag.data
if win_obj:
simple_access = SimpleAccess(win_obj.dbstate.db)
url = link_tag.data
if url.startswith("gramps://"):
obj_class, prop, value = url[9:].split("/")
display = simple_access.display(obj_class, prop, value) or url
return display
示例2: EditLink
# 需要导入模块: from gramps.gen.simple import SimpleAccess [as 别名]
# 或者: from gramps.gen.simple.SimpleAccess import display [as 别名]
class EditLink(ManagedWindow):
def __init__(self, dbstate, uistate, track, url, callback):
self.url = url
self.dbstate = dbstate
self.simple_access = SimpleAccess(self.dbstate.db)
self.callback = callback
ManagedWindow.__init__(self, uistate, track, url)
self._local_init()
self._connect_signals()
self.show()
def _local_init(self):
self.top = Glade()
self.set_window(self.top.toplevel,
self.top.get_object("title"),
_('Link Editor'))
self.uri_list = self.top.get_object('link_type')
for text in [_("Internet Address"), # 0 this order range above
_("Event"), # 1
_("Family"), # 2
_("Media"), # 3
_("Note"), # 4
_("Person"), # 5
_("Place"), # 6
_("Repository"), # 7
_("Source"), # 8
]:
self.uri_list.append_text(text)
self.pick_item = self.top.get_object('button1')
self.new_button = self.top.get_object('new')
self.edit_button = self.top.get_object('edit')
self.selected = self.top.get_object('label1')
self.url_link = self.top.get_object('entry1')
self.uri_list.connect("changed", self._on_type_changed)
self.pick_item.connect("clicked", self._on_pick_one)
self.new_button.connect("clicked", self._on_new)
self.edit_button.connect("clicked", self._on_edit_one)
if self.url.startswith("gramps://"):
object_class, prop, value = self.url[9:].split("/", 2)
if object_class == "Event":
self.uri_list.set_active(EVENT)
elif object_class == "Family":
self.uri_list.set_active(FAMILY)
elif object_class == "Media":
self.uri_list.set_active(MEDIA)
elif object_class == "Note":
self.uri_list.set_active(NOTE)
elif object_class == "Person":
self.uri_list.set_active(PERSON)
elif object_class == "Place":
self.uri_list.set_active(PLACE)
elif object_class == "Repository":
self.uri_list.set_active(REPOSITORY)
elif object_class == "Source":
self.uri_list.set_active(SOURCE)
# set texts:
self.selected.set_text(self.display_link(
object_class, prop, value))
self.url_link.set_text("gramps://%s/%s/%s" %
(object_class, prop, value))
else:
self.uri_list.set_active(WEB)
self.url_link.set_text(self.url)
self.url_link.connect("changed", self.update_ui)
def update_ui(self, widget):
url = self.url_link.get_text()
# text needs to have 3 or more chars://and at least one char
match = re.match("\w{3,}://\w+", url)
if match:
self.ok_button.set_sensitive(True)
else:
self.ok_button.set_sensitive(False)
def display_link(self, obj_class, prop, value):
return self.simple_access.display(obj_class, prop, value)
def _on_new_callback(self, obj):
object_class = obj.__class__.__name__
self.selected.set_text(self.display_link(
object_class, "handle", obj.handle))
self.url_link.set_text("gramps://%s/%s/%s" %
(object_class, "handle", obj.handle))
def _on_new(self, widget):
from ..editors import EditObject
object_class = OBJECT_MAP[self.uri_list.get_active()]
EditObject(self.dbstate,
self.uistate,
self.track,
object_class,
callback=self._on_new_callback)
def _on_edit_one(self, widget):
from ..editors import EditObject
uri = self.url_link.get_text()
if uri.startswith("gramps://"):
#.........这里部分代码省略.........