Saturday, December 17, 2011

PyGTK - Collapsible Panels

Mwahahaha... last night I finally managed to coerce PyGTK into giving me collapsible panels that looked the way I wanted.



This took a bit of custom widget hacking, by clobbering together some standard widgets into a few layout managers, and overriding the show/hide methods (well, you can't really override them, but you can define a signal that gets fired after the default ones do, where you can than overwrite what the previous one did) so that they'd do the deeds.

It comes after having wasted a bit of time trying to figure out how to properly theme the builtin "Expander" widget. I've since given up on that approach, since it seems impossible to set the inactive background state, while it's all too happy to draw a lighter rectangle for the mouse-over state (but with no way to set that colour either). Trying to fiddle with the "styles" is just a bad-smelling worm-hole that is often quite fruitless, while many of the colour setting settings are often defunct decoys.

Argh! I know that the GTK guys tried to get all high and hippy fancy about accessibility and user-themability crap, but seriously. When your widget toolkit has buggy things such as combo-box lists showing up where the list is usually scroll half down the screen away from the mouse, or that release the mouse button while these are open just confirms+closes the popup (leading to situations where you hold down the LMB and try to scroll with another finger), you bloody well need to provide ways that people can tweak that without forcing their users to install a different theme OR to resort to rolling their own from scratch using GObject + Cairo. Gah!

Anyways, here's a little hierarchy of the widgets that went into this:

2 comments:

  1. Would be awesome if you can get a little example of the code.

    ReplyDelete
  2. https://sites.google.com/site/aligorith/collapsible_panel.py?attredirects=0&d=1

    ReplyDelete