Issue
I want two numbers to be entered and one divided by the other and at the end the quotient is output to QPlainTextEdit, but I can' t do it right. here is a problematic piece of code
def electrovolnyshablon():
global ElectroVolSh
ElectroVolSh = QtWidgets.QMainWindow()
uie = ElectroVolni()
uie.ShablonElectro(ElectroVolSh)
ElectroVolSh.show()
MainElectric.hide()
uie.lineEdit_2.setPlaceholderText('Указывайте в метрах (м)')
uie.lineEdit.setPlaceholderText("Указывайте в м/c")
def nazadlzadacham():
MainElectric.show()
ElectroVolSh.hide()
#############specifically here########################
def obrabotka():
dlinavolni = int(uie.lineEdit_2.text())
skorc = int(uie.lineEdit.text())
otvett = dlinavolni / skorc
#if not skorc:
# otvett = dlinavolni / 300000000
#else:
# skorc1 = int(skorc)
# otvett = dlinavolni / skorc1
uie.plainTextEdit.setText(str(otvett))
uie.pushButton.clicked.connect(obrabotka)
uie.pushButton_3.clicked.connect(nazadlzadacham)
Solution
First, the text should be output via setPlainText, that is, it should look like this: uie.plainTextEdit.setPlainText(str(otvett))
Secondly, you need to convert to int after checking for an empty input.
Answered By - lobzinc
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.