Invalid Object type 'AdwHeaderBar'

Hello there ! I was building a python-GTK app for a personal project and was using something like Cambalache to make a GTKXml definition for the interface.

However, when trying to build a template class (using a constructor), the only thing returned was “Invalid Object type ‘AdwHeaderBar’”, and the program crashes. Did I mess up something in the environment ?

Make sure that libadwaita is initialized before you create the class. If you use Adw.Application this should be handled for you automatically.

You mean something like this when talking about using Adw.Application ? I just want to be sure I don’t miss something in your explanation

You’re overriding startup to show the window: that’s wrong.

You need to override do_activate, not do_startup, to create and/or show the main application window; startup is called only once. Additionally, if you override do_startup() then you must chain up to the parent’s implementation. AdwApplication will initialise libadwaita inside the base class startup implementation.

2 Likes

It did work a lot better, thank you !