Created
September 3, 2014 03:23
-
-
Save kissgyorgy/b025e0ae23fe25cf2a61 to your computer and use it in GitHub Desktop.
PySide: Load mainwindow from UI file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from PySide.QtCore import QFile | |
from PySide.QtGui import QApplication, QMainWindow | |
from PySide.QtUiTools import QUiLoader | |
class MainWindow(QMainWindow): | |
def __new__(cls, *args, **kwargs): | |
"""Load widget from UI file.""" | |
super().__new__(cls, *args, **kwargs) | |
uifile = QFile('mainwindow.ui') | |
uifile.open(QFile.ReadOnly) | |
mainWindow = QUiLoader().load(uifile) | |
uifile.close() | |
return mainWindow | |
if __name__ == "__main__": | |
app = QApplication(sys.argv) | |
mainWindow = MainWindow() | |
mainWindow.show() | |
sys.exit(app.exec_()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
`
Traceback (most recent call last):
File "_run.py", line 29, in
File "_run.py", line 18, in new
TypeError: super() takes at least 1 argument (0 given)
`