Example #1
0
    def ValidationAndResult(self):
        try:

            if str(self.lineEditWeight.text()) =="" and str(self.lineEditHeight.text()) =="":
                QMessageBox.warning(QMessageBox(), 'Cannot Calculate!', "No data was detected. Please fill in the textbox.", QMessageBox.Ok)

            elif str(self.lineEditWeight.text()) =="" and str(self.lineEditHeight.text()) !="":
                QMessageBox.warning(QMessageBox(), 'Cannot Calculate!', "No value for weight was entered. Please enter weight.", QMessageBox.Ok)

            elif str(self.lineEditWeight.text()) =="" and str(self.lineEditHeight.text()) !="":
                QMessageBox.warning(QMessageBox(), 'Cannot Calculate!', "No value for weight was entered. Please enter Height ", QMessageBox.Ok)

            else:
                weight = float(int(self.lineEditWeight.text()) )
                height = float(int(self.lineEditHeight.text()) )

                result = weight / (height * height) * 703
                SQLStatements.changeBmi(result,self.userID)


                if ((result)) < 18.5: QMessageBox.information(QMessageBox(), 'Result', "Your BMI result is: " + str('%.2f' %(result)) + "\n Weight Category: Underweight", QMessageBox.Ok)


                elif ((result)) < 25 and ((result)) >= 18.5: QMessageBox.information(QMessageBox(), 'Result', "Your BMI result is: " + str('%.2f' %(result)) + "\n Weight Category: Healthy weight", QMessageBox.Ok)

                elif ((result)) < 30 and ((result)) >= 25: QMessageBox.information(QMessageBox(), 'Result', "Your BMI result is: " + str('%.2f' %(result)) + "\n Weight Category: Overweight", QMessageBox.Ok)

                else:
                    QMessageBox.information(QMessageBox(), 'Result', "Your BMI result is: " + str('%.2f' %(result)) + "\n Category: Obese", QMessageBox.Ok)

        except Exception as e:
            print(e)