简体   繁体   中英

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. 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.

  • 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.

  • Another possibility is to bind a click event to the image and to query the x/y coordinates of the click. 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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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