当前位置: 首页>>代码示例>>Python>>正文


Python repository.GdkPixbuf方法代码示例

本文整理汇总了Python中gi.repository.GdkPixbuf方法的典型用法代码示例。如果您正苦于以下问题:Python repository.GdkPixbuf方法的具体用法?Python repository.GdkPixbuf怎么用?Python repository.GdkPixbuf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gi.repository的用法示例。


在下文中一共展示了repository.GdkPixbuf方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_pixbuf_from_base64string

# 需要导入模块: from gi import repository [as 别名]
# 或者: from gi.repository import GdkPixbuf [as 别名]
def get_pixbuf_from_base64string(base64string):
    if base64string is None:
        return NOIMAGE
    raw_data = base64.b64decode(base64string.encode())
    try:
        pixbuf_loader = GdkPixbuf.PixbufLoader.new_with_mime_type("image/jpeg")
        pixbuf_loader.write(raw_data)
        pixbuf_loader.close()
        pixbuf = pixbuf_loader.get_pixbuf()
        return pixbuf
    except Exception as e:
        print(e)
    try:
        pixbuf_loader = GdkPixbuf.PixbufLoader.new_with_mime_type("image/png")
        pixbuf_loader.write(raw_data)
        pixbuf_loader.close()
        pixbuf = pixbuf_loader.get_pixbuf()
        return pixbuf
    except Exception as e:
        print(e)
    return NOIMAGE 
开发者ID:atareao,项目名称:lplayer,代码行数:23,代码来源:utils.py

示例2: get_pixbuf

# 需要导入模块: from gi import repository [as 别名]
# 或者: from gi.repository import GdkPixbuf [as 别名]
def get_pixbuf(self):
        """
        Returns a pixbuf with the current line-color.

        This method takes the current line-color hex-triplet and adds two
        characters for the transparency (Currently no transparency = ff). Then
        it created a Gdk.Pixbuf, fills it with the color and returns it. This
        method is called by the main window to create the colored squares for
        the layer view.
        """
        line_color_alpha = int("0x{0}ff".format(self.props["line_color"][1:]),
                               base=16)
        pixbuf_color = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB,
                                            True, 8, 16, 16)
        pixbuf_color.fill(line_color_alpha)
        return pixbuf_color 
开发者ID:innstereo,项目名称:innstereo,代码行数:18,代码来源:layer_types.py

示例3: test_write

# 需要导入模块: from gi import repository [as 别名]
# 或者: from gi.repository import GdkPixbuf [as 别名]
def test_write(self):
        """Write changes to disk via write command."""
        self.settings.override("autosave_images", "false")
        pixbuf = self.vimiv["image"].get_pixbuf_original()
        self.transform.rotate("1")
        # File has not changed
        file_pixbuf = GdkPixbuf.Pixbuf.new_from_file(self.vimiv.get_path())
        self.assertEqual(pixbuf.get_height(), file_pixbuf.get_height())
        # But after calling write it has
        self.transform.write()
        file_pixbuf = GdkPixbuf.Pixbuf.new_from_file(self.vimiv.get_path())
        self.assertNotEqual(pixbuf.get_height(), file_pixbuf.get_height())
        # Set back
        self.transform.rotate("-1")
        self.transform.write()
        file_pixbuf = GdkPixbuf.Pixbuf.new_from_file(self.vimiv.get_path())
        self.assertEqual(pixbuf.get_height(), file_pixbuf.get_height()) 
开发者ID:karlch,项目名称:vimiv,代码行数:19,代码来源:transform_test.py

示例4: set_audio

