Ich muss eine GUI für ein Projekt machen, an dem ich arbeite. Da ich kein Programmierer bin, entschuldige bitte meine Frage.Wie initialisiert man Python-Code aus dem Qt-Designer
Ich habe die GUI mit Qt-Designer erstellt. Ich habe auch die .ui Datei erfolgreich kompiliert .py
from PySide import QtCore, QtGui
class Ui_Mesher(object):
def setupUi(self, Mesher):
Mesher.setObjectName("Mesher")
Mesher.resize(480, 555)
self.pushButton = QtGui.QPushButton(Mesher)
self.pushButton.setGeometry(QtCore.QRect(130, 510, 101, 23))
self.pushButton.setObjectName("pushButton")
self.pushButton_2 = QtGui.QPushButton(Mesher)
self.pushButton_2.setGeometry(QtCore.QRect(240, 510, 101, 23))
self.pushButton_2.setObjectName("pushButton_2")
self.pushButton_3 = QtGui.QPushButton(Mesher)
self.pushButton_3.setGeometry(QtCore.QRect(320, 450, 75, 23))
self.pushButton_3.setObjectName("pushButton_3")
self.comboBox = QtGui.QComboBox(Mesher)
self.comboBox.setGeometry(QtCore.QRect(10, 450, 131, 22))
self.comboBox.setAcceptDrops(False)
self.comboBox.setObjectName("comboBox")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.comboBox.addItem("")
self.groupBox = QtGui.QGroupBox(Mesher)
self.groupBox.setGeometry(QtCore.QRect(10, 10, 461, 351))
self.groupBox.setObjectName("groupBox")
self.add_coordinates_button = QtGui.QPushButton(self.groupBox)
self.add_coordinates_button.setGeometry(QtCore.QRect(190, 100, 51, 41))
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap("../../Icons/green-right-arrow-clip-art-6842.jpg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.add_coordinates_button.setIcon(icon)
self.add_coordinates_button.setObjectName("add_coordinates_button")
self.list_coordinates = QtGui.QListWidget(self.groupBox)
self.list_coordinates.setGeometry(QtCore.QRect(280, 20, 161, 192))
self.list_coordinates.setObjectName("list_coordinates")
self.input_x_coordinate = QtGui.QLineEdit(self.groupBox)
self.input_x_coordinate.setGeometry(QtCore.QRect(40, 110, 51, 20))
self.input_x_coordinate.setObjectName("input_x_coordinate")
self.input_y_coordinate = QtGui.QLineEdit(self.groupBox)
self.input_y_coordinate.setGeometry(QtCore.QRect(100, 110, 51, 20))
self.input_y_coordinate.setObjectName("input_y_coordinate")
self.retranslateUi(Mesher)
QtCore.QMetaObject.connectSlotsByName(Mesher)
def retranslateUi(self, Mesher):
Mesher.setWindowTitle(QtGui.QApplication.translate("Mesher", "Mesher", None, QtGui.QApplication.UnicodeUTF8))
self.pushButton.setText(QtGui.QApplication.translate("Mesher", "Save Changes", None, QtGui.QApplication.UnicodeUTF8))
self.pushButton_2.setText(QtGui.QApplication.translate("Mesher", "Exit", None, QtGui.QApplication.UnicodeUTF8))
self.pushButton_3.setText(QtGui.QApplication.translate("Mesher", "Import", None, QtGui.QApplication.UnicodeUTF8))
self.comboBox.setItemText(0, QtGui.QApplication.translate("Mesher", "Engrid", None, QtGui.QApplication.UnicodeUTF8))
self.comboBox.setItemText(1, QtGui.QApplication.translate("Mesher", "Gmsh", None, QtGui.QApplication.UnicodeUTF8))
self.comboBox.setItemText(2, QtGui.QApplication.translate("Mesher", "Salome", None, QtGui.QApplication.UnicodeUTF8))
self.comboBox.setItemText(3, QtGui.QApplication.translate("Mesher", "Abaqus", None, QtGui.QApplication.UnicodeUTF8))
self.comboBox.setItemText(4, QtGui.QApplication.translate("Mesher", "Ansys", None, QtGui.QApplication.UnicodeUTF8))
self.groupBox.setTitle(QtGui.QApplication.translate("Mesher", "EzMesher", None, QtGui.QApplication.UnicodeUTF8))
self.add_coordinates_button.setText(QtGui.QApplication.translate("Mesher", "Create geometry", None, QtGui.QApplication.UnicodeUTF8))
Ui_Mesher()
Ich habe versucht, es in meinem Haupt-Datei wie zu initialisieren:
from PySide.QtCore import *
from PySide.QtGui import *
import sys
import Gui_mesh
class MainDialog(QDialog, Gui_mesh.Ui_mainDialog):
def __init__(self, parent = None):
super(MainDialog, self).__init__(parent)
self.setupUi(self)
app = QApplication(sys.argv)
form = MainDialog()
form.show()
app.exec_()
aber anscheinend kann ich nicht Ui_mainDialog verwenden. Ich hoffe ihr könnt mir helfen.
Grüße
Bitte Fehler Stack-Ablaufverfolgung. –
AttributeError: 'Modul' Objekt hat kein Attribut 'Ui_mainDialog' –