如何在 Python 中设置 Gtk 图像的大小
How to set size of a Gtk Image in Python
如何在 Python 3.
首先用new_from_file_at_scale[=29=创建一个GdkPixbuf ] 方法,语法如下。
new_from_file_at_scale (filename, width, height, 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)
如何在 Python 3.
首先用new_from_file_at_scale[=29=创建一个GdkPixbuf ] 方法,语法如下。
new_from_file_at_scale (filename, width, height, 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)