How to implement a widget with a Bin interface, but internally using a Box or Grid


I’m trying to implement an own widget class. It should expose the interface for a Bin, i.e. it should allow me to add one child to it. Internally - in my idea at least - it will use a hierarchy of Box’es and/or Grid’s. It places the child widget that we got from the Bin interface somewhere there, but also some other buttons and stuff (created and driven internally, not coming through any public interface).

Does the idea make sense, or is it faulty? In the latter case, why? If it makes sense, what is the best way to do that? Obviously it’s not the way to go to just derive from Bin and Grid, since it makes all the internal Grid stuff public (and perhaps will lead to some hard conflicts), right?

I’m not entirely sure, but it looks like HeaderBar does somewhat similar things (I’d just be lost in understanding its source code for sure).

I’m using Gtk3 and Python/PyGObject.

In that case you can overwrite the public functions such as add, remove to do those specific to bin only. Also you should warn users in your documentation not to use any method that exposes the internals.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.