示例#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)
示例#2
0
    def addUsersinfo(self):
        try:
            #take inputs as variables
            e = self.email
            pw = self.password
            pn = self.num
            fn = self.lineEditFirstName.text()
            sn = self.lineEditlastName.text()
            dateOfBirth = self.dateEdit.text()
            w = self.lineEditWeight.text()
            h = self.lineEditHeight.text()
            sw = w

            #if a user is added
            if (SQLStatements.addUserInfo(e, pw, pn, fn, sn, dateOfBirth, w, h,
                                          sw) == 'True'):

                #show message box and open login window
                QMessageBox.about(QMessageBox(), 'Success',
                                  'you have been added to the database.')
                self.openLoginWindow()
                #if it doesnt work
            elif (SQLStatements.addUserInfo(e, pw, pn, fn, sn, dateOfBirth, w,
                                            h, sw) == 'checkFailed'):
                #show message box
                QMessageBox.warning(QMessageBox(), 'Error', 'Email exists')
                #reopen sign in window
                self.openSignInWindow()

            else:
                QMessageBox.warning(QMessageBox(), 'Error',
                                    'Could not add you to the database.')

        except Exception as e:
            print(e)
示例#3
0
    def login(self):
        try:
            #taking inputs as variables
            email = self.lineEditEmail.text()
            passwordInput = self.lineEditPassword.text()
            passwordInput = ("('"+passwordInput+"',)")

            if (SQLStatements.getUserID(email) == "NoUser"):
                #if a user doesnt exist send a message box
                QMessageBox.warning(QMessageBox(), 'Error', 'User does not exist!')


            else:
                #taking inputs as variables
                userID = SQLStatements.getUserID(email)
                passwordCheck = SQLStatements.checkPassword(userID)
                passwordCheckString = str(passwordCheck)

                #if passwords do not match
                if (passwordInput != passwordCheckString):
                    #tell user
                    QMessageBox.warning(QMessageBox(), 'Error', 'Password incorrect!')
                else:
                    #open progress window
                    self.openProgressWindow(userID)

        except Exception as e:
            print(e)
示例#4
0
    def loadCurrentWeight(self):
        currentweight = SQLStatements.getCurrentWeight(self.userID)
        self.labelCurrentWeight.setText(str(currentweight))

        if (SQLStatements.usersStartingweightValidation(self.userID) == False):
            startingweight = SQLStatements.getStartingWeight(self.userID)
            print(startingweight)
            SQLStatements.addWeightChange(self.userID, startingweight)
示例#5
0
    def showImage(self):
        image = SQLStatements.showImage(self.userID)

        pixmap = QtGui.QPixmap()
        pixmap.loadFromData(image, 'jpg')
        pixmap5 = pixmap.scaled(120, 120)

        self.labelPhoto.setPixmap(pixmap5)
示例#6
0
    def loadExerciseData(self):
        try:
            Date = self.dateEdit.date().toString(QtCore.Qt.ISODate)
            result = SQLStatements.getExerciseInfo(self.userID,Date)
            self.tableWidgetExercise.setRowCount(0)
            self.tableWidgetExercise.setHorizontalHeaderLabels(['Exercise', 'Calories lost'])
            for row_number, row_data in enumerate(result):
                    self.tableWidgetExercise.insertRow(row_number)
                    for column_number, data in enumerate(row_data):
                            self.tableWidgetExercise.setItem(row_number, column_number,
                                                             QtWidgets.QTableWidgetItem(str(data)))

            data = SQLStatements.getTotalExerciseCalories(self.userID)
            tot = 0
            for row in data:
                tot += row[0]
            self.labelExerciseValue.setText(str(tot))
        except Exception as e: print(e)
示例#7
0
    def AddImage(self):

        fileName = QtWidgets.QFileDialog.getOpenFileName()
        path = fileName[0]

        with open(path, "rb") as f:
            data = f.read()

        SQLStatements.AddImage(data, self.userID)
        self.showImage()
示例#8
0
    def test_get_namespaces(self):
        """ test get namespaces - This will change over time :-("""
	err, res, msg  = self.query(SQLStatements.sql_get_namespaces())
        correct = (
          {'namespace_version': 'GEMET - Concepts, version 2.3, 2009-07-13', 'namespace_id': 1L, 'namespace_uri': 'http://www.eionet.europa.eu/gemet/concept/', 'namespace_type': 'http://www.w3.org/2004/02/skos/core#Concept', 'namespace_name': 'Concepts'},
          {'namespace_version': 'GEMET - Super groups, version 2.3, 2009-07-13', 'namespace_id': 2L, 'namespace_uri': 'http://www.eionet.europa.eu/gemet/supergroup/', 'namespace_type': 'http://www.eionet.europa.eu/gemet/2004/06/gemet-schema.rdf#SuperGroup', 'namespace_name': ''},
          {'namespace_version': 'GEMET - Groups, version 2.3, 2009-07-13', 'namespace_id': 3L, 'namespace_uri': 'http://www.eionet.europa.eu/gemet/group/', 'namespace_type': 'http://www.eionet.europa.eu/gemet/2004/06/gemet-schema.rdf#Group', 'namespace_name': 'Groups'},
          {'namespace_version': 'GEMET - Themes, version 2.3, 2009-07-13', 'namespace_id': 4L, 'namespace_uri': 'http://www.eionet.europa.eu/gemet/theme/', 'namespace_type': 'http://www.eionet.europa.eu/gemet/2004/06/gemet-schema.rdf#Theme', 'namespace_name': 'Themes'},
          {'namespace_version': 'GEMET - INSPIRE themes, version 1.0, 2008-06-01', 'namespace_id': 5L, 'namespace_uri': 'http://inspire.jrc.it/theme/', 'namespace_type': '', 'namespace_name': 'Inspire Themes'},
          {'namespace_version': 'Version 0.1', 'namespace_id': 6L, 'namespace_uri': 'http://en.wikipedia.org/wiki/Names_of_European_cities_in_different_languages#', 'namespace_type': '', 'namespace_name': 'European Cities'}
        )
示例#9
0
    def loadBreakfastData(self):
            try:
                # imput data from db into table
                    Date = self.dateEdit.date().toString(QtCore.Qt.ISODate)
                    result = SQLStatements.getBreakfastInfo(self.userID,Date)
                    self.tableWidgetBreakfast.setRowCount(0)
                    self.tableWidgetBreakfast.setHorizontalHeaderLabels(['Food', 'Calories', 'Grams'])
                    for row_number, row_data in enumerate(result):
                            self.tableWidgetBreakfast.insertRow(row_number)
                            for column_number, data in enumerate(row_data):
                                    self.tableWidgetBreakfast.setItem(row_number, column_number,
                                                             QtWidgets.QTableWidgetItem(str(data)))
                    #set total calories amount
                    data = SQLStatements.getTotalBreakfastCalories(self.userID,Date)
                    tot = 0
                    for row in data:
                        tot += row[0]
                    self.labelBreakfastValue.setText(str(tot))

            except Exception as e:
                    print(e)
    def addToDb(self):
        try:
            # Adding variable names to the text boxes on add information windows
            weight = self.ui.lineEditFood.text()
          
            # Stores the user ID as a variable and removes the excess string
            UserID = self.userID
            UserID = str(UserID)
            UserID = (UserID.replace("(", ""))
            UserID = (UserID.replace(")", ""))
            UserID = (UserID.replace(",", ""))
            # Validation Check.
            if (SQLStatements.updateWeight(weight, UserID) == 'True'):
                SQLStatements.addWeightChange(UserID, weight)
                QMessageBox.about(QMessageBox(), 'Success', 'added to the database.')
            else:
                QMessageBox.warning(QMessageBox(), 'Error', 'Could not be added')



        except Exception as e:
            print(e)
示例#11
0
    def test_get_concept_languages(self):
        """ test get languages for concept 7 in namespace 1"""
	err, res, msg  = self.query(SQLStatements.sql_get_concept_languages(1, 7))
        correct = (
          {'langcode': 'ar'}, {'langcode': 'bg'}, {'langcode': 'cs'}, {'langcode': 'da'},
          {'langcode': 'de'}, {'langcode': 'el'}, {'langcode': 'en'}, {'langcode': 'en-US'},
          {'langcode': 'es'}, {'langcode': 'et'}, {'langcode': 'eu'}, {'langcode': 'fi'},
          {'langcode': 'fr'}, {'langcode': 'ga'}, {'langcode': 'hu'}, {'langcode': 'it'},
          {'langcode': 'lt'}, {'langcode': 'lv'}, {'langcode': 'mt'}, {'langcode': 'nl'},
          {'langcode': 'no'}, {'langcode': 'pl'}, {'langcode': 'pt'}, {'langcode': 'ro'},
          {'langcode': 'ru'}, {'langcode': 'sk'}, {'langcode': 'sl'}, {'langcode': 'sv'}
        )
        self.assertEquals(res, correct)
        def addToDb(self):
            try:
                #Adding variable names to the text boxes on add information windows
                FoodType = self.ui.lineEditFood.text()
                Calories = self.ui.lineEditCalories.text()
                Grams = self.ui.lineEditGrams.text()
                mealType = "Breakfast"
                #Stores the user ID as a variable and removes the excess string
                UserID = self.userID
                UserID = str(UserID)
                UserID= (UserID.replace("(",""))
                UserID = (UserID.replace(")", ""))
                UserID = (UserID.replace(",", ""))
                #Validation Check.
                if (SQLStatements.addFood(FoodType,Calories,Grams,mealType,UserID) == 'True'):
                    QMessageBox.about(QMessageBox(), 'Success', 'added to the database.')
                else:
                    QMessageBox.warning(QMessageBox(), 'Error', 'Could not be added')

            except Exception as e: print (e)
示例#13
0
 def test_get_properties_as_rdf(self):
     """ get rdf for concept 250"""
     err, res, msg  = self.query(SQLStatements.sql_get_properties_as_rdf(1, 250))
     correct = (
       {'langcode': '', 'is_resource': 1L, 'uri': 'http://www.w3.org/2004/02/skos/core#broader', 'value': 'http://www.eionet.europa.eu/gemet/concept/6817'},
       {'langcode': '', 'is_resource': 1L, 'uri': 'http://www.w3.org/2004/02/skos/core#broader', 'value': 'http://www.eionet.europa.eu/gemet/group/8575'},
       {'langcode': '', 'is_resource': 1L, 'uri': 'http://www.w3.org/2004/02/skos/core#broader', 'value': 'http://www.eionet.europa.eu/gemet/theme/7'},
       {'langcode': '', 'is_resource': 1L, 'uri': 'http://www.w3.org/2004/02/skos/core#broader', 'value': 'http://www.eionet.europa.eu/gemet/theme/33'},
       {'langcode': 'bg', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#definition', 'value': '\xd0\xa1\xd0\xb8\xd1\x81\xd1\x82\xd0\xb5\xd0\xbc\xd0\xb0 \xd0\xb8\xd0\xbb\xd0\xb8 \xd0\xbf\xd1\x80\xd0\xbe\xd1\x86\xd0\xb5\xd1\x81 \xd0\xb7\xd0\xb0 \xd0\xba\xd0\xbe\xd0\xbd\xd1\x82\xd1\x80\xd0\xbe\xd0\xbb\xd0\xb8\xd1\x80\xd0\xb0\xd0\xbd\xd0\xb5 \xd0\xbd\xd0\xb0 \xd1\x82\xd0\xb5\xd0\xbc\xd0\xbf\xd0\xb5\xd1\x80\xd0\xb0\xd1\x82\xd1\x83\xd1\x80\xd0\xb0\xd1\x82\xd0\xb0 \xd0\xb8 \xd0\xbf\xd0\xbe\xd0\xbd\xd1\x8f\xd0\xba\xd0\xbe\xd0\xb3\xd0\xb0 \xd0\xbd\xd0\xb0 \xd0\xb2\xd0\xbb\xd0\xb0\xd0\xb6\xd0\xbd\xd0\xbe\xd1\x81\xd1\x82\xd1\x82\xd0\xb0 \xd0\xb8 \xd1\x87\xd0\xb8\xd1\x81\xd1\x82\xd0\xbe\xd1\x82\xd0\xb0\xd1\x82\xd0\xb0 \xd0\xbd\xd0\xb0 \xd0\xb2\xd1\x8a\xd0\xb7\xd0\xb4\xd1\x83\xd1\x85\xd0\xb0 \xd0\xb2 \xd0\xba\xd1\x8a\xd1\x89\xd0\xb0 \xd0\xb8 \xd1\x82.\xd0\xbd.'},
       {'langcode': 'en', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#definition', 'value': 'A system or process for controlling the temperature and sometimes the humidity and purity of the air in a house, etc.\r\n(Source: CED)'},
       {'langcode': 'pl', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#definition', 'value': 'system kontrolowania temperatury, czasem wilgotno\xc5\x9bci i czysto\xc5\x9bci powietrza w pomieszczeniach'},
       {'langcode': 'ru', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#definition', 'value': '\xd0\xa1\xd0\xb8\xd1\x81\xd1\x82\xd0\xb5\xd0\xbc\xd0\xb0 \xd0\xb8\xd0\xbb\xd0\xb8 \xd0\xbf\xd1\x80\xd0\xbe\xd1\x86\xd0\xb5\xd1\x81\xd1\x81 \xd0\xba\xd0\xbe\xd0\xbd\xd1\x82\xd1\x80\xd0\xbe\xd0\xbb\xd1\x8f \xd0\xb7\xd0\xb0 \xd1\x82\xd0\xb5\xd0\xbc\xd0\xbf\xd0\xb5\xd1\x80\xd0\xb0\xd1\x82\xd1\x83\xd1\x80\xd0\xbe\xd0\xb9 \xd0\xb8 \xd0\xb8\xd0\xbd\xd0\xbe\xd0\xb3\xd0\xb4\xd0\xb0 \xd0\xb7\xd0\xb0 \xd0\xb2\xd0\xbb\xd0\xb0\xd0\xb6\xd0\xbd\xd0\xbe\xd1\x81\xd1\x82\xd1\x8c\xd1\x8e \xd0\xb8 \xd1\x87\xd0\xb8\xd1\x81\xd1\x82\xd0\xbe\xd1\x82\xd0\xbe\xd0\xb9 \xd0\xb2\xd0\xbe\xd0\xb7\xd0\xb4\xd1\x83\xd1\x85\xd0\xb0 \xd0\xb2 \xd0\xb4\xd0\xbe\xd0\xbc\xd0\xb5 \xd0\xb8 \xd0\xbf\xd1\x80.'},
       {'langcode': 'sl', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#definition', 'value': 'Sistem ali proces uravnavanja temperature in v\xc4\x8dasih tudi vlage in \xc4\x8distosti zraka v hi\xc5\xa1i, itd.\n(Vir: CED)'},
       {'langcode': 'ar', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#prefLabel', 'value': '\xd8\xaa\xd9\x83\xd9\x8a\xd9\x8a\xd9\x81 \xd8\xa7\xd9\x84\xd9\x87\xd9\x88\xd8\xa7\xd8\xa1'},
       {'langcode': 'bg', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#prefLabel', 'value': '\xd0\x9a\xd0\xbb\xd0\xb8\xd0\xbc\xd0\xb0\xd1\x82\xd0\xb8\xd0\xb7\xd0\xb8\xd1\x80\xd0\xb0\xd0\xbd\xd0\xb5 (\xd0\xba\xd0\xbe\xd0\xbd\xd0\xb4\xd0\xb8\xd1\x86\xd0\xb8\xd0\xbe\xd0\xbd\xd0\xb8\xd1\x80\xd0\xb0\xd0\xbd\xd0\xb5) \xd0\xbd\xd0\xb0 \xd0\xb2\xd1\x8a\xd0\xb7\xd0\xb4\xd1\x83\xd1\x85\xd0\xb0'},
       {'langcode': 'cs', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#prefLabel', 'value': 'klimatizace'},
       {'langcode': 'da', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#prefLabel', 'value': 'luftkonditionering'},
       {'langcode': 'de', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#prefLabel', 'value': 'Klimatisierung'},
       {'langcode': 'el', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#prefLabel', 'value': '\xce\xba\xce\xbb\xce\xb9\xce\xbc\xce\xb1\xcf\x84\xce\xb9\xcf\x83\xce\xbc\xcf\x8c\xcf\x82'},
       {'langcode': 'en', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#prefLabel', 'value': 'air conditioning'},
       {'langcode': 'en-US', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#prefLabel', 'value': 'air conditioning'},
       {'langcode': 'es', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#prefLabel', 'value': 'acondicionamiento del aire'},
       {'langcode': 'et', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#prefLabel', 'value': '\xc3\xb5hu konditsioneerimine'},
       {'langcode': 'eu', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#prefLabel', 'value': 'aire-girotze'},
       {'langcode': 'fi', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#prefLabel', 'value': 'ilmastointi'},
       {'langcode': 'fr', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#prefLabel', 'value': 'climatisation'},
       {'langcode': 'ga', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#prefLabel', 'value': 'aerch\xc3\xb3iri\xc3\xba'},
       {'langcode': 'hu', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#prefLabel', 'value': 'l\xc3\xa9gkondicion\xc3\xa1l\xc3\xa1s'},
       {'langcode': 'it', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#prefLabel', 'value': "condizionamento dell'aria"},
       {'langcode': 'lt', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#prefLabel', 'value': 'oro kondicionavimas'},
       {'langcode': 'lv', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#prefLabel', 'value': 'gaisa kondicion\xc4\x93\xc5\xa1ana'},
       {'langcode': 'mt', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#prefLabel', 'value': 'kondizzjonament tal-arja'},
       {'langcode': 'nl', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#prefLabel', 'value': 'luchtverversing'},
       {'langcode': 'no', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#prefLabel', 'value': 'luftkondisjonering'},
       {'langcode': 'pl', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#prefLabel', 'value': 'klimatyzacja'},
       {'langcode': 'pt', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#prefLabel', 'value': 'ar condicionado'},
       {'langcode': 'ro', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#prefLabel', 'value': 'aer condi\xc5\xa3ionat'},
       {'langcode': 'ru', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#prefLabel', 'value': '\xd0\xba\xd0\xbe\xd0\xbd\xd0\xb4\xd0\xb8\xd1\x86\xd0\xb8\xd0\xbe\xd0\xbd\xd0\xb8\xd1\x80\xd0\xbe\xd0\xb2\xd0\xb0\xd0\xbd\xd0\xb8\xd0\xb5 \xd0\xb2\xd0\xbe\xd0\xb7\xd0\xb4\xd1\x83\xd1\x85\xd0\xb0'},
       {'langcode': 'sk', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#prefLabel', 'value': 'klimatiz\xc3\xa1cia'},
       {'langcode': 'sl', 'is_resource': 0L, 'uri': 'http://www.w3.org/2004/02/skos/core#prefLabel', 'value': 'klimatizacija'}
     )
示例#14
0
    def create_piechart(self):

        Date = date.today()

        breakfastData = SQLStatements.getTotalBreakfastCalories(
            self.userID, Date)
        breakfastData = str(breakfastData)
        breakfastData = (breakfastData.replace("[", ""))
        breakfastData = (breakfastData.replace("]", ""))
        breakfastData = (breakfastData.replace("(", ""))
        breakfastData = (breakfastData.replace(")", ""))
        breakfastData = (breakfastData.replace(",", ""))
        breakfastData = int(breakfastData)

        lunchData = SQLStatements.getTotalLunchCalories(self.userID, Date)
        lunchData = str(lunchData)
        lunchData = (lunchData.replace("[", ""))
        lunchData = (lunchData.replace("]", ""))
        lunchData = (lunchData.replace("(", ""))
        lunchData = (lunchData.replace(")", ""))
        lunchData = (lunchData.replace(",", ""))
        lunchData = int(lunchData)

        dinnerData = SQLStatements.getTotalDinnerCalories(self.userID, Date)
        dinnerData = str(dinnerData)
        dinnerData = (dinnerData.replace("[", ""))
        dinnerData = (dinnerData.replace("]", ""))
        dinnerData = (dinnerData.replace("(", ""))
        dinnerData = (dinnerData.replace(")", ""))
        dinnerData = (dinnerData.replace(",", ""))
        dinnerData = int(dinnerData)

        snackData = SQLStatements.getTotalSnacksCalories(self.userID, Date)
        snackData = str(snackData)
        snackData = (snackData.replace("[", ""))
        snackData = (snackData.replace("]", ""))
        snackData = (snackData.replace("(", ""))
        snackData = (snackData.replace(")", ""))
        snackData = (snackData.replace(",", ""))
        snackData = int(snackData)

        series = QPieSeries()
        series.append("Breakfast calories", breakfastData)
        series.append("Lunch calories", lunchData)
        series.append("Dinner calories", dinnerData)
        series.append("Snack calories", snackData)

        labelFont = QFont("Sans Serif", )
        labelFont.setPixelSize(16)

        slice = QPieSlice()
        slice.setLabelFont(labelFont)
        slice = series.slices()[0]
        slice.setExploded(True)
        slice.setLabelVisible(True)
        slice.setPen(QPen(Qt.green, 2))
        slice.setBrush(Qt.green)

        slice = QPieSlice()
        slice.setLabelFont(labelFont)
        slice = series.slices()[1]
        slice.setExploded(True)
        slice.setLabelVisible(True)
        slice.setPen(QPen(Qt.white, 2))
        slice.setBrush(Qt.white)

        slice = QPieSlice()
        slice.setLabelFont(labelFont)
        slice = series.slices()[2]
        slice.setExploded(True)
        slice.setLabelVisible(True)
        slice.setPen(QPen(Qt.yellow, 2))
        slice.setBrush(Qt.yellow)

        slice = QPieSlice()
        slice.setLabelFont(labelFont)
        slice = series.slices()[3]
        slice.setExploded(True)
        slice.setLabelVisible(True)
        slice.setPen(QPen(Qt.yellow, 2))
        slice.setBrush(Qt.yellow)

        chart = QChart()
        chart.legend().hide()
        chart.addSeries(series)
        chart.createDefaultAxes()
        chart.setAnimationOptions(QChart.SeriesAnimations)
        chart.setTitle("Daily Calories")
        chart.setTheme(QChart.ChartThemeBlueCerulean)

        chart.setBackgroundVisible(False)
        # Title Font size
        font = QFont("Sans Serif", )
        font.setPixelSize(18)
        chart.setTitleFont(font)

        chart.legend().setVisible(True)
        chart.legend().setAlignment(Qt.AlignBottom)
        chartview = QChartView(chart)
        chartview.setRenderHint(QPainter.Antialiasing)
        return chartview
示例#15
0
import SQLStatements

#create tables and database
SQLStatements.createDB()
SQLStatements.createUserTable()
SQLStatements.createFoodTable()
SQLStatements.createExerciseTable()
SQLStatements.createweightChangeTable()

# Read Python File for Application Functions
exec(open('login.py').read())
示例#16
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(381, 287)
        MainWindow.setStyleSheet("background-color: qlineargradient(spread:pad, x1:0.267, y1:0.642, x2:0.778, y2:0.323864, stop:0 rgba(0, 150, 136, 255), stop:1 rgba(63, 81, 181, 255));""")
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        MainWindow.setCentralWidget(self.centralwidget)
        MainWindow.setWindowTitle("MainWindow")

        self.frame = QtWidgets.QFrame(self.centralwidget)
        self.frame.setGeometry(QtCore.QRect(0, -20, 391, 61))
        self.frame.setStyleSheet("background-color: rgb(255, 255, 255);")
        self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame.setObjectName("frame")
        self.labelheight_2 = QtWidgets.QLabel(self.centralwidget)
        self.labelheight_2.setGeometry(QtCore.QRect(240, 70, 81, 31))
        self.labelheight_2.setAutoFillBackground(False)
        self.labelheight_2.setStyleSheet("font: 15  \"Lato\";" "color: rgb(255, 255, 255);""""background-color: transparent;""")
        self.labelheight_2.setObjectName("labelheight_2")
        self.labelheight_3 = QtWidgets.QLabel(self.centralwidget)
        self.labelheight_3.setGeometry(QtCore.QRect(240, 130, 81, 31))
        self.labelheight_3.setAutoFillBackground(False)
        self.labelheight_3.setStyleSheet("font: 15  \"Lato\";" "color: rgb(255, 255, 255);""""background-color: transparent;""")
        self.labelheight_3.setObjectName("labelheight_3")

        self.labelTitle = QtWidgets.QLabel(self.frame)
        self.labelTitle.setGeometry(QtCore.QRect(20, 20, 341, 41))
        self.labelTitle.setStyleSheet("font: 75 16pt \"MS Shell Dlg 2\";")
        self.labelTitle.setObjectName("labelTitle")

        self.labelheight = QtWidgets.QLabel(self.centralwidget)
        self.labelheight.setGeometry(QtCore.QRect(60, 70, 81, 31))
        self.labelheight.setStyleSheet("font: 15  \"Lato\";" "color: rgb(255, 255, 255);""""background-color: transparent;""")
        self.labelheight.setObjectName("labelheight")

        self.labelweight = QtWidgets.QLabel(self.centralwidget)
        self.labelweight.setGeometry(QtCore.QRect(60, 130, 81, 31))
        self.labelweight.setStyleSheet("font: 15  \"Lato\";" "color: rgb(255, 255, 255);""""background-color: transparent;""")
        self.labelweight.setObjectName("labelweight")

        self.ButtonCalculate = QtWidgets.QPushButton(self.centralwidget)
        self.ButtonCalculate.setGeometry(QtCore.QRect(140, 200, 101, 41))
        self.ButtonCalculate.setStyleSheet("background-color: rgb(255, 255, 255);")
        self.ButtonCalculate.setObjectName("ButtonCalculate")

        self.lineEditHeight = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEditHeight.setGeometry(QtCore.QRect(150, 77, 61, 20))
        self.lineEditHeight.setStyleSheet("background-color: rgb(255, 255, 255);")
        self.lineEditHeight.setObjectName("lineEditHeight")

        self.lineEditWeight = QtWidgets.QLineEdit(self.centralwidget)
        self.lineEditWeight.setGeometry(QtCore.QRect(150, 137, 61, 20))
        self.lineEditWeight.setStyleSheet("background-color: rgb(255, 255, 255);")
        self.lineEditWeight.setObjectName("lineEditWeight")

        self.labelTitle.setText("Body Mass Index (BMI) Calculator:")
        self.labelheight.setText("Insert Height:")
        self.labelweight.setText("Insert Weight:")
        self.ButtonCalculate.setText("Calculate")
        self.labelheight_2.setText("inches")
        self.labelheight_3.setText("lbs")

        UsersWeight = SQLStatements.getWeight(self.userID)
        UsersHeight = SQLStatements.getHeight(self.userID)

        UsersWeight = (float(UsersWeight) * 2.2)
        UsersWeight = int(UsersWeight)
        UsersWeight = str(UsersWeight)

        UsersHeight = (float(UsersHeight) * 0.39)
        UsersHeight = int(UsersHeight)
        UsersHeight = str(UsersHeight)

        self.lineEditHeight.setText(UsersHeight)
        self.lineEditWeight.setText(UsersWeight)

        self.ButtonCalculate.clicked.connect(self.ValidationAndResult)
示例#17
0
    def test_get_themes(self):
        """ get themes"""
	err, res, msg  = self.query(SQLStatements.sql_get_themes(3, 'en', 'utf8_general_ci'))
        correct = [96L, 234L, 1062L, 618L, 893L, 1349L, 2504L, 10114L, 2711L, 10111L, 13109L, 14980L, 10117L, 3875L, 4125L, 4281L, 1922L, 4630L, 4750L, 4856L, 6237L, 10112L, 7007L, 7136L, 10118L, 7243L, 7779L, 7956L, 14979L, 8575L, 8603L, 9117L]
        list_of_themeids = [ x['theme_id'] for x in res]
        self.assertEquals(list_of_themeids, correct)
示例#18
0
    def setupUi(self, progress):
        #set window parameters
        progress.setFixedSize(1188, 730)
        progress.resize(1188, 730)
        progress.setWindowTitle("Home Page")
        progress.setStyleSheet(
            "background-color: qlineargradient(spread:pad, x1:0.267, y1:0.642, x2:0.778, y2:0.323864, stop:0 rgba(0, 150, 136, 255), stop:1 rgba(63, 81, 181, 255));"
            "")
        self.progress_2 = QtWidgets.QWidget(progress)
        progress.setCentralWidget(self.progress_2)

        self.frameWhiteHeader = QtWidgets.QFrame(self.progress_2)
        self.frameWhiteHeader.setGeometry(QtCore.QRect(0, 0, 1191, 51))
        self.frameWhiteHeader.setStyleSheet(
            "\n"
            "background-color: rgb(255, 255, 255);")
        self.frameWhiteHeader.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frameWhiteHeader.setFrameShadow(QtWidgets.QFrame.Raised)

        self.frameGreyBackground = QtWidgets.QFrame(self.progress_2)
        self.frameGreyBackground.setGeometry(QtCore.QRect(0, 50, 181, 761))
        self.frameGreyBackground.setStyleSheet(
            "background-color: rgb(96, 125, 139);")
        self.frameGreyBackground.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frameGreyBackground.setFrameShadow(QtWidgets.QFrame.Raised)

        self.frameGreyHeader2 = QtWidgets.QFrame(self.progress_2)
        self.frameGreyHeader2.setGeometry(QtCore.QRect(180, 50, 1011, 51))
        self.frameGreyHeader2.setStyleSheet(
            "background-color: rgb(224, 224, 224);")
        self.frameGreyHeader = QtWidgets.QFrame(self.frameGreyHeader2)
        self.frameGreyHeader.setGeometry(QtCore.QRect(140, 50, 1011, 51))
        self.frameGreyHeader.setStyleSheet(
            "background-color: rgb(240, 240, 240);")

        #set label for calorie budget
        self.labelCalorieBudget = QtWidgets.QLabel(self.progress_2)
        self.labelCalorieBudget.setGeometry(QtCore.QRect(350, 140, 200, 71))
        self.labelCalorieBudget.setStyleSheet(
            "font: 200 15pt \"Lato\";"
            "color: rgb(255, 255, 255);"
            """background-color: transparent;""")
        self.labelCalorieBudget.setText("BMI")

        #set label for weightloss
        self.labelWeightGoalProgress = QtWidgets.QLabel(self.progress_2)
        self.labelWeightGoalProgress.setGeometry(
            QtCore.QRect(820, 140, 200, 71))
        self.labelWeightGoalProgress.setStyleSheet(
            "font: 75 15pt \"Lato\";"
            "color: rgb(255, 255, 255);"
            """background-color: transparent;""")
        self.labelWeightGoalProgress.setText("Weight Goal Progress")

        # set label for static starting weight name
        self.labelStaticStartingWeight = QtWidgets.QLabel(self.progress_2)
        self.labelStaticStartingWeight.setGeometry(
            QtCore.QRect(800, 300, 200, 30))
        self.labelStaticStartingWeight.setStyleSheet(
            "font: 75 15pt \"Lato\";"
            "color: rgb(255, 255, 255);"
            """background-color: transparent;""")
        self.labelStaticStartingWeight.setText("Starting Weight")

        # set label for static current weight name
        self.labelStaticCurrentWeight = QtWidgets.QLabel(self.progress_2)
        self.labelStaticCurrentWeight.setGeometry(
            QtCore.QRect(800, 400, 200, 71))
        self.labelStaticCurrentWeight.setStyleSheet(
            "font: 75 15pt \"Lato\";"
            "color: rgb(255, 255, 255);"
            """background-color: transparent;""")
        self.labelStaticCurrentWeight.setText("Current Weight")

        # set label for current weight value
        self.labelCurrentWeight = QtWidgets.QLabel(self.progress_2)
        self.labelCurrentWeight.setGeometry(QtCore.QRect(980, 400, 300, 80))
        self.labelCurrentWeight.setStyleSheet(
            "font: 75 15pt \"Lato\";"
            "color: rgb(255, 255, 255);"
            """background-color: transparent;""")
        self.labelCurrentWeight.setText("0")

        # set label for starting weight value
        self.labelStartingWeight = QtWidgets.QLabel(self.progress_2)
        self.labelStartingWeight.setGeometry(QtCore.QRect(980, 300, 200, 30))
        self.labelStartingWeight.setStyleSheet(
            "font: 75 15pt \"Lato\";"
            "color: rgb(255, 255, 255);"
            """text-align: center; background-color: transparent;""")
        self.labelStartingWeight.setText("0")

        #BMI VALUE
        self.BMIValue = QtWidgets.QLabel(self.progress_2)
        self.BMIValue.setGeometry(QtCore.QRect(425, 305, 120, 20))
        self.BMIValue.setStyleSheet(
            "font: 75 15pt \"Lato\";"
            "color: rgb(255, 255, 255);"
            """text-align: center; background-color: transparent;""")
        self.BMIValue.setText("0")

        labelCurrentBmi = QtWidgets.QLabel(self.progress_2)
        labelCurrentBmi.setGeometry(QtCore.QRect(300, 305, 120, 20))
        labelCurrentBmi.setStyleSheet(
            "font: 75 15pt \"Lato\";"
            "color: rgb(255, 255, 255);"
            """text-align: center; background-color: transparent;""")
        labelCurrentBmi.setText("Current BMI:")

        # set label for static starting weight kg
        self.labelStaticStartingWeightKg = QtWidgets.QLabel(self.progress_2)
        self.labelStaticStartingWeightKg.setGeometry(
            QtCore.QRect(1050, 300, 300, 30))
        self.labelStaticStartingWeightKg.setStyleSheet(
            "font: 75 15pt \"Lato\";"
            "color: rgb(255, 255, 255);"
            """background-color: transparent;""")
        self.labelStaticStartingWeightKg.setText("kg")

        # set label for static current weight kg
        self.labelStaticCurrentWeightKg = QtWidgets.QLabel(self.progress_2)
        self.labelStaticCurrentWeightKg.setGeometry(
            QtCore.QRect(1050, 400, 300, 80))
        self.labelStaticCurrentWeightKg.setStyleSheet(
            "font: 75 15pt \"Lato\";"
            "color: rgb(255, 255, 255);"
            """background-color: transparent;""")
        self.labelStaticCurrentWeightKg.setText("kg")

        #GEOMETRY
        #First Value - X is left or right
        # Second Value Y is up or down
        # Third value is width
        # Fourth value is height

        #set label for member date
        self.labelMember = QtWidgets.QLabel(self.frameGreyBackground)
        self.labelMember.setGeometry(QtCore.QRect(20, 200, 111, 31))
        self.labelMember.setStyleSheet("color: rgb(255, 255, 255);")
        self.labelMember.setText("Member Since:")

        self.labelSteps = QtWidgets.QLabel(self.frameGreyBackground)
        self.labelSteps.setGeometry(QtCore.QRect(60, 320, 41, 41))
        self.labelSteps.setLayoutDirection(QtCore.Qt.LeftToRight)
        self.labelSteps.setStyleSheet("font: 75 12pt \"Lato\";"
                                      "color: rgb(255, 255, 255);"
                                      """background-color: transparent;""")
        self.labelSteps.setText("Steps")

        self.labelWater = QtWidgets.QLabel(self.frameGreyBackground)
        self.labelWater.setGeometry(QtCore.QRect(60, 420, 41, 41))
        self.labelWater.setLayoutDirection(QtCore.Qt.LeftToRight)
        self.labelWater.setStyleSheet("font: 75 12pt \"Lato\";"
                                      "color: rgb(255, 255, 255);"
                                      """background-color: transparent;""")
        self.labelWater.setText("Water")

        #frame for users photo
        self.frameUserPhoto = QtWidgets.QFrame(self.frameGreyBackground)
        self.frameUserPhoto.setGeometry(QtCore.QRect(30, 40, 120, 120))
        self.frameUserPhoto.setStyleSheet(
            "image: url(:/images/default-user.png);\n"
            "border-radius: 90px;")
        self.frameUserPhoto.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.frameUserPhoto.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frameUserPhoto.setLineWidth(27)

        #Photo label
        self.labelPhoto = QtWidgets.QLabel(self.frameGreyBackground)
        self.labelPhoto.setGeometry(QtCore.QRect(30, 40, 120, 120))
        self.labelPhoto.setStyleSheet("background-color: rgba(0,0,0,0%)")

        self.buttonsLeftArrow = QtWidgets.QPushButton(self.frameGreyHeader2)
        self.buttonsLeftArrow.setGeometry(QtCore.QRect(0, 0, 61, 51))
        self.buttonsLeftArrow.setFlat(True)
        self.buttonsLeftArrow.setText("<")

        self.buttonRightArrow = QtWidgets.QPushButton(self.frameGreyHeader2)
        self.buttonRightArrow.setGeometry(QtCore.QRect(950, 0, 61, 51))
        self.buttonRightArrow.setFlat(True)
        self.buttonRightArrow.setText(">")

        #set buttons
        self.buttonProfile = QtWidgets.QPushButton(self.frameWhiteHeader)
        self.buttonProfile.setGeometry(QtCore.QRect(0, 0, 85, 51))
        self.buttonProfile.setStyleSheet("font: 75 12pt \"Lato\";")
        self.buttonProfile.setFlat(True)
        self.buttonProfile.clicked.connect(self.openProfileWindow)
        self.buttonProfile.setText("       Profile |    ")

        self.buttonDiary = QtWidgets.QPushButton(self.frameWhiteHeader)
        self.buttonDiary.setGeometry(QtCore.QRect(88, 0, 90, 51))
        self.buttonDiary.setStyleSheet("font: 75 12pt \"Lato\";")
        self.buttonDiary.setFlat(True)
        self.buttonDiary.clicked.connect(self.openDiaryWindow)
        self.buttonDiary.setText("Diary |       ")

        self.buttonPlans = QtWidgets.QPushButton(self.frameWhiteHeader)
        self.buttonPlans.setGeometry(QtCore.QRect(145, 0, 85, 51))
        self.buttonPlans.setStyleSheet("font: 75 12pt \"Lato\";")
        self.buttonPlans.setFlat(True)
        self.buttonPlans.clicked.connect(self.openPlansWindow)
        self.buttonPlans.setText("        Plans |      ")

        self.buttonProgress = QtWidgets.QPushButton(self.frameWhiteHeader)
        self.buttonProgress.setGeometry(QtCore.QRect(230, 0, 100, 51))
        self.buttonProgress.setStyleSheet("font: 75 12pt \"Lato\";")
        self.buttonProgress.setFlat(True)
        self.buttonProgress.setText("    Progress |   ")

        self.buttonNutrition = QtWidgets.QPushButton(self.frameWhiteHeader)
        self.buttonNutrition.setGeometry(QtCore.QRect(330, 0, 100, 51))
        self.buttonNutrition.setStyleSheet("font: 75 12pt \"Lato\";")
        self.buttonNutrition.setFlat(True)
        self.buttonNutrition.clicked.connect(self.openNutritionWindow)
        self.buttonNutrition.setText("     Nutrition |  ")

        self.signOut = QtWidgets.QPushButton(self.frameWhiteHeader)
        self.signOut.setGeometry(QtCore.QRect(1050, 0, 110, 51))
        self.signOut.setStyleSheet("font: 75 12pt \"Lato\";")
        self.signOut.setFlat(True)
        self.signOut.setText("      Sign Out")

        #Update photo button
        self.buttonUpdatePhoto = QtWidgets.QPushButton(
            self.frameGreyBackground)
        self.buttonUpdatePhoto.setGeometry(QtCore.QRect(90, 160, 60, 20))
        self.buttonUpdatePhoto.setStyleSheet(
            "background-color: rgb(85, 170, 255);\n"
            "\n"
            "font:  10pt \"SourceSansPro\";\n"
            "color: rgb(255, 255, 255);")
        self.buttonUpdatePhoto.setText("Update")
        self.buttonUpdatePhoto.clicked.connect(self.AddImage)

        self.buttonAddWeight = QtWidgets.QPushButton(self.progress_2)
        self.buttonAddWeight.setGeometry(QtCore.QRect(800, 475, 150, 20))
        self.buttonAddWeight.setStyleSheet(
            "background-color: rgb(85, 170, 255);\n"
            "\n"
            "font:  10pt \"SourceSansPro\";\n"
            "color: rgb(255, 255, 255);")
        self.buttonAddWeight.clicked.connect(self.openWindowWeight)
        self.buttonAddWeight.setText("Update Current Weight")

        # display current weight in progress window
        self.buttonDisplayCurrentWeight = QtWidgets.QPushButton(
            self.progress_2)
        self.buttonDisplayCurrentWeight.setGeometry(
            QtCore.QRect(800, 450, 150, 20))
        self.buttonDisplayCurrentWeight.setStyleSheet(
            "background-color: rgb(85, 170, 255);\n"
            "\n"
            "font:  10pt \"SourceSansPro\";\n"
            "color: rgb(255, 255, 255);")
        self.buttonDisplayCurrentWeight.clicked.connect(self.loadCurrentWeight)
        self.buttonDisplayCurrentWeight.setText("Display Current Weight")

        #BMI BUTTON
        #self.buttonBMI = QtWidgets.QPushButton(self.progress_2)
        #  self.buttonBMI.setGeometry(QtCore.QRect(300, 325, 120, 20))
        #  self.buttonBMI.setStyleSheet("background-color: rgb(85, 170, 255);\n""\n""font:  10pt \"SourceSansPro\";\n""color: rgb(255, 255, 255);")
        #  self.buttonBMI.clicked.connect(self.loadAddBMI)
        #  self.buttonBMI.setText("Update your BMI")

        #BMI BUTTON
        self.buttonBMI = QtWidgets.QPushButton(self.progress_2)
        self.buttonBMI.setGeometry(QtCore.QRect(300, 330, 150, 20))
        self.buttonBMI.setStyleSheet("background-color: rgb(85, 170, 255);\n"
                                     "\n"
                                     "font:  10pt \"SourceSansPro\";\n"
                                     "color: rgb(255, 255, 255);")
        self.buttonBMI.clicked.connect(self.loadAddBMI)
        self.buttonBMI.setText("Calculate BMI")

        #display current weight in progress window
        self.buttonShowWeight = QtWidgets.QPushButton(self.progress_2)
        self.buttonShowWeight.setGeometry(QtCore.QRect(800, 330, 150, 20))
        self.buttonShowWeight.setStyleSheet(
            "background-color: rgb(85, 170, 255);\n"
            "\n"
            "font:  10pt \"SourceSansPro\";\n"
            "color: rgb(255, 255, 255);")
        self.buttonShowWeight.clicked.connect(self.loadStartingWeight)
        self.buttonShowWeight.setText("Display Start Weight")

        #open weight progress window
        self.buttonShowWeightProgress = QtWidgets.QPushButton(self.progress_2)
        self.buttonShowWeightProgress.setGeometry(
            QtCore.QRect(970, 455, 150, 20))
        self.buttonShowWeightProgress.setStyleSheet(
            "background-color: rgb(85, 170, 255);\n"
            "\n"
            "font:  10pt \"SourceSansPro\";\n"
            "color: rgb(255, 255, 255);")
        self.buttonShowWeightProgress.clicked.connect(self.openWeightChanges)
        self.buttonShowWeightProgress.setText("show weight changes")

        #label to show total calories
        self.labelCaloriesFromDB = QtWidgets.QLabel(self.frameGreyBackground)
        self.labelCaloriesFromDB.setGeometry(QtCore.QRect(40, 290, 91, 41))
        self.labelCaloriesFromDB.setStyleSheet(
            "font: 75 12pt \"Lato\";"
            "color: rgb(255, 255, 255);"
            """background-color: transparent;""")
        caloriesData = SQLStatements.getTotalCalories(self.userID)
        self.labelCaloriesFromDB.setText(caloriesData)

        self.labelStepsFromDB = QtWidgets.QLabel(self.frameGreyBackground)
        self.labelStepsFromDB.setGeometry(QtCore.QRect(30, 370, 91, 41))

        self.labelWaterFromDB = QtWidgets.QLabel(self.frameGreyBackground)
        self.labelWaterFromDB.setGeometry(QtCore.QRect(40, 460, 91, 41))

        #label to show join date
        self.labelJoinDateFromDB = QtWidgets.QLabel(self.frameGreyBackground)
        self.labelJoinDateFromDB.setGeometry(QtCore.QRect(100, 196, 91, 41))
        self.labelJoinDateFromDB.setStyleSheet(
            "font: 75 12pt \"Lato\";"
            "color: rgb(255, 255, 255);"
            """background-color: transparent;""")

        #find join date of user
        Joindate = SQLStatements.getJoinDate(self.userID)

        Joindate = str(Joindate)
        Joindate = (Joindate.replace("[", ""))
        Joindate = (Joindate.replace("]", ""))
        Joindate = (Joindate.replace("(", ""))
        Joindate = (Joindate.replace(")", ""))
        Joindate = (Joindate.replace("'", ""))
        Joindate = (Joindate.replace(",", ""))

        self.labelJoinDateFromDB.setText(Joindate)

        self.showImage()
        self.loadCurrentWeight()
        self.loadStartingWeight()
        self.loadBmi()
示例#19
0
    def test_get_themes(self):
        """ test get languages"""
	self._timed_query(SQLStatements.sql_get_themes(3, 'en', 'utf8_general_ci'))
示例#20
0
    def test_get_concept_languages(self):
        """ test get languages"""
	self._timed_query(SQLStatements.sql_get_concept_languages(1, 7))
示例#21
0
    def loadStartingWeight(self):

        startingweight = SQLStatements.getStartingWeight(self.userID)
        self.labelStartingWeight.setText(str(startingweight))
示例#22
0
    def create_piechart(self):
        series = QLineSeries()

        weights = SQLStatements.getallWeightChanges(self.userID)
        print(weights)

        weights = str(weights)
        weights = weights.replace("(", "")
        weights = weights.replace(")", "")
        weights = weights.replace(",", "")
        weights = weights.replace("[", "")
        weights = weights.replace("]", "")

        weightsTable = weights.split()

        print(weightsTable)

        count = 0
        for x in weightsTable:
            x = int(float(x))
            print(x)
            series.append(count, x)
            count = count + 2

        chart = QChart()

        chart.addSeries(series)
        chart.setAnimationOptions(QChart.SeriesAnimations)
        chart.setTitle("Weight Change over time")
        chart.setTheme(QChart.ChartThemeBlueCerulean)
        chart.setBackgroundVisible(False)

        #Title Font size
        font = QFont("Sans Serif", )
        font.setPixelSize(18)
        chart.setTitleFont(font)

        # X Axis Settings
        axisX = QValueAxis()
        axisX.setTitleText("Time")

        # Y Axis Settings
        axisY = QValueAxis()
        axisY.setTitleText("Weight (KG)")

        # Customize axis label font
        Lfont = QFont("Sans Serif")
        Lfont.setPixelSize(16)
        axisX.setLabelsFont(Lfont)
        axisY.setLabelsFont(Lfont)

        #add Axis
        chart.addAxis(axisX, Qt.AlignBottom)
        series.attachAxis(axisX)

        chart.addAxis(axisY, Qt.AlignLeft)
        series.attachAxis(axisY)

        chartview = QChartView(chart)
        chartview.setRenderHint(QPainter.Antialiasing)

        return chartview
示例#23
0
 def loadBmi(self):
     bmi = SQLStatements.getBmi(self.userID)
     bmi = str(bmi)
     self.BMIValue.setText(bmi)
示例#24
0
    def test_get_languages(self):
        """ test get languages"""
	self._timed_query(SQLStatements.sql_get_namespaces())
示例#25
0
    def setupUi(self, progress):
        #set window title
        progress.setWindowTitle("Diary")
        progress.resize(1188, 730)
        progress.setStyleSheet("background-color: qlineargradient(spread:pad, x1:0.267, y1:0.642, x2:0.778, y2:0.323864, stop:0 rgba(0, 150, 136, 255), stop:1 rgba(63, 81, 181, 255));\n""")
        self.progress_2 = QtWidgets.QWidget(progress)
        QtCore.QMetaObject.connectSlotsByName(progress)
        progress.setCentralWidget(self.progress_2)

        self.frameWhiteHeader = QtWidgets.QFrame(self.progress_2)
        self.frameWhiteHeader.setGeometry(QtCore.QRect(0, 0, 1191, 51))
        self.frameWhiteHeader.setStyleSheet("background-color: rgb(255, 255, 255);")
        self.frameWhiteHeader.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frameWhiteHeader.setFrameShadow(QtWidgets.QFrame.Raised)

        self.frameGreyBackground = QtWidgets.QFrame(self.progress_2)
        self.frameGreyBackground.setGeometry(QtCore.QRect(0, 50, 181, 761))
        self.frameGreyBackground.setStyleSheet("background-color: rgb(96, 125, 139);")
        self.frameGreyBackground.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frameGreyBackground.setFrameShadow(QtWidgets.QFrame.Raised)

        self.frame_2 = QtWidgets.QFrame(self.progress_2)
        self.frame_2.setGeometry(QtCore.QRect(180, 50, 1011, 51))
        self.frame_2.setStyleSheet("background-color: rgb(224, 224, 224);")
        self.frame_2.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame_2.setFrameShadow(QtWidgets.QFrame.Raised)

        self.frameGreyHeader = QtWidgets.QFrame(self.frame_2)
        self.frameGreyHeader.setGeometry(QtCore.QRect(140, 50, 1011, 51))
        self.frameGreyHeader.setStyleSheet("background-color: rgb(240, 240, 240);")
        self.frameGreyHeader.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frameGreyHeader.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frameGreyHeader.setObjectName("frameGreyHeader")

        self.frameUserPhoto = QtWidgets.QFrame(self.frameGreyBackground)
        self.frameUserPhoto.setGeometry(QtCore.QRect(30, 40, 120, 120))
        self.frameUserPhoto.setStyleSheet("image: url(:/images/default-user.png);\n""border-radius: 90px;")
        self.frameUserPhoto.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.frameUserPhoto.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frameUserPhoto.setLineWidth(27)

        self.labelName = QtWidgets.QLabel(self.frameGreyBackground)
        self.labelName.setGeometry(QtCore.QRect(50, 170, 100, 21))
        self.labelName.setStyleSheet("font: 11pt \"MS Shell Dlg 2\";\n""color: rgb(255, 255, 255);")
        UserName = SQLStatements.getUserName(self.userID)
        self.labelName.setText(UserName)
        #set labels
        self.labelBreakfast = QtWidgets.QLabel(self.frameGreyBackground)
        self.labelBreakfast.setGeometry(QtCore.QRect(50, 250, 81, 30))
        self.labelBreakfast.setStyleSheet("font: 75 10pt \"Lato\";" "color: rgb(255, 255, 255);")
        self.labelBreakfast.setText("Breakfast")
        self.labelBreakfastValue = QtWidgets.QLabel(self.frameGreyBackground)
        self.labelBreakfastValue.setGeometry(QtCore.QRect(60, 275, 41, 31))
        self.labelBreakfastValue.setStyleSheet("\n""color: rgb(255, 255, 255);\n""text-align: center;")
        self.labelBreakfastValue.setText("0")

        self.labelLunch = QtWidgets.QLabel(self.frameGreyBackground)
        self.labelLunch.setGeometry(QtCore.QRect(50, 310, 81, 20))
        self.labelLunch.setLayoutDirection(QtCore.Qt.LeftToRight)
        self.labelLunch.setStyleSheet("font: 75 10pt \"Lato\";" "color: rgb(255, 255, 255);""text-align: centre;")
        self.labelLunch.setText("Lunch")
        self.labelLunchValue = QtWidgets.QLabel(self.frameGreyBackground)
        self.labelLunchValue.setGeometry(QtCore.QRect(60, 345, 41, 31))
        self.labelLunchValue.setStyleSheet("color: rgb(255, 255, 255);")
        self.labelLunchValue.setText("0")

        self.labelDinner = QtWidgets.QLabel(self.frameGreyBackground)
        self.labelDinner.setGeometry(QtCore.QRect(50, 385, 81, 20))
        self.labelDinner.setLayoutDirection(QtCore.Qt.LeftToRight)
        self.labelDinner.setStyleSheet("font: 75 10pt \"Lato\";""color: rgb(255, 255, 255);""text-align: centre;")
        self.labelDinner.setText("Dinner")
        self.labelDinnerValue = QtWidgets.QLabel(self.frameGreyBackground)
        self.labelDinnerValue.setGeometry(QtCore.QRect(60, 415, 41, 31))
        self.labelDinnerValue.setStyleSheet("color: rgb(255, 255, 255);")
        self.labelDinnerValue.setText("0")

        self.labelSnacks = QtWidgets.QLabel(self.frameGreyBackground)
        self.labelSnacks.setGeometry(QtCore.QRect(50, 450, 81, 21))
        self.labelSnacks.setLayoutDirection(QtCore.Qt.LeftToRight)
        self.labelSnacks.setStyleSheet("font: 75 10pt \"Lato\";" "color: rgb(255, 255, 255);""text-align: centre;")
        self.labelSnacks.setText("Snacks")
        self.labelSnacksValue = QtWidgets.QLabel(self.frameGreyBackground)
        self.labelSnacksValue.setGeometry(QtCore.QRect(60, 490, 51, 21))
        self.labelSnacksValue.setStyleSheet("\n""color: rgb(255, 255, 255);")
        self.labelSnacksValue.setText("0")

        self.labelExercise = QtWidgets.QLabel(self.frameGreyBackground)
        self.labelExercise.setGeometry(QtCore.QRect(50, 525, 75, 30))
        self.labelExercise.setLayoutDirection(QtCore.Qt.LeftToRight)
        self.labelExercise.setStyleSheet("font: 75 10pt \"Lato\";" "color: rgb(255, 255, 255);""text-align: centre;")
        self.labelExercise.setText("Exercise")
        self.labelExerciseValue = QtWidgets.QLabel(self.frameGreyBackground)
        self.labelExerciseValue.setGeometry(QtCore.QRect(60, 565, 41, 21))
        self.labelExerciseValue.setStyleSheet("color: rgb(255, 255, 255);")
        self.labelExerciseValue.setText("0")

        self.labelBreakfastHeader = QtWidgets.QLabel(self.progress_2)
        self.labelBreakfastHeader.setGeometry(QtCore.QRect(210, 120, 281, 21))
        self.labelBreakfastHeader.setStyleSheet("font: 75 7pt \"Lato\";" "background-color: rgb(255, 255, 255);")

        self.labelLunchHeader = QtWidgets.QLabel(self.progress_2)
        self.labelLunchHeader.setGeometry(QtCore.QRect(870, 120, 281, 21))
        self.labelLunchHeader.setStyleSheet("font: 75 7pt \"Lato\";" "background-color: rgb(255, 255, 255);")

        self.labelDinnerHeader = QtWidgets.QLabel(self.progress_2)
        self.labelDinnerHeader.setGeometry(QtCore.QRect(210, 450, 281, 21))
        self.labelDinnerHeader.setStyleSheet("font: 75 7pt \"Lato\";" "background-color: rgb(255, 255, 255);")

        self.labelSnackHeader = QtWidgets.QLabel(self.progress_2)
        self.labelSnackHeader.setGeometry(QtCore.QRect(870, 450, 281, 21))
        self.labelSnackHeader.setStyleSheet("font: 75 7pt \"Lato\";" "background-color: rgb(255, 255, 255);")

        self.labelExerciseHeader = QtWidgets.QLabel(self.progress_2)
        self.labelExerciseHeader.setGeometry(QtCore.QRect(540, 300, 281, 21))
        self.labelExerciseHeader.setStyleSheet("font: 75 7pt \"Lato\";" "background-color: rgb(255, 255, 255);")
        #set buttons
        self.buttonProfile = QtWidgets.QPushButton(self.frameWhiteHeader)
        self.buttonProfile.setGeometry(QtCore.QRect(0, 0, 85, 51))
        self.buttonProfile.setStyleSheet("font: 75 10pt \"Lato\";")
        self.buttonProfile.setFlat(True)
        self.buttonProfile.setText("       Profile |    ")

        self.buttonDiary = QtWidgets.QPushButton(self.frameWhiteHeader)
        self.buttonDiary.setGeometry(QtCore.QRect(88, 0, 90, 51))
        self.buttonDiary.setStyleSheet("font: 75 10pt \"Lato\";")
        self.buttonDiary.setFlat(True)
        self.buttonDiary.setText("Diary |       ")

        self.buttonPlans = QtWidgets.QPushButton(self.frameWhiteHeader)
        self.buttonPlans.setGeometry(QtCore.QRect(145, 0, 85, 51))
        self.buttonPlans.setStyleSheet("font: 75 10pt \"Lato\";")
        self.buttonPlans.setFlat(True)
        self.buttonPlans.setText("        Plans |      ")

        self.buttonProgress = QtWidgets.QPushButton(self.frameWhiteHeader)
        self.buttonProgress.setGeometry(QtCore.QRect(230, 0, 100, 51))
        self.buttonProgress.setStyleSheet("font: 75 10pt \"Lato\";")
        self.buttonProgress.setFlat(True)
        self.buttonProgress.setText("    Progress |   ")

        self.buttonNutrition = QtWidgets.QPushButton(self.frameWhiteHeader)
        self.buttonNutrition.setGeometry(QtCore.QRect(330, 0, 100, 51))
        self.buttonNutrition.setStyleSheet("font: 75 10pt \"Lato\";")
        self.buttonNutrition.setFlat(True)
        self.buttonNutrition.setText("     Nutrition |  ")

        self.signOut = QtWidgets.QPushButton(self.frameWhiteHeader)
        self.signOut.setGeometry(QtCore.QRect(1050, 0, 110, 51))
        self.signOut.setStyleSheet("font: 75 10pt \"Lato\";")
        self.signOut.setFlat(True)
        self.signOut.setText("      Sign Out")

        self.buttonLeftArrow = QtWidgets.QPushButton(self.frame_2)
        self.buttonLeftArrow.setGeometry(QtCore.QRect(0, 0, 61, 51))
        self.buttonLeftArrow.setStyleSheet("border: 1px solid #C8C8C8;")
        self.buttonLeftArrow.setFlat(True)
        self.buttonLeftArrow.setText("<")

        self.buttonRightArrow = QtWidgets.QPushButton(self.frame_2)
        self.buttonRightArrow.setGeometry(QtCore.QRect(950, 0, 61, 51))
        self.buttonRightArrow.setStyleSheet("border: 1px solid #C8C8C8;")
        self.buttonRightArrow.setFlat(True)
        self.buttonRightArrow.setText(">")

        self.frameGreyHeader = QtWidgets.QFrame(self.frame_2)
        self.frameGreyHeader.setGeometry(QtCore.QRect(140, 50, 1011, 51))
        self.frameGreyHeader.setStyleSheet("background-color: rgb(240, 240, 240);")
        self.frameGreyHeader.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frameGreyHeader.setFrameShadow(QtWidgets.QFrame.Raised)
        #set table widgets
        self.tableWidgetBreakfast = QtWidgets.QTableWidget(self.progress_2)
        self.tableWidgetBreakfast.setGeometry(QtCore.QRect(210, 140, 281, 171))
        self.tableWidgetBreakfast.setStyleSheet("background-color: rgb(255, 255, 255);")
        self.tableWidgetBreakfast.setLineWidth(1)
        self.tableWidgetBreakfast.setMidLineWidth(0)
        #max row count
        self.tableWidgetBreakfast.setRowCount(200)
        #max column count
        self.tableWidgetBreakfast.setColumnCount(3)

        self.tableWidgetExercise = QtWidgets.QTableWidget(self.progress_2)
        self.tableWidgetExercise.setGeometry(QtCore.QRect(540, 320, 281, 171))
        self.tableWidgetExercise.setStyleSheet("background-color: rgb(255, 255, 255);")
        self.tableWidgetExercise.setLineWidth(1)
        self.tableWidgetExercise.setMidLineWidth(0)
        self.tableWidgetExercise.setRowCount(200)
        self.tableWidgetExercise.setColumnCount(2)

        self.tableWidgetlunch = QtWidgets.QTableWidget(self.progress_2)
        self.tableWidgetlunch.setGeometry(QtCore.QRect(870, 140, 281, 171))
        self.tableWidgetlunch.setStyleSheet("background-color: rgb(255, 255, 255);")
        self.tableWidgetlunch.setLineWidth(1)
        self.tableWidgetlunch.setMidLineWidth(0)
        self.tableWidgetlunch.setRowCount(200)
        self.tableWidgetlunch.setColumnCount(3)

        self.tableWidgetSnacks = QtWidgets.QTableWidget(self.progress_2)
        self.tableWidgetSnacks.setGeometry(QtCore.QRect(870, 470, 281, 171))
        self.tableWidgetSnacks.setStyleSheet("background-color: rgb(255, 255, 255);")
        self.tableWidgetSnacks.setLineWidth(1)
        self.tableWidgetSnacks.setMidLineWidth(0)
        self.tableWidgetSnacks.setRowCount(200)
        self.tableWidgetSnacks.setColumnCount(3)

        self.tableWidgetDinner = QtWidgets.QTableWidget(self.progress_2)
        self.tableWidgetDinner.setGeometry(QtCore.QRect(210, 470, 281, 171))
        self.tableWidgetDinner.setStyleSheet("background-color: rgb(255, 255, 255);")
        self.tableWidgetDinner.setLineWidth(1)
        self.tableWidgetDinner.setMidLineWidth(0)
        self.tableWidgetDinner.setRowCount(200)
        self.tableWidgetDinner.setColumnCount(3)

        self.buttonUpdateBreakfast = QtWidgets.QPushButton(self.progress_2)
        self.buttonUpdateBreakfast.setGeometry(QtCore.QRect(350, 118, 75, 23))
        self.buttonUpdateBreakfast.setStyleSheet("font: 75 8pt \"Lato\";" "font-weight: bold;")
        self.buttonUpdateBreakfast.setFlat(True)
        self.buttonUpdateBreakfast.setText("Update")


        self.buttonUpdateLunch = QtWidgets.QPushButton(self.progress_2)
        self.buttonUpdateLunch.setGeometry(QtCore.QRect(1020, 118, 75, 23))
        self.buttonUpdateLunch.setStyleSheet("font: 75 8pt \"Lato\";" "font-weight: bold;")
        self.buttonUpdateLunch.setFlat(True)
        self.buttonUpdateLunch.setText("Update")

        self.buttonUpdateDinner = QtWidgets.QPushButton(self.progress_2)
        self.buttonUpdateDinner.setGeometry(QtCore.QRect(350, 448, 75, 23))
        self.buttonUpdateDinner.setStyleSheet("font: 75 8pt \"Lato\";" "font-weight: bold;")
        self.buttonUpdateDinner.setFlat(True)
        self.buttonUpdateDinner.setText("Update")

        self.buttonUpdateSnacks = QtWidgets.QPushButton(self.progress_2)
        self.buttonUpdateSnacks.setGeometry(QtCore.QRect(1010, 448, 75, 23))
        self.buttonUpdateSnacks.setStyleSheet("font: 75 8pt \"Lato\";" "font-weight: bold;")
        self.buttonUpdateSnacks.setFlat(True)

        self.buttonUpdateExercise = QtWidgets.QPushButton(self.progress_2)
        self.buttonUpdateExercise.setGeometry(QtCore.QRect(680, 298, 75, 23))
        self.buttonUpdateExercise.setStyleSheet("font: 75 8pt \"Lato\";" "font-weight: bold;")
        self.buttonUpdateExercise.setFlat(True)
        self.buttonUpdateExercise.setText("Update")

        self.buttonAddBreakfast = QtWidgets.QPushButton(self.progress_2)
        self.buttonAddBreakfast.setGeometry(QtCore.QRect(450, 118, 41, 23))
        self.buttonAddBreakfast.setStyleSheet("font: 75 8pt \"Lato\";" "font-weight: bold;")
        self.buttonAddBreakfast.setFlat(True)
        self.buttonAddBreakfast.setText("Add")

        self.buttonAddLunch = QtWidgets.QPushButton(self.progress_2)
        self.buttonAddLunch.setGeometry(QtCore.QRect(1110, 118, 41, 23))
        self.buttonAddLunch.setStyleSheet("font: 75 8pt \"Lato\";" "font-weight: bold;")

        self.buttonAddLunch.setFlat(True)
        self.buttonAddLunch.setText("Add")

        self.buttonAddDinner = QtWidgets.QPushButton(self.progress_2)
        self.buttonAddDinner.setGeometry(QtCore.QRect(450, 448, 41, 23))
        self.buttonAddDinner.setStyleSheet("font: 75 8pt \"Lato\";" "font-weight: bold;")
        self.buttonAddDinner.setFlat(True)

        self.buttonAddSnacks = QtWidgets.QPushButton(self.progress_2)
        self.buttonAddSnacks.setGeometry(QtCore.QRect(1110, 448, 41, 23))
        self.buttonAddSnacks.setStyleSheet("font: 75 8pt \"Lato\";" "font-weight: bold;")
        self.buttonAddSnacks.setFlat(True)

        self.buttonAddExercise = QtWidgets.QPushButton(self.progress_2)
        self.buttonAddExercise.setGeometry(QtCore.QRect(780, 298, 41, 23))
        self.buttonAddExercise.setStyleSheet("font: 75 8pt \"Lato\";" "font-weight: bold;")
        self.buttonAddExercise.setFlat(True)
        self.buttonAddExercise.setText("Add")

        self.dateEdit = QtWidgets.QDateEdit(self.frame_2)
        self.dateEdit.setGeometry(QtCore.QRect(410, 10, 181, 31))
        self.dateEdit.setDateTime(QtCore.QDateTime.currentDateTime())

        self.labelBreakfastHeader.raise_()
        self.frameWhiteHeader.raise_()
        self.frameGreyBackground.raise_()
        self.frame_2.raise_()
        self.tableWidgetBreakfast.raise_()
        self.tableWidgetExercise.raise_()
        self.tableWidgetlunch.raise_()
        self.tableWidgetSnacks.raise_()
        self.tableWidgetDinner.raise_()
        self.buttonUpdateBreakfast.raise_()
        self.buttonAddBreakfast.raise_()
        self.labelLunchHeader.raise_()
        self.buttonUpdateLunch.raise_()
        self.buttonAddLunch.raise_()
        self.labelExerciseHeader.raise_()
        self.buttonUpdateExercise.raise_()
        self.buttonAddExercise.raise_()
        self.labelDinnerHeader.raise_()
        self.buttonUpdateDinner.raise_()
        self.buttonAddDinner.raise_()
        self.labelSnackHeader.raise_()
        self.buttonUpdateSnacks.raise_()
        self.buttonAddSnacks.raise_()

        self.labelBreakfast.setText("Breakfast")
        self.labelLunch.setText("Lunch")
        self.labelSnacks.setText("Snacks")
        self.labelBreakfastHeader.setText("  Breakfast")
        self.labelLunchHeader.setText("  Lunch")
        self.labelExerciseHeader.setText("Exercise")
        self.labelDinnerHeader.setText("  Dinner")
        self.buttonAddDinner.setText("Add")
        self.labelSnackHeader.setText("  Snacks")
        self.buttonUpdateSnacks.setText("Update")
        self.buttonAddSnacks.setText("Add")

        self.buttonUpdateBreakfast.clicked.connect(self.loadBreakfastData)
        self.buttonUpdateLunch.clicked.connect(self.loadLunchData)
        self.buttonUpdateDinner.clicked.connect(self.loadDinnerData)
        self.buttonUpdateSnacks.clicked.connect(self.loadSnacksData)
        self.buttonUpdateExercise.clicked.connect(self.loadExerciseData)

        self.buttonAddBreakfast.clicked.connect(self.openWindowDiary)
        self.buttonAddLunch.clicked.connect(self.openWindowLunch)
        self.buttonAddDinner.clicked.connect(self.openWindowDinner)
        self.buttonAddSnacks.clicked.connect(self.openWindowSnack)
        self.buttonAddExercise.clicked.connect(self.openWindowExercise)