Skip to content

Instantly share code, notes, and snippets.

@kissgyorgy
Created September 3, 2014 03:23
Show Gist options
  • Save kissgyorgy/b025e0ae23fe25cf2a61 to your computer and use it in GitHub Desktop.
Save kissgyorgy/b025e0ae23fe25cf2a61 to your computer and use it in GitHub Desktop.
PySide: Load mainwindow from UI file.
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_())
@internety
Copy link

`
Traceback (most recent call last):

File "_run.py", line 29, in

mainWindow = MainWindow()

File "_run.py", line 18, in new

super().__new__(cls, *args, **kwargs)

TypeError: super() takes at least 1 argument (0 given)
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment