I am trying to build a virtualized grid container to display 100k+ files in PyGTK 4 on Fedora 35. I succeeded in creating the layout and scrolling support which works beautifully.
In order to support resizing of my application window, I need to react to changes its size. I already connected to the notify
signal of the window and handle the default-width
, default-height
, maximized
and unmaximized
events to update the geometry of my layout. However, everytime I invoke get_width()
of my widget/app window after the maximized
event I only get the width before the window was maximized! Is this by design?
I've been trying pretty hard but I fail to come to a working solution for this simple problem. Can anyone help me?
Edit
Here is some code to outline how I am trying to measure the window size. I modified the code to use connect_after
instead of connect
as proposed by @GüntherWagner. However, the behavior is the same for both methods:
class TestLayout(Gtk.ScrolledWindow):
def on_realize(self, widget):
...
self.get_root().connect_after('notify', self.on_notify)
def on_notify(self, widget, param):
if param.name in [..., 'maximized', 'unmaximized']:
self.draw()
def draw(self):
self.width = self.get_width()
self.height = self.get_height()