コード例 #1
0
ファイル: imageslaveslave.py プロジェクト: LeonamSilva/stoq
    def _erase_image(self):
        # emit needs to go first to allow removing the reference, or else
        # we won't be able to remove the Image entry from the database.
        self.emit('image-changed', None)
        Image.delete(self._image_model.id, self.store)
        self._image_model = None
        self._image = None
        self._thumbnail = None

        self._update_widgets()
コード例 #2
0
    def _erase_image(self):
        # emit needs to go first to allow removing the reference, or else
        # we won't be able to remove the Image entry from the database.
        self.emit('image-changed', None)
        Image.delete(self._image_model.id, self.store)
        self._image_model = None
        self._image = None
        self._thumbnail = None

        self._update_widgets()
コード例 #3
0
ファイル: imageslave.py プロジェクト: 5l1v3r1/stoq-1
    def _edit_image(self):
        filters = get_filters_for_images()
        with selectfile(_("Select Image"), filters=filters) as sf:
            rv = sf.run()
            filename = sf.get_filename()
            if rv != Gtk.ResponseType.OK or not filename:
                return

        if not self.image_model:
            self.image_model = Image(store=self.store, sellable=self._sellable)

        pb = GdkPixbuf.Pixbuf.new_from_file(filename)
        self.image_model.image = _pixbuf_converter.as_string(pb)
        self.image_model.filename = str(os.path.basename(filename))

        if self._sellable:
            for image in self._sellable.images:
                if image.is_main:
                    break
            else:
                # If there's no main image, set this one to be
                self.image_model.is_main = True

        self._setup_thumbnail()
        self.emit('image-changed', self.image_model)

        self._update_widgets()
コード例 #4
0
    def _edit_image(self):
        filters = get_filters_for_images()
        with selectfile(_("Select Image"), filters=filters) as sf:
            rv = sf.run()
            filename = sf.get_filename()
            if rv != gtk.RESPONSE_OK or not filename:
                return

        w, h = (Image.THUMBNAIL_SIZE_WIDTH, Image.THUMBNAIL_SIZE_HEIGHT)
        self._thumbnail = gtk.gdk.pixbuf_new_from_file_at_size(filename, w, h)
        self._image = gtk.gdk.pixbuf_new_from_file(filename)

        if not self._image_model:
            self._image_model = Image(store=self.store)
        self._image_model.thumbnail = (_pixbuf_converter.as_string(
            self._thumbnail))
        self._image_model.image = _pixbuf_converter.as_string(self._image)
        self.emit('image-changed', self._image_model)

        self._update_widgets()
コード例 #5
0
 def create_image(self):
     from stoqlib.domain.image import Image
     return Image(
         store=self.store,
         description=u"Test image",
     )