ich Versuche gerade erstmals mit PySide6 eine GUI zu erstellen.
Dies hat so weit auch alles wunderbar funktioniert. Nur als ich nun den von PySide6-uic erstellten Quelltext in PyCharm eingefügt habe, bekomme ich 14 Warnings. Und es Passiert auch nichts.
Ich klicke auf RUN und alles läuft fehlerfrei durch, nur nichts passiert.
Hier der Quelltext:
Code: Alles auswählen
# -*- coding: utf-8 -*-
################################################################################
## Form generated from reading UI file 'hauptdialog.ui'
##
## Created by: Qt User Interface Compiler version 6.6.1
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
QMetaObject, QObject, QPoint, QRect,
QSize, QTime, QUrl, Qt)
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
QFont, QFontDatabase, QGradient, QIcon,
QImage, QKeySequence, QLinearGradient, QPainter,
QPalette, QPixmap, QRadialGradient, QTransform)
from PySide6.QtWidgets import (QApplication, QDialog, QGroupBox, QHBoxLayout,
QLabel, QLineEdit, QPushButton, QSizePolicy,
QSpacerItem, QVBoxLayout, QWidget)
class Ui_Hauptdialog(object):
def setupUi(self, Hauptdialog):
if not Hauptdialog.objectName():
Hauptdialog.setObjectName(u"Hauptdialog")
Hauptdialog.resize(400, 600)
self.verticalLayout_3 = QVBoxLayout(Hauptdialog)
self.verticalLayout_3.setObjectName(u"verticalLayout_3")
self.verticalLayout = QVBoxLayout()
self.verticalLayout.setObjectName(u"verticalLayout")
self.groupBox = QGroupBox(Hauptdialog)
self.groupBox.setObjectName(u"groupBox")
self.verticalLayout_2 = QVBoxLayout(self.groupBox)
self.verticalLayout_2.setObjectName(u"verticalLayout_2")
self.horizontalLayout_2 = QHBoxLayout()
self.horizontalLayout_2.setObjectName(u"horizontalLayout_2")
self.label = QLabel(self.groupBox)
self.label.setObjectName(u"label")
self.horizontalLayout_2.addWidget(self.label)
self.vorname = QLineEdit(self.groupBox)
self.vorname.setObjectName(u"vorname")
self.horizontalLayout_2.addWidget(self.vorname)
self.verticalLayout_2.addLayout(self.horizontalLayout_2)
self.horizontalLayout_3 = QHBoxLayout()
self.horizontalLayout_3.setObjectName(u"horizontalLayout_3")
self.label_2 = QLabel(self.groupBox)
self.label_2.setObjectName(u"label_2")
self.horizontalLayout_3.addWidget(self.label_2)
self.nachname = QLineEdit(self.groupBox)
self.nachname.setObjectName(u"nachname")
self.horizontalLayout_3.addWidget(self.nachname)
self.verticalLayout_2.addLayout(self.horizontalLayout_3)
self.verticalLayout.addWidget(self.groupBox)
self.groupBox_2 = QGroupBox(Hauptdialog)
self.groupBox_2.setObjectName(u"groupBox_2")
self.verticalLayout.addWidget(self.groupBox_2)
self.horizontalLayout = QHBoxLayout()
self.horizontalLayout.setObjectName(u"horizontalLayout")
self.horizontalSpacer = QSpacerItem(198, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
self.horizontalLayout.addItem(self.horizontalSpacer)
self.buttonOK = QPushButton(Hauptdialog)
self.buttonOK.setObjectName(u"buttonOK")
self.horizontalLayout.addWidget(self.buttonOK)
self.buttonAbbrechen = QPushButton(Hauptdialog)
self.buttonAbbrechen.setObjectName(u"buttonAbbrechen")
self.horizontalLayout.addWidget(self.buttonAbbrechen)
self.verticalLayout.addLayout(self.horizontalLayout)
self.verticalLayout_3.addLayout(self.verticalLayout)
self.retranslateUi(Hauptdialog)
self.buttonOK.setDefault(True)
QMetaObject.connectSlotsByName(Hauptdialog)
# setupUi
def retranslateUi(self, Hauptdialog):
Hauptdialog.setWindowTitle(QCoreApplication.translate("Hauptdialog", u"Dialog", None))
self.groupBox.setTitle(QCoreApplication.translate("Hauptdialog", u"Pers\u00f6nliche Daten", None))
self.label.setText(QCoreApplication.translate("Hauptdialog", u"Vorname", None))
self.label_2.setText(QCoreApplication.translate("Hauptdialog", u"Nachname", None))
self.groupBox_2.setTitle(QCoreApplication.translate("Hauptdialog", u"Weitere Angaben", None))
self.buttonOK.setText(QCoreApplication.translate("Hauptdialog", u"OK", None))
self.buttonAbbrechen.setText(QCoreApplication.translate("Hauptdialog", u"Abbrechen", None))
# retranslateUi
Code: Alles auswählen
import sys
from PySide6 import QtWidgets
from hauptdialog import Ui_Hauptdialog
class MeinDialog(QtWidgets.QDialog):
def __init__(self, parent=None):
super().__init__(parent)
self.ui = Ui_Hauptdialog()
self.ui.setupUi(self)
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
dialog = MeinDialog()
dialog.show()
sys.exit(app.exec())
Ich denke mal der erstellte Quelltext kann ja eigentlich nicht fehlerhaft sein. könnte es an einer Einstellung von PyCharm liegen?
Grüße Master_Shredder