# 需要导入模块: from gi import repository [as 别名]
# 或者: from gi.repository import GdkPixbuf [as 别名]
def set_audio(self, audio):
        self.audio = audio
        filename = os.path.join(
            comun.THUMBNAILS_DIR, '{0}.png'.format(audio['hash']))
        if os.path.exists(filename):
            pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
                filename, 80, 80)
        else:
            pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
                comun.NOIMAGE_ICON, 80, 80)
        self.image.set_from_pixbuf(pixbuf)
        if len(audio['artist']) > 35:
            artist = audio['artist'][:32] + '...'
        else:
            artist = audio['artist']
        self.label1.set_markup(
            '<big><b>{0}</b></big>'.format(artist))
        if len(audio['title']) > 35:
            title = audio['title'][:32] + '...'
        else:
            title = audio['title']
        self.label2.set_text(title)
        if audio['listened'] is True:
            self.listened.set_from_pixbuf(LISTENED)
        else:
            self.listened.set_from_pixbuf(NOLISTENED)
        self.set_duration(audio['length'])
        self.set_position(audio['position']) 
开发者ID:atareao,项目名称:lplayer,代码行数:30,代码来源:listboxrowwithdata.py

示例5: create_thumbnail_for_audio

# 需要导入模块: from gi import repository [as 别名]
# 或者: from gi.repository import GdkPixbuf [as 别名]
def create_thumbnail_for_audio(hash, thumbnail_base64):
    thumbnail_filename = os.path.join(comun.THUMBNAILS_DIR,
                                      '{0}.png'.format(hash))
    if not os.path.exists(thumbnail_filename):
        if thumbnail_base64 is not None:
            pixbuf = get_pixbuf_from_base64string(thumbnail_base64)
        else:
            pixbuf = NOIMAGE
        pixbuf = pixbuf.scale_simple(256, 256, GdkPixbuf.InterpType.BILINEAR)
        pixbuf.savev(thumbnail_filename, 'png', [], []) 
开发者ID:atareao,项目名称:lplayer,代码行数:12,代码来源:utils.py

示例6: drag_begin

# 需要导入模块: from gi import repository [as 别名]
# 或者: from gi.repository import GdkPixbuf [as 别名]
def drag_begin(self, widget, context):
        if self.is_playing:
            self.player.pause()
            self.is_playing = False
        print('==== Drag begin ====')
        rows = self.trackview.get_selected_rows()
        if len(rows) > 0:
            selected = rows[0]
            pixbuf = get_pixbuf_from_base64string(
                selected.audio['thumbnail_base64']).scale_simple(
                64, 64, GdkPixbuf.InterpType.BILINEAR)
            Gtk.drag_set_icon_pixbuf(context, pixbuf, -2, -2) 
开发者ID:atareao,项目名称:lplayer,代码行数:14,代码来源:mainwindow.py

示例7: on_about_activate

# 需要导入模块: from gi import repository [as 别名]
# 或者: from gi.repository import GdkPixbuf [as 别名]
def on_about_activate(self, widget, optional):
        ad = Gtk.AboutDialog(comun.APPNAME, self.win)
        ad.set_name(comun.APPNAME)
        ad.set_version(comun.VERSION)
        ad.set_copyright('Copyrignt (c) 2018-2019\nLorenzo Carbonell')
        ad.set_comments(_('A minimal audio player for Linux'))
        ad.set_license('''
MIT License

Copyright (c) 2012-2018 Lorenzo Carbonell Cerezo <a.k.a. atareao>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
''')
        ad.set_website('http://www.atareao.es')
        ad.set_website_label('http://www.atareao.es')
        ad.set_authors([
            'Lorenzo Carbonell <lorenzo.carbonell.cerezo@gmail.com>'])
        ad.set_documenters([
            'Lorenzo Carbonell <lorenzo.carbonell.cerezo@gmail.com>'])
        ad.set_translator_credits('\
Lorenzo Carbonell <lorenzo.carbonell.cerezo@gmail.com>\n')
        ad.set_program_name(comun.APPNAME)
        ad.set_logo(GdkPixbuf.Pixbuf.new_from_file(comun.ICON))
        ad.run()
        ad.destroy() 
开发者ID:atareao,项目名称:lplayer,代码行数:43,代码来源:lplayer.py

示例8: compare_files

# 需要导入模块: from gi import repository [as 别名]
# 或者: from gi.repository import GdkPixbuf [as 别名]
def compare_files(file1, file2):
    """Directly compare two image files using GdkPixbuf."""
    pb1 = GdkPixbuf.Pixbuf.new_from_file(file1)
    pb2 = GdkPixbuf.Pixbuf.new_from_file(file2)
    return compare_pixbufs(pb1, pb2) 
