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


Python Photo.set_uistate方法代碼示例

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


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

示例1: load_images

# 需要導入模塊: from gramps.gui.widgets import Photo [as 別名]
# 或者: from gramps.gui.widgets.Photo import set_uistate [as 別名]
 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,代碼行數:28,代碼來源:gallery.py

示例2: MediaPreview

# 需要導入模塊: from gramps.gui.widgets import Photo [as 別名]
# 或者: from gramps.gui.widgets.Photo import set_uistate [as 別名]
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.connect(self.dbstate.db, '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_media_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_media_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.photo.set_image(None)
            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)
        self.photo.set_uistate(self.uistate, None)
開發者ID:SNoiraud,項目名稱:gramps,代碼行數:57,代碼來源:mediapreview.py

示例3: AddressPreview

# 需要導入模塊: from gramps.gui.widgets import Photo [as 別名]
# 或者: from gramps.gui.widgets.Photo import set_uistate [as 別名]

#.........這裏部分代碼省略.........
        place_dict = self.generate_place_dictionary(place)
        parser = FormatStringParser(place_dict)

        addr1 = parser.parse(place_dict, self._address_format[0])
        addr2 = parser.parse(place_dict, self._address_format[1])
        city = parser.parse(place_dict, self._address_format[2])
        state = parser.parse(place_dict, self._address_format[3])
        country = parser.parse(place_dict, self._address_format[4])
        code = parser.parse(place_dict, self._address_format[5])

        self.add_row(_("Address 1"), addr1)
        self.add_row(_("Address 2"), addr2)
        self.add_row(_("City"), city)
        self.add_row(_("State"), state)
        self.add_row(_("Country"), country)
        self.add_row(_("Postal Code"), code)
        self.add_row(_("Version"), "0.1")

        #self.add_row(_('Name'), place.get_name())
        #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 generate_place_dictionary(self, place):
        db = self.dbstate.get_database()
        location = get_main_location(db, place)
        place_dict = dict()

        for key in self._place_keys:
            place_type = self._place_types.get(key.lower())
            if place_type:
                value = location.get(place_type)
            elif key == "code":
                value = place.get_code()
            else:
                value = ""
            if not value: value = ""

            place_dict[key] = value
        return place_dict


    def display_alt_names(self, place):
        """
        Display alternative names for the place.
        """
        alt_names = place .get_alternative_names()
        if len(alt_names) > 0:
            self.add_row(_('Alternative Names'), '\n'.join(alt_names))

    def display_empty(self):
        """
        Display empty details when no repository is selected.
        """
        self.photo.set_image(None)
        self.photo.set_uistate(None, None)
        self.title.set_text('')
        self.clear_table()

    def display_separator(self):
        """
        Display an empty row to separate groupd of entries.
        """
        label = Gtk.Label(label='')
        label.modify_font(Pango.FontDescription('sans 4'))
        label.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)

    def load_place_image(self, place):
        """
        Load the primary image if it exists.
        """
        media_list = place.get_media_list()
        if media_list:
            media_ref = media_list[0]
            object_handle = media_ref.get_reference_handle()
            obj = self.dbstate.db.get_object_from_handle(object_handle)
            full_path = media_path_full(self.dbstate.db, obj.get_path())
            mime_type = obj.get_mime_type()
            if mime_type and mime_type.startswith("image"):
                self.photo.set_image(full_path, mime_type,
                                     media_ref.get_rectangle())
                self.photo.set_uistate(self.uistate, object_handle)
            else:
                self.photo.set_image(None)
                self.photo.set_uistate(None, None)
        else:
            self.photo.set_image(None)
            self.photo.set_uistate(None, None)
開發者ID:daleathan,項目名稱:gramps-addons,代碼行數:104,代碼來源:AddressPreview.py

示例4: PlaceDetails

# 需要導入模塊: from gramps.gui.widgets import Photo [as 別名]
# 或者: from gramps.gui.widgets.Photo import set_uistate [as 別名]

#.........這裏部分代碼省略.........
        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:
            self.add_row(_('Alternative Names'), '\n'.join(alt_names))

    def display_empty(self):
        """
        Display empty details when no repository is selected.
        """
        self.photo.set_image(None)
        self.photo.set_uistate(None, None)
        self.title.set_text('')
        self.clear_grid()

    def display_separator(self):
        """
        Display an empty row to separate groupd of entries.
        """
        label = Gtk.Label(label='')
        label.override_font(Pango.FontDescription('sans 4'))
        label.show()
        self.grid.add(label)

    def load_place_image(self, place):
        """
        Load the primary image if it exists.
        """
        media_list = place.get_media_list()
        if media_list:
            media_ref = media_list[0]
            object_handle = media_ref.get_reference_handle()
            obj = self.dbstate.db.get_object_from_handle(object_handle)
            full_path = media_path_full(self.dbstate.db, obj.get_path())
            mime_type = obj.get_mime_type()
            if mime_type and mime_type.startswith("image"):
                self.photo.set_image(full_path, mime_type,
                                     media_ref.get_rectangle())
                self.photo.set_uistate(self.uistate, object_handle)
            else:
                self.photo.set_image(None)
                self.photo.set_uistate(None, None)
        else:
            self.photo.set_image(None)
            self.photo.set_uistate(None, None)
開發者ID:Greunlis,項目名稱:gramps,代碼行數:104,代碼來源:placedetails.py

示例5: PersonDetails

# 需要導入模塊: from gramps.gui.widgets import Photo [as 別名]
# 或者: from gramps.gui.widgets.Photo import set_uistate [as 別名]

#.........這裏部分代碼省略.........
        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:
                self.display_person(active_person)
            self.top.show()
        self.update_has_data()

    def display_person(self, active_person):
        """
        Display details of the active person.
        """
        self.load_person_image(active_person)
        self.name.set_text(name_displayer.display(active_person))
        self.clear_grid()
        self.display_alternate_names(active_person)
        self.display_parents(active_person)
        self.display_separator()
        self.display_type(active_person, EventType(EventType.BIRTH))
        self.display_type(active_person, EventType(EventType.BAPTISM))
        self.display_type(active_person, EventType(EventType.DEATH))
        self.display_type(active_person, EventType(EventType.BURIAL))
        self.display_separator()
        self.display_attribute(active_person, _('Occupation'))
        self.display_attribute(active_person, _('Title'))
        self.display_attribute(active_person, _('Religion'))

    def display_empty(self):
        """
        Display empty details when no person is selected.
        """
        self.photo.set_image(None)
        self.photo.set_uistate(None, None)
        self.name.set_text(_('No active person'))
        self.clear_grid()

    def display_separator(self):
        """
        Display an empty row to separate groupd of entries.
        """
        label = Gtk.Label(label='')
        label.override_font(Pango.FontDescription('sans 4'))
        label.set_selectable(True)
        label.show()
        self.grid.add(label)

    def display_alternate_names(self, active_person):
        """
        Display other names of the person
        """
        try:
            nlist = active_person.get_alternate_names()
            if len(nlist) > 0:
                for altname in nlist:
                    name_type = str(altname.get_type())
                    text = name_displayer.display_name(altname)
                    self.add_row(name_type, text)
                self.display_separator()
        except:
            pass

    def display_parents(self, active_person):
        """
        Display the parents of the active person.
        """
開發者ID:SNoiraud,項目名稱:gramps,代碼行數:70,代碼來源:persondetails.py


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