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


Python widgets.Photo類代碼示例

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


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

示例1: MediaPreview

class MediaPreview(Gramplet):
    """
    Displays a preview of the media 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)

    def build_gui(self):
        """
        Build the GUI interface.
        """
        self.top = Gtk.Box()
        self.photo = Photo(self.uistate.screen_height() < 1000)
        self.top.pack_start(self.photo, fill=True, expand=False, padding=5)
        self.top.show_all()
        return self.top

    def db_changed(self):
        self.dbstate.db.connect('media-update', self.update)
        self.connect_signal('Media', self.update)

    def update_has_data(self): 
        active_handle = self.get_active('Media')
        if active_handle:
            active_media = self.dbstate.db.get_object_from_handle(active_handle)
            self.set_has_data(active_media is not None)
        else:
            self.set_has_data(False)

    def main(self):
        active_handle = self.get_active('Media')
        if active_handle:
            media = self.dbstate.db.get_object_from_handle(active_handle)
            self.top.hide()
            if media:
                self.load_image(media)
                self.set_has_data(True)
            else:
                self.photo.set_image(None)
                self.set_has_data(False)
            self.top.show()
        else:
            self.set_has_data(False)

    def load_image(self, media):
        """
        Load the primary image if it exists.
        """
        self.full_path = media_path_full(self.dbstate.db,
                                               media.get_path())
        mime_type = media.get_mime_type()
        self.photo.set_image(self.full_path, mime_type)
開發者ID:nblock,項目名稱:gramps,代碼行數:54,代碼來源:mediapreview.py

示例2: load_images

 def load_images(self, obj):
     """
     Load the primary image into the main form if it exists.
     """
     media_list = obj.get_media_list()
     count = 0
     for media_ref in media_list:
         media_handle = media_ref.get_reference_handle()
         media = self.dbstate.db.get_media_from_handle(media_handle)
         full_path = media_path_full(self.dbstate.db, media.get_path())
         mime_type = media.get_mime_type()
         if mime_type and mime_type.startswith("image"):
             photo = Photo(self.uistate.screen_height() < 1000)
             photo.set_image(full_path, mime_type, media_ref.get_rectangle())
             photo.set_uistate(self.uistate, media_handle)
         else:
             photo = Photo(self.uistate.screen_height() < 1000)
             photo.set_pixbuf(full_path,
                             get_thumbnail_image(full_path,
                                 mime_type,
                                 media_ref.get_rectangle()))
         self.image_list.append(photo)
         self.top.pack_start(photo, False, False, 0)
         count += 1
     self.top.show_all()
     self.set_has_data(count > 0)
開發者ID:tecknicaltom,項目名稱:gramps,代碼行數:26,代碼來源:gallery.py

示例3: build_gui

 def build_gui(self):
     """
     Build the GUI interface.
     """
     self.top = Gtk.Box()
     if not computer_vision_available:
         vbox = Gtk.Label(_("OpenCV-Python is not installed"))
         self.top.pack_start(vbox, False, False, 0)
         self.top.show_all()
         return self.top
     # first column:
     vbox = Gtk.Box(Gtk.Orientation.VERTICAL)
     self.top.pack_start(vbox, False, False, 0)
     self.photo = Photo()
     vbox.pack_start(self.photo, False, False, 5)
     self.detect_button = Gtk.Button(_("Detect New Faces"))
     self.detect_button.connect('button-press-event', self.detect)
     vbox.pack_start(self.detect_button, False, False, 0)
     # second column
     vbox = Gtk.Box(Gtk.Orientation.VERTICAL)
     vbox.pack_start(Gtk.Label("Image:"), False, False, 0)
     self.top.pack_start(vbox, False, False, 0)
     # show and return:
     self.top.show_all()
     return self.top
開發者ID:daleathan,項目名稱:addons-source,代碼行數:25,代碼來源:FaceDetection.py

示例4: build_gui

 def build_gui(self):
     """
     Build the GUI interface.
     """
     self.top = Gtk.Box()
     self.photo = Photo(self.uistate.screen_height() < 1000)
     self.top.pack_start(self.photo, fill=True, expand=False, padding=5)
     self.top.show_all()
     return self.top
開發者ID:cz172638,項目名稱:gramps,代碼行數:9,代碼來源:mediapreview.py

示例5: 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

示例6: build_gui

 def build_gui(self):
     """
     Build the GUI interface.
     """
     self.top = Gtk.HBox()
     vbox = Gtk.VBox()
     self.photo = Photo(self.uistate.screen_height() < 1000)
     self.title = Gtk.Label()
     self.title.set_alignment(0, 0)
     self.title.modify_font(Pango.FontDescription('sans bold 12'))
     vbox.pack_start(self.title, False, True, 7)
     self.table = Gtk.Table(n_rows=1, n_columns=2)
     vbox.pack_start(self.table, False, True, 0)
     self.top.pack_start(self.photo, False, True, 5)
     self.top.pack_start(vbox, False, True, 10)
     self.top.show_all()
     return self.top
開發者ID:daleathan,項目名稱:gramps-addons,代碼行數:17,代碼來源:AddressPreview.py

示例7: build_gui

 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.title = Gtk.Label(halign=Gtk.Align.START)
     self.title.override_font(Pango.FontDescription('sans bold 12'))
     vbox.pack_start(self.title, False, True, 7)
     self.grid = Gtk.Grid(orientation=Gtk.Orientation.VERTICAL)
     self.grid.set_column_spacing(10)
     vbox.pack_start(self.grid, False, True, 0)
     self.top.pack_start(self.photo, False, True, 5)
     self.top.pack_start(vbox, False, True, 10)
     self.top.show_all()
     return self.top
開發者ID:Greunlis,項目名稱:gramps,代碼行數:17,代碼來源:placedetails.py

示例8: build_gui

 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'))
     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
開發者ID:belissent,項目名稱:gramps,代碼行數:18,代碼來源:persondetails.py

示例9: build_gui

 def build_gui(self):
     """
     Build the GUI interface.
     """
     self.top = Gtk.HBox()
     # first column:
     vbox = Gtk.VBox()
     self.top.pack_start(vbox, False, False, 0)
     self.photo = Photo()
     vbox.pack_start(self.photo, False, False, 5)
     self.detect_button = Gtk.Button(_("Detect New Faces"))
     self.detect_button.connect('button-press-event', self.detect)
     vbox.pack_start(self.detect_button, False, False, 0)
     # second column
     vbox = Gtk.VBox()
     vbox.pack_start(Gtk.Label("Image:"), False, False, 0)
     self.top.pack_start(vbox, False, False, 0)
     # show and return:
     self.top.show_all()
     return self.top
開發者ID:belissent,項目名稱:addons-source,代碼行數:20,代碼來源:FaceDetection.py

示例10: FaceDetection

class FaceDetection(Gramplet):
    """
    Interface for detecting and assigning facial areas to 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)

    def build_gui(self):
        """
        Build the GUI interface.
        """
        self.top = Gtk.HBox()
        # first column:
        vbox = Gtk.VBox()
        self.top.pack_start(vbox, False, False, 0)
        self.photo = Photo()
        vbox.pack_start(self.photo, False, False, 5)
        self.detect_button = Gtk.Button(_("Detect New Faces"))
        self.detect_button.connect('button-press-event', self.detect)
        vbox.pack_start(self.detect_button, False, False, 0)
        # second column
        vbox = Gtk.VBox()
        vbox.pack_start(Gtk.Label("Image:"), False, False, 0)
        self.top.pack_start(vbox, False, False, 0)
        # show and return:
        self.top.show_all()
        return self.top

    def db_changed(self):
        self.dbstate.db.connect('media-update', self.update)
        self.connect_signal('Media', self.update)
        self.update()

    def update_has_data(self):
        active_handle = self.get_active('Media')
        active_media = self.dbstate.db.get_media_from_handle(active_handle)
        self.set_has_data(active_media is not None)

    def main(self):
        active_handle = self.get_active('Media')
        media = self.dbstate.db.get_media_from_handle(active_handle)
        self.top.hide()
        if media:
            self.detect_button.set_sensitive(True)
            self.load_image(media)
            self.set_has_data(True)
        else:
            self.detect_button.set_sensitive(False)
            self.photo.set_image(None)
            self.set_has_data(False)
        self.top.show()

    def load_image(self, media):
        """
        Load the primary image if it exists.
        """
        self.full_path = media_path_full(self.dbstate.db,
                                               media.get_path())
        self.mime_type = media.get_mime_type()
        self.photo.set_image(self.full_path, self.mime_type)
        # show where image parts are used by people:
        rects = self.find_references()
        self.draw_rectangles([], rects)

    def find_references(self):
        """
        Find backref people
        """
        active_handle = self.get_active('Media')
        rects = []
        for (classname, handle) in \
                self.dbstate.db.find_backlink_handles(active_handle):
            if classname == "Person":
                person = self.dbstate.db.get_person_from_handle(handle)
                if person:
                    media_list = person.get_media_list()
                    for media_ref in media_list:
                        # get the rect for this image:
                        if media_ref.ref != active_handle: continue
                        rect = media_ref.get_rectangle()
                        if rect:
                            x1, y1, x2, y2 = rect
                            # make percentages
                            rects.append((x1/100.0, y1/100.0,
                                          (x2 - x1)/100.0, (y2 - y1)/100.0))
        return rects

    def detect(self, obj, event):
        # First, reset image, in case of previous detections:
        active_handle = self.get_active('Media')
        media = self.dbstate.db.get_media_from_handle(active_handle)
        self.load_image(media)
        min_face_size = (50,50) # FIXME: get from setting
        self.cv_image = cv.LoadImage(self.full_path, cv.CV_LOAD_IMAGE_GRAYSCALE)
        o_width, o_height = self.cv_image.width, self.cv_image.height
        cv.EqualizeHist(self.cv_image, self.cv_image)
        cascade = cv.Load(HAARCASCADE_PATH)
        faces = cv.HaarDetectObjects(self.cv_image, cascade,
#.........這裏部分代碼省略.........
開發者ID:belissent,項目名稱:addons-source,代碼行數:101,代碼來源:FaceDetection.py

示例11: AddressPreview

class AddressPreview(Gramplet, DbGUIElement):
    """
    Displays the participants of an event.
    """
    def __init__(self, gui, nav_group=0):
        Gramplet.__init__(self, gui, nav_group)
        DbGUIElement.__init__(self, self.dbstate.db)

    def _connect_db_signals(self):
        """
        called on init of DbGUIElement, connect to db as required.
        """
        self.callman.register_callbacks({'place-update': self.changed,
                                         'event-update': self.changed})
        self.callman.connect_all(keys=['place', 'event'])
        #self.dbstate.db.connect('person-update', self.update)
        self.connect_signal('Place', self.update)

    def changed(self, handle):
        """
        Called when a registered person is updated.
        """
        self.update()

    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.
        """
        self.top = Gtk.HBox()
        vbox = Gtk.VBox()
        self.photo = Photo(self.uistate.screen_height() < 1000)
        self.title = Gtk.Label()
        self.title.set_alignment(0, 0)
        self.title.modify_font(Pango.FontDescription('sans bold 12'))
        vbox.pack_start(self.title, False, True, 7)
        self.table = Gtk.Table(n_rows=1, n_columns=2)
        vbox.pack_start(self.table, False, True, 0)
        self.top.pack_start(self.photo, False, True, 5)
        self.top.pack_start(vbox, False, True, 10)
        self.top.show_all()
        return self.top

# ------------------------------------------------------------------------------------------

    _address_format = ["street, custom, unknown, building, department, farm, neighborhood",
                       "hamlet, village, borough, locality",
                       "code[ town, city, municipality], parish",
                       "district, region, province, county, state",
                       "country",
                       ""]

    _place_keys = ['street', 'department', 'building', 'farm', 'neighborhood', 'hamlet', 'village',
                  'borough', 'locality', 'town', 'city', 'municipality', 'parish', 'district',
                  'region', 'province', 'county', 'state', 'country', 'custom', 'unknown', 'code']

    _place_types = dict(street=PlaceType.STREET,
                       department=PlaceType.DEPARTMENT,
                       building=PlaceType.BUILDING,
                       farm=PlaceType.FARM,
                       neighborhood=PlaceType.NEIGHBORHOOD,
                       hamlet=PlaceType.HAMLET,
                       village=PlaceType.VILLAGE,
                       borough=PlaceType.BOROUGH,
                       locality=PlaceType.LOCALITY,
                       town=PlaceType.TOWN,
                       city=PlaceType.CITY,
                       municipality=PlaceType.MUNICIPALITY,
                       parish=PlaceType.PARISH,
                       district=PlaceType.DISTRICT,
                       province=PlaceType.PROVINCE,
                       region=PlaceType.REGION,
                       county=PlaceType.COUNTY,
                       state=PlaceType.STATE,
                       country=PlaceType.COUNTRY,
                       custom=PlaceType.CUSTOM,
                       unknown=PlaceType.UNKNOWN)

    def add_row(self, title, value):
        """
        Add a row to the table.
        """
        label = Gtk.Label(label=title + ':')
        label.set_alignment(1, 0)
        label.show()
        value = Gtk.Label(label=value)
        value.set_alignment(0, 0)
        value.show()
        rows = self.table.get_property('n-rows')
        rows += 1
        self.table.resize(rows, 2)
        self.table.attach(label, 0, 1, rows, rows + 1, xoptions=Gtk.AttachOptions.FILL,
                                                       xpadding=10)
        self.table.attach(value, 1, 2, rows, rows + 1)

#.........這裏部分代碼省略.........
開發者ID:daleathan,項目名稱:gramps-addons,代碼行數:101,代碼來源:AddressPreview.py

示例12: PlaceDetails

class PlaceDetails(Gramplet):
    """
    Displays details for a place.
    """
    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)

    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.title = Gtk.Label(halign=Gtk.Align.START)
        self.title.override_font(Pango.FontDescription('sans bold 12'))
        vbox.pack_start(self.title, False, True, 7)
        self.grid = Gtk.Grid(orientation=Gtk.Orientation.VERTICAL)
        self.grid.set_column_spacing(10)
        vbox.pack_start(self.grid, False, True, 0)
        self.top.pack_start(self.photo, False, True, 5)
        self.top.pack_start(vbox, False, True, 10)
        self.top.show_all()
        return self.top

    def add_row(self, title, value):
        """
        Add a row to the table.
        """
        label = Gtk.Label(label=title + ':', halign=Gtk.Align.END,
                          valign=Gtk.Align.START)
        label.show()
        value = Gtk.Label(label=value, halign=Gtk.Align.START)
        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.dbstate.db.connect('place-update', self.update)
        self.connect_signal('Place', self.update)

    def update_has_data(self):
        active_handle = self.get_active('Person')
        if active_handle:
            active_person = self.dbstate.db.get_person_from_handle(active_handle)
            self.set_has_data(active_person is not None)
        else:
            self.set_has_data(False)

    def main(self):
        self.display_empty()
        active_handle = self.get_active('Place')
        if active_handle:
            place = self.dbstate.db.get_place_from_handle(active_handle)
            self.top.hide()
            if place:
                self.display_place(place)
                self.set_has_data(True)
            else:
                self.set_has_data(False)
            self.top.show()
        else:
            self.set_has_data(False)

    def display_place(self, place):
        """
        Display details of the active place.
        """
        self.load_place_image(place)
        title = place_displayer.display(self.dbstate.db, place)
        self.title.set_text(title)

        self.clear_grid()
        self.add_row(_('Name'), place.get_name().get_value())
        self.add_row(_('Type'), place.get_type())
        self.display_separator()
        self.display_alt_names(place)
        self.display_separator()
        lat, lon = conv_lat_lon(place.get_latitude(),
                                place.get_longitude(),
                                format='DEG')
        if lat:
            self.add_row(_('Latitude'), lat)
        if lon:
            self.add_row(_('Longitude'), lon)

    def display_alt_names(self, place):
        """
        Display alternative names for the place.
        """
        alt_names = [name.get_value() for name in place.get_alternative_names()]
        if len(alt_names) > 0:
#.........這裏部分代碼省略.........
開發者ID:Greunlis,項目名稱:gramps,代碼行數:101,代碼來源:placedetails.py

示例13: MediaBrowser

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,代碼行數:101,代碼來源:MediaBrowser.py

示例14: PersonDetails

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,代碼行數:101,代碼來源:persondetails.py


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