开发者ID:karlch,项目名称:vimiv,代码行数:7,代码来源:vimiv_testcase.py

示例9: test_rotate

# 需要导入模块: from gi import repository [as 别名]
# 或者: from gi.repository import GdkPixbuf [as 别名]
def test_rotate(self):
        """Rotate image file."""
        def do_rotate_test(rotate_int):
            """Run the rotation test.

            Args:
                rotate_int: Number defining the rotation.
            """
            pb = GdkPixbuf.Pixbuf.new_from_file(self.filename)
            orientation_before = pb.get_width() < pb.get_height()
            imageactions.rotate_file(self.filename, rotate_int)
            pb = GdkPixbuf.Pixbuf.new_from_file(self.filename)
            orientation_after = pb.get_width() < pb.get_height()
            if rotate_int in [1, 3]:
                self.assertNotEqual(orientation_before, orientation_after)
            elif rotate_int == 2:
                self.assertEqual(orientation_before, orientation_after)
        # Rotate counterclockwise
        do_rotate_test(1)
        # Rotate clockwise
        do_rotate_test(3)
        # Images are now equal again
        self.assertTrue(compare_files(self.orig, self.filename))
        # Rotate 180
        do_rotate_test(2)
        # Images are not equal
        self.assertFalse(compare_files(self.orig, self.filename)) 
开发者ID:karlch,项目名称:vimiv,代码行数:29,代码来源:imageactions_test.py

示例10: test_autorotate

# 需要导入模块: from gi import repository [as 别名]
# 或者: from gi.repository import GdkPixbuf [as 别名]
def test_autorotate(self):
        """Autorotate files."""
        pb = GdkPixbuf.Pixbuf.new_from_file(self.filename)
        orientation_before = pb.get_width() < pb.get_height()
        autorotate = imageactions.Autorotate([self.filename])
        autorotate.connect("completed", self._on_autorotate_completed)
        autorotate.run()
        # Wait for it to complete
        self._waiting = True
        while self._waiting:
            time.sleep(0.05)
        pb = GdkPixbuf.Pixbuf.new_from_file(self.filename)
        orientation_after = pb.get_width() < pb.get_height()
        self.assertNotEqual(orientation_before, orientation_after) 
开发者ID:karlch,项目名称:vimiv,代码行数:16,代码来源:imageactions_test.py

示例11: get_about_dialog

# 需要导入模块: from gi import repository [as 别名]
# 或者: from gi.repository import GdkPixbuf [as 别名]
def get_about_dialog(self):
        """Create and populate the about dialog."""
        about_dialog = Gtk.AboutDialog()
        about_dialog.set_name(comun.APPNAME)
        about_dialog.set_version(comun.VERSION)
        about_dialog.set_copyright(
            'Copyrignt (c) 2014-2016\nLorenzo Carbonell Cerezo')
        about_dialog.set_comments(_('An indicator for Pomodoro Technique'))
        about_dialog.set_license('''
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
''')
        about_dialog.set_website('http://www.atareao.es')
        about_dialog.set_website_label('http://www.atareao.es')
        about_dialog.set_authors([
            'Lorenzo Carbonell <https://launchpad.net/~lorenzo-carbonell>'])
        about_dialog.set_documenters([
            'Lorenzo Carbonell <https://launchpad.net/~lorenzo-carbonell>'])
        about_dialog.set_translator_credits('''
Lorenzo Carbonell <https://launchpad.net/~lorenzo-carbonell>\n
''')
        about_dialog.set_icon(GdkPixbuf.Pixbuf.new_from_file(comun.ICON))
        about_dialog.set_logo(GdkPixbuf.Pixbuf.new_from_file(comun.ICON))
        about_dialog.set_program_name(comun.APPNAME)
        return about_dialog

    # ##################### callbacks for the menu ####################### 
