首先 使用new_from_file_at_scale方法创建一个 GdkPixbuf,该方法具有以下语法.
new_from_file_at_scale(文件名,宽度,高度,preserve_aspect_ratio)
创建小部件Gtk.Image与方法new_from_pixbuf其接收PIXBUF作为参数.
简单示例:
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GdkPixbuf
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(
filename="1.jpg",
width=24,
height=24,
preserve_aspect_ratio=True)
image = Gtk.Image.new_from_pixbuf(pixbuf)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1898 次 |
| 最近记录: |