简体   繁体   English

GTK#背景图片

[英]Gtk# background image

I just started to use Gtk# today, and I'm astonished how few Documentation and exampleprojects are out there. 我今天才刚开始使用Gtk#,而我惊讶的是那里的文档和示例项目很少。 Anyways I wanted to ask, does anybody know how to add a backgroundimage to a window or a widget? 无论如何我想问,有人知道如何向窗口或小部件添加背景图像吗? Or I don't know is it possible to stack multiple widgets over each other beacause, because then it would be quite easy. 或者我不知道是否可以将多个小部件彼此堆叠,因为那样会很容易。

Gtk.Window is for the GUI, for background images you need to use Graphics ie you need to access the underlying GdkWindow . Gtk.Window用于GUI,对于背景图像,您需要使用Graphics,即您需要访问基础的GdkWindow。 In Gtk# simply use 在Gtk#中只需使用

 Gtk.Window mwin = new Gtk.Window();
 Gdk.Window gwin = mwin.GdkWindow;

then use Gdk.Pixbuf to set the background image. 然后使用Gdk.Pixbuf设置背景图像。 Here's a link that may be helpful, it is in PHP-GTK, but it shouldn't be too hard to convert to C#. 这是一个有用的链接,它在PHP-GTK中,但转换为C#并不难。

http://www.kksou.com/php-gtk2/articles/place-a-background-image-in-GtkWindow.php http://www.kksou.com/php-gtk2/articles/place-a-background-image-in-GtkWindow.php

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

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