2010/12/8 Vladimir Rutsky <[email protected]>: > 2010/12/8 机械唯物主义 : linjunhalida <[email protected]> >> >> I download the example from pyside git repos, and don't find example for ui, >> is this kind of function still under development? >> >> 2010/12/8 机械唯物主义 : linjunhalida <[email protected]>: >> > hello, I used to write code like this in pyqt: >> > >> > form, base = uic.loadUiType("score.ui") >> > class ScoreDlg(QDialog, form): >> > def __init__(self): >> > super(ScoreDlg, self).__init__() >> > self.setupUi(self) >> > >> > and in pyside, I only found QUiLoader.load, it returns a widget >> > object, not a widget class. >> > >> > so, can pyside do this kind of work? >> > >> _______________________________________________ >> PySide mailing list >> [email protected] >> http://lists.openbossa.org/listinfo/pyside > > Hello, > > In PyQt I used this code for loading UI files: > > class SomeWidget(QtGui.QDockWidget): > def __init__(self, parent=None): > super(SomeWidget, self).__init__(parent) > > loadUi('some_widget.ui'), self) > > And when moving from PyQt to PySide I found implementation of loadUi > function with PySide posted by Tamás Bajusz at > http://www.mail-archive.com/[email protected]/msg00878.html : > > from PySide import QtCore > from PySide.QtUiTools import QUiLoader > > class MyQUiLoader(QUiLoader): > def __init__(self, baseinstance): > super(MyQUiLoader, self).__init__() > self.baseinstance = baseinstance > > def createWidget(self, className, parent=None, name=""): > widget = QUiLoader.createWidget(self, className, parent, name) > if parent is None: > return self.baseinstance > else: > setattr(self.baseinstance, name, widget) > return widget > > def loadUi(uifile, baseinstance=None): > loader = MyQUiLoader(baseinstance) > ui = loader.load(uifile) > QtCore.QMetaObject.connectSlotsByName(ui) > return ui > > Not sure is this a correct way but it works for me. I hope you find > this examples useful. > > Regards, > Vladimir Rutsky >
fantastic! now I can take full use of pyside now! Thanks! maybe this code can ship with pyside.. _______________________________________________ PySide mailing list [email protected] http://lists.openbossa.org/listinfo/pyside
