简体   繁体   English

如何在PyGTK中使按钮不可见但处于活动状态?

[英]How do I make a button invisible but active in PyGTK?

As far as I know, hide() and set_visible(False) both make the button invisible and inactive. 据我所知, hide()set_visible(False)都使按钮不可见和不活动。 Any workaround? 任何解决方法?

There is a 'workaround', and that is changing the implementation strategy. 有一个“解决方法”,它正在改变实施策略。 The idea of a clickable graphic seems legit, but I wouldn't recommend mixing custom 2D drawing and widgets. 可点击图形的想法似乎合法,但我不建议您混合使用自定义2D绘图和小部件。

  • If it fits your needs, you can split the graphic of a person up and put specific parts like the head image on a button. 如果适合您的需要,您可以将一个人的图形拆分起来,然后将诸如头像之类的特定部分放在按钮上。 Have a look at gtk_button_set_image and its Python equivalent. 看看gtk_button_set_image及其Python等效项。

  • Another possibility is to bind a click event to the image and to query the x/y coordinates of the click. 另一种可能性是将点击事件绑定到图像并查询点击的x / y坐标。 Simplest math, just iterate through a list of shapes associated with the image and determine a list of matching shapes (eg (50/100) is within the rectangle with the upper left corner of (30/80) and width & height of 40, this must be the stomach region). 最简单的数学,只需遍历与图像关联的形状列表并确定匹配形状的列表(例如(50/100)在矩形内,左上角为(30/80),宽度和高度为40,这一定是胃区域)。

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

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