dyskette
(Eddy Castillo)
April 1, 2024, 9:36pm
1
I’m trying to use MenuButton’s activate event to do something in pygobject, but my code is not executed. I’m wondering if I’m missing something.
gtk4
version is 4.12.5-1.fc39
in Fedora 39
pygobject
version is 3.48.1
from pypi
def button_activated(_button):
print("Button activated")
btn = Gtk.MenuButton(label="test")
btn.set_popover(Gtk.Popover())
btn.connect("activate", button_activated)
ebassi
(Emmanuele Bassi)
April 1, 2024, 9:44pm
2
The “activate” signal is emitted when a widget is activated—the user pressed Return , or something called Gtk.Widget.activate()
.
dyskette
(Eddy Castillo)
April 1, 2024, 10:08pm
3
Gotcha, my expectation of a click emitting the activate signal was wrong then. I’m going to use ‘notify::active’ now instead… I just wanted to do something when the popup opens.
Quick question. SpinButton only has the ‘activate’ signal since GTK 4.14. How would I do the “do something when pressing enter” before that version?
ebassi
(Emmanuele Bassi)
April 1, 2024, 10:10pm
4
You’d have to add an EventControllerKey, add set it to handle the capture phase, so you get the Enter key before the widget.
dyskette
(Eddy Castillo)
April 1, 2024, 10:13pm
5
Cool, I’ll try that. Hey, thank you.
system
(system)
Closed
May 1, 2024, 10:13pm
6
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.