简体   繁体   English

如何将PyGTK按钮带到前面?

[英]How do I bring a PyGTK Button to the front?

I have a gtk.Table to which I've attached a number of gtk.Buttons, some of which overlap others. 我有一个gtk.Table,上面已经附加了许多gtk.Button,其中有些与其他按钮重叠。 I can't figure out how to bring a specific button to the front, however. 但是,我不知道如何将特定按钮带到前面。 How do I do it? 我该怎么做?

I've struggled with an issue similar to this, and came to the conclusion that it wasn't possible in an officially documented manner... gtk.Table doesn't seem to have been designed to deal with the idea that things might overlap. 我一直在努力解决类似问题,并得出这样的结论,即不可能以正式记录的方式... gtk.Table似乎并非旨在处理事物可能重叠的想法。 Widgets seemed to be rendered in an order related to (but not exactly) the order they were added into the table. 窗口小部件的呈现顺序似乎与(但不完全相同)它们添加到表中的顺序有关。

What I ended up doing was determining which widgets were overlapping, and wrote code to toggle their visibility, depending on which one was appropriate for the current state. 我最终要做的是确定哪些小部件重叠,并编写代码以切换它们的可见性,具体取决于哪一种适合当前状态。 That was only possible because of the particular nature of my app, it might not work for you. 仅由于我的应用程序的特殊性,才有可能,但它可能对您不起作用。

One avenue which I didn't research to far, but might be viable: intercepting the expose event on the gtk table, and propagating it to the children in a specific order (this got complicated quickly, but might work). 我到目前为止还没有研究过但可能可行的一种途径:拦截gtk表上的暴露事件,并以特定顺序将其传播给孩子(这很快变得很复杂,但可能会起作用)。 My understanding of the gtk.Widget events is incomplete, there may be other events that need intercepting as well. 我对gtk.Widget事件的理解不完整,可能还有其他事件需要拦截。

You could try to use the Clutter toolkit, I believe this is more suitable for putting widgets on surfaces that you can then animate and move around. 您可以尝试使用Clutter工具包,我相信这更适合将小部件放置在可以进行动画处理和移动的表面上。 It's also built on the same technology as GTK, so it won't be too unfamiliar. 它也基于与GTK相同的技术构建,因此不会太陌生。

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

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