# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'myinterface.ui' # # Created by: PyQt5 UI code generator 4.11.4 # # WARNING! All changes made in this file will be lost! from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QDesktopWidget from PyQt5.QtGui import QIcon from PyQt5.QtCore import QCoreApplication try: _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: def _fromUtf8(s): return s try: _encoding = QtGui.QApplication.UnicodeUTF8 def _translate(context, text, disambig): return QtGui.QApplication.translate(context, text, disambig, _encoding) except AttributeError: def _translate(context, text, disambig): return QtGui.QApplication.translate(context, text, disambig) class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) MainWindow.resize(632, 480) self.centralwidget = QtGui.QWidget(MainWindow) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.label = QtGui.QLabel(self.centralwidget) self.label.setGeometry(QtCore.QRect(10, 10, 131, 17)) self.label.setObjectName(_fromUtf8("label")) self.lineEdit = QtGui.QLineEdit(self.centralwidget) self.lineEdit.setGeometry(QtCore.QRect(140, 7, 113, 24)) self.lineEdit.setObjectName(_fromUtf8("lineEdit")) self.label_2 = QtGui.QLabel(self.centralwidget) self.label_2.setGeometry(QtCore.QRect(10, 40, 68, 17)) self.label_2.setObjectName(_fromUtf8("label_2")) self.lineEdit_2 = QtGui.QLineEdit(self.centralwidget) self.lineEdit_2.setGeometry(QtCore.QRect(80, 40, 113, 24)) self.lineEdit_2.setObjectName(_fromUtf8("lineEdit_2")) self.label_3 = QtGui.QLabel(self.centralwidget) self.label_3.setGeometry(QtCore.QRect(10, 70, 171, 17)) self.label_3.setObjectName(_fromUtf8("label_3")) self.lineEdit_3 = QtGui.QLineEdit(self.centralwidget) self.lineEdit_3.setGeometry(QtCore.QRect(180, 70, 113, 24)) self.lineEdit_3.setObjectName(_fromUtf8("lineEdit_3")) self.label_4 = QtGui.QLabel(self.centralwidget) self.label_4.setGeometry(QtCore.QRect(10, 100, 231, 17)) self.label_4.setObjectName(_fromUtf8("label_4")) self.lineEdit_4 = QtGui.QLineEdit(self.centralwidget) self.lineEdit_4.setGeometry(QtCore.QRect(250, 100, 113, 24)) self.lineEdit_4.setObjectName(_fromUtf8("lineEdit_4")) self.label_5 = QtGui.QLabel(self.centralwidget) self.label_5.setGeometry(QtCore.QRect(260, 150, 101, 17)) self.label_5.setObjectName(_fromUtf8("label_5")) self.lineEdit_5 = QtGui.QLineEdit(self.centralwidget) self.lineEdit_5.setGeometry(QtCore.QRect(10, 170, 611, 211)) self.lineEdit_5.setObjectName(_fromUtf8("lineEdit_5")) self.pushButton = QtGui.QPushButton(self.centralwidget) self.pushButton.setGeometry(QtCore.QRect(520, 400, 99, 27)) self.pushButton.setObjectName(_fromUtf8("pushButton")) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 632, 25)) self.menubar.setObjectName(_fromUtf8("menubar")) MainWindow.setMenuBar(self.menubar) self.statusbar = QtGui.QStatusBar(MainWindow) self.statusbar.setObjectName(_fromUtf8("statusbar")) MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) self.pushButton.clicked.connect(self.myFunction) def retranslateUi(self, MainWindow): MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None)) self.label.setText(_translate("MainWindow", "Сумма внесения:", None)) self.label_2.setText(_translate("MainWindow", "Процент:", None)) self.label_3.setText(_translate("MainWindow", "Интервал начислений:", None)) self.label_4.setText(_translate("MainWindow", "Срок вклада(указать в месяцах):", None)) self.label_5.setText(_translate("MainWindow", "Начисления:", None)) self.pushButton.setText(_translate("MainWindow", "Вычислить", None)) def MyFunction(self): self.a = int(input(self.lineEdit.text())) self.b = float(input(self.lineEdit_2.text())) self.c = int(input(self.lineEdit_3.text())) self.d = int(input(self.lineEdit_4.text())) i=0 if d < c: lineEdit_5=('Начислений нет, сумма за неполный период= '+str(a)) elif d >= c: e = a n = d / c # Сколько раз будет происходить начисление процентов за весь срок содержания суммы while i < n: # Лимит e += (a * b / 100);i += 1 # Начисление процентов lineEdit_5 = ('Сумма за ' + str(i) + ' начисление = ' + str(e)+' руб.') # Вывод if i == n: tlineEdit_5 = ('Разница "внесение-начисление"= ' + str(int(e - a)) + ' руб.') if __name__ == "__main__": import sys app = QtWidgets.QApplication(sys.argv) MainWindow = QtWidgets.QMainWindow() ui = Ui_MainWindow() ui.setupUi(MainWindow) MainWindow.show() sys.exit(app.exec_())
Эта часть разве не должна генерироваться сама? скопипастил ее
if __name__ == “__main__”:
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
И в результате выдает такие ошибки:
line 9, in <module>
from PyQt5 import QtCore, QtGui, QtWidgets
ImportError: /usr/local/lib/python3.5/dist-packages/PyQt5/QtCore.so: invalid ELF header
line 10, in <module>
from PyQt5.QtWidgets import QApplication
ImportError: /usr/local/lib/python3.5/dist-packages/PyQt5/QtWidgets.so: invalid ELF header
line 26, in <module>
class Ui_MainWindow(object):
line 107, in Ui_MainWindow
app = QtWidgets.QApplication(sys.argv)
NameError: name ‘QtWidgets’ is not defined
Пмогите разобраться пожалуйста!
Заранее спасибо.