== Why? == PyQt is the best GUI development kit there is. You can't beat the syntax, and the performance is pretty damned good. I would use this page as a starting point for anyone making important decisions regarding their development environment. It is my opinion that no one can offord compilation overhead when writing graphical interfaces. It is faster to write interface code with pyqt, and easier to write *more reliable code*. Check out the pksampler archive for examples. == Tools == * Generic pixmap widgets: [https://svn.patrickkidd.com/repos_old/pk/gui/pixmapwidgets.py] * PKPovGUI: Render you pyqt widgets with povray! * Embed puxmaps in a python module: $ pyuic -embed * PK Widget demo (Very Cool!) [https://svn.patrickkidd.com/repos_old/bin/pkdemo] == How Does it Work? == The code says it all. ([https://svn.patrickkidd.com/pyqt_demo.tgz Download the demo]) {{{ #!python """ A pixmap widget to show the power and flexibility of python and Qt used together. This widget was torn from pk.gui.pixmapwidgets to make a simple demo pixmap widget that is easy to understand on the first read. """ from qt import * import pixmaps class DemoWidget(QWidget): """ Loads all the pixmaps in a directory, and controls the drawing. """ cache = {} def __init__(self, parent=None, name=None, f=0): QWidget.__init__(self, parent, name, f) self.widgetname = 'mixerslider' self.cacheName(self.widgetname, pixmaps) data = self.get(self.widgetname) self.setFixedSize(data.items()[0][1].size()) self.setPixmap(0) ## FROM pk.gui.pixmapwidgets.PixmapCache def cacheName(self, name, embedded_pixmaps): """ Cache all pixmaps for a chosen prefix """ if self.get(name, None) is None: pixmaps = {} for entry in embedded_pixmaps.embed_image_vec: fn = entry[8] if fn.startswith(name): label = fn[len(name):fn.rfind('.')] i = embedded_pixmaps.uic_findImage(fn) p = QPixmap(i) if not p.isNull(): pixmaps[label] = p self.cache[name] = pixmaps def get(self, *kwds): return self.cache.get(*kwds) ## FROM pk.gui.pixmapwidgets.PixmapWidget def _setPixmap(self, label): """ Set the pixmap corresponding to label. 'label' can be a number, malformed string, or whatever. """ entry = self.get(self.widgetname) try_label = str(label) try: p = entry[try_label] except KeyError: try_label = str(label).zfill(10) try: p = entry[try_label] except KeyError: return self.setPaletteBackgroundPixmap(p) ## FROM pk.gui.pixmapwidgets.PixmapRangeControl def paintEvent(self, e): """ Don't draw that bloody stuff. """ pass def mouseReleaseEvent(self, e): pass def mousePressEvent(self, e): margin = 5 if e.y() > self.height() - margin: v = 127 elif e.y() < margin: v = 0 else: v = (((e.y()-15)* 1.0) / (self.height() - 30)) * 127 self.setPixmap(v) def mouseMoveEvent(self, e): self.mousePressEvent(e) def wheelEvent(self, e): v = self.value() + e.delta() self.setPixmap(v) def setPixmap(self, value): """ set the current pixmap. """ new_val = int(value) value = self.value = new_val if value < 0: value = 0 elif value > 127: value = 127 value = str((127 - 0) - value) self._setPixmap(value) import sys from qt import * a = QApplication(sys.argv) w = DemoWidget() w.show() a.setMainWidget(w) a.exec_loop() }}} Used in conjunction with an asynchronous communication toolkit like gstreamer or CORBA, PyQT can be used to make high-performance real-time applications, too!