GTK#小部件在另一个小部件之前 [英] GTK# Widget in front of another widget

查看:99
本文介绍了GTK#小部件在另一个小部件之前的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将一个小部件置于另一个小部件的前面? 我想将timeLeft标签放置在DrawingArea框的前面

How to bring a widget to the front of another widget? I want to put the timeLeft Label in front of the box DrawingArea

我的代码:

box.SetSizeRequest((int)Math.Floor(size*2.5), size);
box.ExposeEvent += boxExpose;
theMainWindow.winFix.Put(box, x, y);
box.Show();

Pango.FontDescription fontdesc = Pango.FontDescription.FromString("Lucida Console " + (size - 6));
timeLeft.ModifyFont(fontdesc);
timeLeft.SetSizeRequest((int)Math.Floor(size*2.5)-6, size-6);

theMainWindow.winFix.Put(timeLeft, x+3, y+3);   
timeLeft.Show();

推荐答案

因此gtk#中的标签没有自己的gdk窗口,无法使用父窗口小部件(在这种情况下为窗口).为了解决这个问题,您可以将标签包装在EventBox小部件中,然后将其添加到窗口中.之所以有效,是因为事件框为标签提供了绘制窗口.

So Labels in gtk# don't have there own gdk window and draw on to the parent widget (the window in this case). To get around this you can wrap the label in an EventBox widget and add that to the window. This works because the event box is giving the label a window to draw on.

这篇关于GTK#小部件在另一个小部件之前的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