简体   繁体   中英

How to connect the “show” and “hide” signals with PyGTK?

I would like to have a callback called when some widget (a Menu ) is shown or hidden. Doing this way:

menu = gtk.Menu()
menu.connect("show", self.menu_show, menu)
menu.connect("hide", self.menu_hide, menu)

Callback functions are never called. Are show and hide signals the ones I am looking for? Are they special? Is there something I am missing to have this working?

I think those signals are emitted only when the respective methods on an object are called. If you want to connect to when a widget is (re-) drawn, take the expose-event signal. But why do you want to anyway? A menu is there to provide to the user choices for actions, not to run some setup/teardown code when it is shown/hidden.

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