Three hours later, finally got this little bit of code working - which would have worked instantly, if I wasn't trying to fucking put it (this gallery of galleries) out into its own window rather than dumping it into a frame on the main app.
... which I was only doing, to test it quickly before integrating it into the UI.
Augh.