當前位置: 首頁>>代碼示例>>Python>>正文


Python Photo.show方法代碼示例

本文整理匯總了Python中gramps.gui.widgets.Photo.show方法的典型用法代碼示例。如果您正苦於以下問題:Python Photo.show方法的具體用法?Python Photo.show怎麽用?Python Photo.show使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gramps.gui.widgets.Photo的用法示例。


在下文中一共展示了Photo.show方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: MediaBrowser

# 需要導入模塊: from gramps.gui.widgets import Photo [as 別名]
# 或者: from gramps.gui.widgets.Photo import show [as 別名]
class MediaBrowser(Gramplet):
    """
    Displays an object tree and a media preview for a person.
    """

    def init(self):
        self.gui.WIDGET = self.build_gui()
        self.gui.get_container_widget().remove(self.gui.textview)
        self.gui.get_container_widget().add_with_viewport(self.gui.WIDGET)
        self.gui.WIDGET.show()

    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

    def db_changed(self):
        self.dbstate.db.connect("person-update", self.update)
        self.update()

    def active_changed(self, handle):
        self.update()

    def update_has_data(self):
        active_handle = self.get_active("Person")
        active = self.dbstate.db.get_person_from_handle(active_handle)
        self.set_has_data(self.get_has_data(active))

    def main(self):
        active_handle = self.get_active("Person")
        active = self.dbstate.db.get_person_from_handle(active_handle)

        self.model.clear()
        self.photo.set_image(None)
        if active:
            self.display_data(active)
        else:
            self.set_has_data(False)

    def display_data(self, person):
        """
        Display the object tree for the active person.
        """
        self.add_media(person)
        self.add_events(person)
        self.add_sources(person)
        self.set_has_data(self.model.count > 0)

    def add_events(self, obj, parent_node=None):
        """
        Add event nodes to the model.
        """
        for event_ref in obj.get_event_ref_list():
            handle = event_ref.ref
            name, event = navigation_label(self.dbstate.db, "Event", handle)
            node = self.model.add([name], node=parent_node)
            self.add_sources(event, node)
            self.add_media(event, node)

    def add_sources(self, obj, parent_node=None):
        """
        Add source nodes to the model.
        """
        for citation_handle in obj.get_citation_list():
            citation = self.dbstate.db.get_citation_from_handle(citation_handle)
            handle = citation.get_reference_handle()
            name, src = navigation_label(self.dbstate.db, "Source", handle)
            node = self.model.add([name], node=parent_node)
            self.add_media(src, node)

    def add_media(self, obj, parent_node=None):
        """
        Add media object nodes to the model.
        """
        for media_ref in obj.get_media_list():
            handle = media_ref.ref
            name, media = navigation_label(self.dbstate.db, "Media", handle)
            full_path = media_path_full(self.dbstate.db, media.get_path())
            rect = media_ref.get_rectangle()
            self.model.add([name], info=media_ref, node=parent_node)

    def row_selected(self, selection):
        """
        Change the image when a row is selected.
        """
        selected = self.model.get_selected_objects()
        if selected:
            if selected[0]:
                self.load_image(selected[0])
            else:
#.........這裏部分代碼省略.........
開發者ID:killes,項目名稱:addons-source,代碼行數:103,代碼來源:MediaBrowser.py

示例2: PersonDetails

# 需要導入模塊: from gramps.gui.widgets import Photo [as 別名]
# 或者: from gramps.gui.widgets.Photo import show [as 別名]
class PersonDetails(Gramplet):
    """
    Displays details for a person.
    """
    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.uistate.connect('nameformat-changed', self.update)
        self.uistate.connect('placeformat-changed', self.update)

    def build_gui(self):
        """
        Build the GUI interface.
        """
        self.top = Gtk.Box()
        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.photo = Photo(self.uistate.screen_height() < 1000)
        self.photo.show()
        self.name = Gtk.Label(halign=Gtk.Align.START)
        self.name.override_font(Pango.FontDescription('sans bold 12'))
        self.name.set_selectable(True)
        vbox.pack_start(self.name, fill=True, expand=False, padding=7)
        self.grid = Gtk.Grid(orientation=Gtk.Orientation.VERTICAL)
        self.grid.set_column_spacing(10)
        vbox.pack_start(self.grid, fill=True, expand=False, padding=5)
        vbox.show_all()
        self.top.pack_start(self.photo, fill=True, expand=False, padding=5)
        self.top.pack_start(vbox, fill=True, expand=True, padding=10)
        return self.top

    def add_row(self, title, value):
        """
        Add a row to the table.
        """
        label = Gtk.Label(label=title + COLON, halign=Gtk.Align.END,
                          valign=Gtk.Align.START)
        label.set_selectable(True)
        label.show()
        value = Gtk.Label(label=value, halign=Gtk.Align.START)
        value.set_selectable(True)
        value.show()
        self.grid.add(label)
        self.grid.attach_next_to(value, label, Gtk.PositionType.RIGHT, 1, 1)

    def clear_grid(self):
        """
        Remove all the rows from the grid.
        """
        list(map(self.grid.remove, self.grid.get_children()))

    def db_changed(self):
        self.connect(self.dbstate.db, 'person-update', self.update)

    def active_changed(self, handle):
        self.update()

    def update_has_data(self):
        """
        Determine if a person has_data by checking:

            1. has a birth, baptism, death, or burial event; OR
            2. has a father; OR
            3. has a mother
        """
        active_handle = self.get_active('Person')
        has_data = False
        if active_handle:
            active_person = self.dbstate.db.get_person_from_handle(active_handle)
            if active_person:
                for event_type in [EventType(EventType.BIRTH),
                                   EventType(EventType.BAPTISM),
                                   EventType(EventType.DEATH),
                                   EventType(EventType.BURIAL)]:
                    event = self.get_event(active_person, event_type)
                    if event:
                        has_data = True
                        break
                if not has_data:
                    family_handle = active_person.get_main_parents_family_handle()
                    if family_handle:
                        family = self.dbstate.db.get_family_from_handle(family_handle)
                        handle = family.get_father_handle()
                        if handle:
                            if self.dbstate.db.get_person_from_handle(handle):
                                has_data = True
                            else:
                                handle = family.get_mother_handle()
                                if handle:
                                    if self.dbstate.db.get_person_from_handle(handle):
                                        has_data = True
        self.set_has_data(has_data)

    def main(self): # return false finishes
        self.display_empty()
        active_handle = self.get_active('Person')
        if active_handle:
            active_person = self.dbstate.db.get_person_from_handle(active_handle)
            self.top.hide()
            if active_person:
#.........這裏部分代碼省略.........
開發者ID:SNoiraud,項目名稱:gramps,代碼行數:103,代碼來源:persondetails.py


注:本文中的gramps.gui.widgets.Photo.show方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。