I'm trying to make a custom widget that resembles the "quick search" entry that Gtk uses on all TreeView-like widgets.
Here's a simplified example of my initial idea:
from gi.repository import Gtk
class QuickSearch(Gtk.Bin):
def __init__(self, *args, **kwargs):
super(QuickSearch, self).__init__(*args, **kwargs)
self.add(Gtk.Entry())
win = Gtk.Window()
win.connect("delete-event", Gtk.main_quit)
search = QuickSearch()
win.add(search)
win.show_all()
Gtk.main()
The problems are the following:
- If I use it alone, as in this example, there seems to be space allocated to the custom widget, but the
GtkEntryis not shown on the screen. I tried various combinations of properties on theGtkEntryand the custom widget (hexpand, vexpand, margins, aligns, etc) with no avail. - If combined with other widgets, when I interactively query for the widget allocated height, it aparently is 1. On the screen, the widget effectively doesn't appear (since it's somewhat "squashed" between the other widgets).
So, there's something I'm missing on the object initialization or how I'm using this custom widget? Is this a problem specific to GtkBin? I tried doing the same with a GtkBox and works flawlesly, but I think GtkBin is better suited for this particular widget.
Gtk.Entry? - ptomato