Reputation: 978
I want to get signal from insensitived widget. but when widget is insensitived with widget.set_sensitive(False)
code line, singals of this widget not work. how can I ensure work the signals of the insensitive widgets ?
example
w = Gtk.Button("example")
w.set_sensitive(False)
w.connect("button-press-event", do_anything) # not work
I only want to freeze the widgets. but widgets completely not working with this way.
Upvotes: 0
Views: 447
Reputation: 4104
That is the meaning of the widgets not being sensitive. If so they won't emit signals to events and you won't be able to interact with them.
There are some situations where you want the widgets to be insensitive, for example, imagine a "Login" button in a authentication dialog but you only want to allow the login if both Username and Password are not empty. Then you can check the entries content and if none is empty then set the "Login" to be sensitive.
From the Python API - Gtk.Widget set_sensitive method:
Sets the sensitivity of a widget. A widget is sensitive if the user can interact with it. Insensitive widgets are “grayed out” and the user can’t interact with them. Insensitive widgets are known as “inactive”, “disabled”, or “ghosted” in some other toolkits.
Upvotes: 1
Reputation: 3745
You have to pack the button in a EventBox.
e_b = Gtk.Eventbox()
button = Gtk.Button()
e_b.add(button)
e_b.set_above_child(True) #necessary for event handling
e_b.connect("button-press-event", do_anything)
However, it makes me wonder what you are trying to do. See @JoseFonte answer.
Upvotes: 2