开发者ID:atareao,项目名称:pomodoro-indicator,代码行数:38,代码来源:pomodoro_indicator.py

示例12: image2pixbuf

# 需要导入模块: from gi import repository [as 别名]
# 或者: from gi.repository import GdkPixbuf [as 别名]
def image2pixbuf(image):
	data = image.tobytes()
	w, h = image.size
	data = GLib.Bytes.new(data)
	pixbuf = GdkPixbuf.Pixbuf.new_from_bytes(data, GdkPixbuf.Colorspace.RGB, False, 8, w, h, w * 3)
	return pixbuf

# Convert RGB color to GdkPixbuf pixel 
开发者ID:AXeL-dev,项目名称:Dindo-Bot,代码行数:10,代码来源:convert.py

示例13: load_to_pixbuf

# 需要导入模块: from gi import repository [as 别名]
# 或者: from gi.repository import GdkPixbuf [as 别名]
def load_to_pixbuf(self, full_path, width=None, height=None):

        """Can be called by anything.

        Given the full path to an icon file, loads the icon into a pibxuf, and
        returns the pixbuf.

        Args:

            full_path (str): The full path to the icon file

            width, height (int or None): If both are specified, the icon is
                scaled to that size

        Returns:

            A GdkPixbuf, or None if the file is missing or can't be loaded

        """

        if not os.path.isfile(full_path):
            return None

        try:
            pixbuf = GdkPixbuf.Pixbuf.new_from_file(full_path)
        except:
            return None

        if width is not None and height is not None:
            pixbuf = pixbuf.scale_simple(
                width,
                height,
                GdkPixbuf.InterpType.BILINEAR,
            )

        return pixbuf 
开发者ID:axcore,项目名称:tartube,代码行数:38,代码来源:files.py

示例14: test_rotate

# 需要导入模块: from gi import repository [as 别名]
# 或者: from gi.repository import GdkPixbuf [as 别名]
def test_rotate(self):
        """Rotate image."""
        # Before
        pixbuf = self.vimiv["image"].get_pixbuf()
        self.assertLess(pixbuf.get_height(), pixbuf.get_width())
        # Rotate
        self.transform.rotate("1")
        self.transform.apply()
        pixbuf = self.vimiv["image"].get_pixbuf()
        self.assertGreater(pixbuf.get_height(), pixbuf.get_width())
        while self.transform.threads_running:
            sleep(0.05)
        # Check file
        updated_pixbuf = GdkPixbuf.Pixbuf.new_from_file(self.vimiv.get_path())
        self.assertGreater(updated_pixbuf.get_height(),
                           updated_pixbuf.get_width())
        # Rotate back
        self.transform.rotate("-1")
        self.transform.apply()
        pixbuf = self.vimiv["image"].get_pixbuf()
        self.assertLess(pixbuf.get_height(), pixbuf.get_width())
        while self.transform.threads_running:
            sleep(0.05)
        # Check file
        updated_pixbuf = GdkPixbuf.Pixbuf.new_from_file(self.vimiv.get_path())
        self.assertLess(updated_pixbuf.get_height(), updated_pixbuf.get_width())
        # Fail because of no paths
        backup = list(self.vimiv.get_paths())
        self.vimiv.populate([])
        self.transform.rotate("1")
        self.check_statusbar("ERROR: No image to rotate")
        self.vimiv.populate(backup)
        ##################
        #  Command line  #
        ##################
        # Rotate
        self.run_command("rotate 1")
        pixbuf = self.vimiv["image"].get_pixbuf()
        self.assertGreater(pixbuf.get_height(), pixbuf.get_width())
        # Rotate back
        self.run_command("rotate -1")
        pixbuf = self.vimiv["image"].get_pixbuf()
        self.assertLess(pixbuf.get_height(), pixbuf.get_width())
        # Fail because of invalid argument
        self.run_command("rotate value")
        self.check_statusbar("ERROR: Could not convert 'value' to int") 
开发者ID:karlch,项目名称:vimiv,代码行数:48,代码来源:transform_test.py


注:本文中的gi.repository.GdkPixbuf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。