ich bin gerade dabei Python anhand eines Projektes zu lernen, welches später auch einen sinnvollen Zweck erfüllen soll. Darum wollte ich auch gleich mit einem GUI arbeiten und entschied mich füt PyQT.
Mit dem QtDesigner habe ich nun eine Oberfläche erstellt und diese pyuic4 auch umgewandelt. Problem ist das bei Ausführung des Scriptes folgende Fehlermeldung erscheint
Code: Alles auswählen
mdlg.show()
AttributeError: 'Ui_Dialog' object has no attribute 'show'
Code: Alles auswählen
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'test.ui'
#
# Created: Sun Nov 21 21:17:48 2010
# by: PyQt4 UI code generator 4.5.4
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(400, 300)
self.label = QtGui.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(20, 20, 46, 14))
self.label.setObjectName("label")
self.lineEdit = QtGui.QLineEdit(Dialog)
self.lineEdit.setGeometry(QtCore.QRect(20, 40, 113, 20))
self.lineEdit.setObjectName("lineEdit")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8))
self.label.setText(QtGui.QApplication.translate("Dialog", "TextLabel", None, QtGui.QApplication.UnicodeUTF8))
Code: Alles auswählen
import sys
Code: Alles auswählen
app = QtGui.QApplication(sys.argv)
mdlg = Ui_Dialog()
mdlg.show()
sys.exit(app.exec_())
Code: Alles auswählen
# -*- coding: utf-8 -*-
# gex.py
import sys
from PyQt4 import QtGui
from gexmaindialog import Ui_Dialog as Dlg
class MeinDialog(QtGui.QDialog, Dlg):
def __init__(self):
QtGui.QDialog.__init__(self)
self.setupUi(self)
app = QtGui.QApplication(sys.argv)
dialog = MeinDialog()
dialog.show()
sys.exit(app.exec_())
Code: Alles auswählen
Traceback (most recent call last):
File "C:\Users\Markus\Pythonprojekte\Gaussian\gex.py", line 7, in <module>
from gexmaindialog import Ui_Dialog as Dlg
File "C:\Python26\lib\site-packages\spyderlib\interpreter.py", line 47, in _import
result = self.builtin_import(name, globals, locals, fromlist, level)
ImportError: No module named gexmaindialog
Vielen Dank für eure Hilfe