Gtk.Entry: how to trigger the do_focus_out_event() (or any event in general)
I would like to remove the blinking cursor from an entry field after the user hits the
I think the correct way is to trigger the focus-out event.
This is a sample code. I have tried many variations and also sistematically searched the Internet but I couldn't find a solution.
class MySoftware(Gtk.Window): def __init__(self): # Create a new window ... entryField.connect("activate", self.on_entry_activated) #This function is called when the user hits the "Enter" key in the entry widget def on_entry_activated(self, entry): entryContent = entry.get_text() ... # Here I would like to trigger the focus-out event event = Gdk.EventFocus() event.window = entry.get_window() event.send_event = True event.type = Gdk.EventType.FOCUS_CHANGE event.in_ = False entry.do_focus_out_event(self, event) win = MySoftware() win.connect("destroy", Gtk.main_quit) win.show_all() Gtk.main()
This particular code triggers a segmentation fault error. Other variations of this code return a type error ("... expected
P.s. StackOverflow question: https://stackoverflow.com/questions/61562241/python-gtk-3-pygtk-3-manually-trigger-an-event