Also mit einem QDialog geht alles wunderbar. Nun habe ich mir ein Widget gebastelt (MainWindow).
Dann kompiliert.
Ich finde einfach keinen Fehler.
Code von PyQt in Root/GUI/Haupt.py:
Code: Alles auswählen
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'C:\Python\xEditor\GUI\Haupt.ui'
#
# Created: Thu Jun 12 21:37:57 2008
# by: PyQt4 UI code generator 4.4.2
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(749,600)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setGeometry(QtCore.QRect(0,21,749,560))
self.centralwidget.setObjectName("centralwidget")
self.Pad = QtGui.QTextEdit(self.centralwidget)
self.Pad.setGeometry(QtCore.QRect(10,10,721,531))
font = QtGui.QFont()
font.setFamily("Courier New")
font.setPointSize(10)
self.Pad.setFont(font)
self.Pad.setObjectName("Pad")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0,0,749,21))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setGeometry(QtCore.QRect(0,581,749,19))
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "xEditor", None, QtGui.QApplication.UnicodeUTF8))
Code: Alles auswählen
import sys
from PyQt4 import QtCore, QtGui
from GUI.Haupt import Ui_MainWindow as Fenster_Haupt
class Fenster(QtGui.QWidget, Fenster_Haupt):
def __init__(self):
QtGui.QWidget.__init__(self)
self.setupUi(self)
self.connect(self.Pad, QtCore.SIGNAL("textChanged()"), self.Pad_TextChanged)
def Pad_TextChanged(self):
print "Change"
App = QtGui.QApplication(sys.argv)
Dialog = Fenster()
Dialog.show()
sys.exit(App.exec_())
Code: Alles auswählen
Traceback (most recent call last):
File "C:\Python\xEditor\Test.py", line 16, in <module>
Dialog = Fenster()
File "C:\Python\xEditor\Test.py", line 8, in __init__
self.setupUi(self)
File "C:\Python\xEditor\GUI\Haupt.py", line 26, in setupUi
MainWindow.setCentralWidget(self.centralwidget)
AttributeError: setCentralWidget
~ Chris