I'm not sure I would call that a mixin -- really, all that's going on
is Python is allowing you to call any function, anywhere. In a
language like Scala that does have what I'd consider "real" mixins
(traits over there), then on_key_down would become a function
available in TableWidget's "namespace". (Not trying to make trouble
here, just a pedantic note on terminology -- I quite like Python.)
Anyway, it seems like all you need is to implement your
ArrowKeySelection functionality in one lib, and call its functions
from your UI widget's method implementations. There is the slight
detail of getting ArrowKeySelection's contribution to the widget's
state rolled in, but if you're using, say, a clojure map for your
widget's state (hopefully wrapped in a ref to keep those multithread
gremlins away), then it's easy enough to add an 'init' function to
ArrowKeySelection's namespace that will add the fields it requires to
any given map. Your widgets can then hook into that when they're
first initializing their state map.
- Chas