Python 重量计算器
我想在qt designer中创建一个重量计算器,我想在上面添加一些功能,但我不能,请您检查一下 这是我的主页ui代码: 我的ui文件: 我想在上面添加一些功能:Python 重量计算器,python,pyqt,pyqt5,qt-designer,Python,Pyqt,Pyqt5,Qt Designer,我想在qt designer中创建一个重量计算器,我想在上面添加一些功能,但我不能,请您检查一下 这是我的主页ui代码: 我的ui文件: 我想在上面添加一些功能: gender=input("If Man, please type M or if women type W: ") heigh=int(input("Whats your heigh: ")) if(gender=="M"): r=int(((heigh*4/2.54)-128)*0.453) print("Your
gender=input("If Man, please type M or if women type W: ")
heigh=int(input("Whats your heigh: "))
if(gender=="M"):
r=int(((heigh*4/2.54)-128)*0.453)
print("Your ideal weight: " + str(r))
elif(gender=="W"):
r=int(((heigh*3.5/2.54)-108)*0.453)
print("Your ideal weight: "+str(r))
用户在第一个文本框中键入性别(M或W),在第二个文本框中键入高度,当单击结果按钮时,我们可以在最后一个框中看到result(恢复高度)是的,我找到了,很简单:)
你尝试了什么,什么不起作用?请看一下以下指南:
gender=input("If Man, please type M or if women type W: ")
heigh=int(input("Whats your heigh: "))
if(gender=="M"):
r=int(((heigh*4/2.54)-128)*0.453)
print("Your ideal weight: " + str(r))
elif(gender=="W"):
r=int(((heigh*3.5/2.54)-108)*0.453)
print("Your ideal weight: "+str(r))
import sys
from PyQt5.QtCore import pyqtSlot
from PyQt5.QtWidgets import QApplication, QDialog
from PyQt5.uic import loadUi
class MainPage(QDialog):
def __init__(self):
super(MainPage, self).__init__()
loadUi('HomePage.ui', self)
self.pushButton.clicked.connect(self.takeText)
self.fillCombobox()
def fillCombobox(self):
gender = ["M", "W"]
self.comboBox.addItems(gender)
def takeText(self):
gender = self.comboBox.currentText()
heigh = int(self.plainTextEdit.toPlainText())
if gender == "M":
r = int(((heigh * 4 / 2.54) - 128) * 0.453)
elif gender == "W":
r = int(((heigh * 3.5 / 2.54) - 108) * 0.453)
self.textEdit.setText(str(r))
if __name__ == "__main__":
app=QApplication(sys.argv)
widget=MainPage()
widget.show()
sys.exit(app.exec_())