def qimage_to_str( img, indent="" ): fd = io.StringIO() print(indent, img, file=fd) indent += " " print(indent, "Size:", img.width(), "x", img.height(), file=fd) print(indent, "Depth:", img.depth(), file=fd) print(indent, "Format", qimage_format(img.format()), file=fd) return fd.getvalue()
def loadui(fname, replace_class="QwtPlot"): """ Return Widget or Window class from QtDesigner ui file 'fname' The loadUiType function (PyQt4.uic) doesn't work correctly with guiqwt QtDesigner plugins because they don't inheritate from a PyQt4.QtGui object. """ uifile_text = open(fname).read().replace(replace_class, "QFrame") ui, base_class = uic.loadUiType(io.StringIO(uifile_text)) class Form(base_class, ui): def __init__(self, parent=None): super(Form, self).__init__(parent) self.setupUi(self) return Form
def compileui(fname, replace_class="QwtPlot"): uifile_text = open(fname).read().replace("QwtPlot", "QFrame") uic.compileUi(io.StringIO(uifile_text), open(fname.replace(".ui", "_ui.py"), 'w'), pyqt3_wrapper=True)