Custom widgets using PyQt 2004-03-28 15:52 A short tutorial explaining how to create reusable widgets using PyQt. taj / 2006-04-03 06:38: Nice tutorial. I have one somewhat-related gripe, though, and that is pyuic.A dynamic language like python should be dealing with UI files dynamically, and pyuic doesn't quite fit into that philosophy. At the moment, PyQt doesn't seem to implement QWidgetFactory. But since that creates QWidget objects rather than subclasses, its not the ideal solution either.Now that python provides a much nicer way to create types etc on the fly, a better system would be to dynamically load UI files as modules. Then the module user can dynamically instantiate them at runtime, or import (using an import hook) and subclass them as one does with the current pyuic generated classes.I might have a go at implementing this over the weekend. Peter Gordon / 2006-04-03 06:39: Roberto,Your tutorials are great and I hope you will have more. It is great way to learn Roberto Alsina / 2006-04-03 06:39: Well, if you can make that work, I will fedex you a beer :-) jmoiron / 2006-04-03 06:42: Your live action tutorial was great and this one is just as informative. The first comment seems to be describing the behavior gtk's "libglade"; but I actually prefer the way pyuic does things, since it means that I can have my program's structure in precompiled byte code instead of being parsed and hacked together at run time. G_os / 2006-04-03 06:42: Hi,Thanks a lot. Great to learn :) Both python and qtdesignerG_os taj / 2006-04-03 06:44: jmoiron,Yeah libglade does that, as does designer via the QWidgetFactory interface. I can understand the desire to have stuff precompiled and ready to run, but I personally don't like the intermediate build step. To me it goes against the python idea of not having a build step before running the code.Incidentally, I was wrong about QWidgetFactory not being implemented by PyQt. It is available in the qtui module. Roberto Alsina / 2006-04-03 06:44: But... QWidgetFactory only would work well if there was a way to write a QWidgetPlugin.Or if your app only uses standard widgets. Which I seem unable to limit myself to :-)Being able to create custom gadgetry easily is one of the greatest things about Qt. ItÂ´s even easier in PyQt. But it does break QWidgetFactory :-POne other solution is to use another design pattern, and write a class that manages a group of widgets while not being itself a widget. You can even do event overriding (on PyQt, not on Qt), but I find the code ugly. Useful! But ugly.