möchte mich in PyQt einarbeiten. Dazu habe ich im Designer ein Dialog-Fenster erstellt. Anschliessend habe ich die ui-Datei in eine py-Datei umgewandelt.
Code: Alles auswählen
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'untitled.ui'
#
# Created: Thu Jun 22 18:51:51 2017
# by: PyQt5 UI code generator 5.2.1
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(266, 116)
self.buttonBox = QtWidgets.QDialogButtonBox(Dialog)
self.buttonBox.setGeometry(QtCore.QRect(30, 80, 201, 28))
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox")
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(30, 20, 208, 22))
self.label.setScaledContents(True)
self.label.setObjectName("label")
self.retranslateUi(Dialog)
self.buttonBox.accepted.connect(Dialog.accept)
self.buttonBox.rejected.connect(Dialog.reject)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
Dialog.setToolTip(_translate("Dialog", "<html><head/><body><p><br/></p></body></html>"))
Dialog.setWhatsThis(_translate("Dialog", "<html><head/><body><p><br/></p></body></html>"))
self.label.setText(_translate("Dialog", "<html><head/><body><p><span style=\" font-size:14pt;\">Änderung übernehmen?</span></p></body></html>"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
Wie sieht es bei längerem Text aus, muss ich die Werte beim Dialog.resize und bei self.label.setGeometry händisch anpassen, oder gibt es da eine Lösung das Ganze automatisch zu Scallieren?
Grüße Nobuddy