简体   繁体   English

如何使用 GTK4 将图像添加到按钮?

[英]How to add an image to a button with GTK4?

I know this question exists How to add an image to a button with GTK but gtk_button_set_image is deprecated in gtk4.我知道这个问题存在How to add an image to a button with GTKgtk_button_set_image在 gtk4 中已弃用。

gtk_button_set_child (GTK_BUTTON (button), image); where button and image are GtkButton and GtkImage, respectivly.其中 button 和 image 分别是 GtkButton 和 GtkImage。

Gtk.Box box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 5);
box.prepend(new Image.from_icon_name("media-playback-start"));
box.append(new Gtk.Label("Play"));
button.child = box;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM