Skip to content
Snippets Groups Projects
Commit e1056c66 authored by Agsha Athalla Nurkareem's avatar Agsha Athalla Nurkareem
Browse files

Merge branch 'main' of gitlab.informatika.org:eunicesarah/fitu

parents 6eab46f5 771fb81a
Branches
Tags
No related merge requests found
img/register-page.png

25.2 KiB

import sqlite3
from PyQt6.QtWidgets import QApplication, QLabel, QWidget, QLineEdit, QPushButton, QRadioButton, QCheckBox, QMessageBox
from PyQt6.QtGui import QFont, QPixmap, QCursor
from PyQt6.QtCore import Qt
import sys
class register(QWidget):
def __init__(self):
super().__init__()
self.setUpWindow()
# self.setUpRegisterWindow()
# self.conn = sqlite3.connect("fitu.db")
def setUpWindow(self):
self.setWindowTitle("FitU - Register")
self.setFixedSize(1280, 720)
self.setUp()
def setUp(self):
#Background
background = QLabel(self)
bacgroundImage = QPixmap("img/register-page.png")
background.setPixmap(bacgroundImage)
background.move(0, 0)
inputSize = QFont()
inputSize.setFamily("Segoe UI")
inputSize.setPointSize(10)
genderSize = QFont()
genderSize.setFamily("Segoe UI")
genderSize.setPointSize(14)
registerText = QFont()
registerText.setFamily("Segoe UI")
registerText.setPointSize(16)
self.nameInput = QLineEdit(self)
self.nameInput.setPlaceholderText("Input Your Name")
self.nameInput.setFixedSize(379, 44)
self.nameInput.setFont(inputSize)
self.nameInput.setStyleSheet('''
padding: 11px 30px 11px 30px;
border: 1px solid rgba(255, 255, 255, 0.8);
border-radius: 20px;
color: rgba(23, 71, 40, 1);
background-color: #D2DCC4
''')
self.nameInput.move(773, 196)
self.age = QLineEdit(self)
self.age.setPlaceholderText("Input Your Age")
self.age.setFixedSize(172, 44)
self.age.setFont(inputSize)
self.age.setStyleSheet('''
padding: 11px 30px 11px 30px;
border: 1px solid rgba(255, 255, 255, 0.8);
border-radius: 20px;
color: rgba(23, 71, 40, 1);
background-color: #D2DCC4
''')
self.age.move(976, 285)
self.height = QLineEdit(self)
self.height.setPlaceholderText("Input Your Height")
self.height.setFixedSize(172, 44)
self.height.setFont(inputSize)
self.height.setStyleSheet('''
padding: 11px 30px 11px 30px;
border: 1px solid rgba(255, 255, 255, 0.8);
border-radius: 20px;
color: rgba(23, 71, 40, 1);
background-color: #D2DCC4
''')
self.height.move(769, 392)
self.weight = QLineEdit(self)
self.weight.setPlaceholderText("Input Your Weight")
self.weight.setFixedSize(172, 44)
self.weight.setFont(inputSize)
self.weight.setStyleSheet('''
padding: 11px 30px 11px 30px;
border: 1px solid rgba(255, 255, 255, 0.8);
border-radius: 20px;
color: rgba(23, 71, 40, 1);
background-color: #D2DCC4
''')
self.weight.move(976, 392)
self.male = QRadioButton(self)
self.male.move(780, 285)
self.male.setStyleSheet(f'background-color: #174728 ; color: #D2DCC4 ')
self.male.setText("Male")
self.male.setFont(genderSize)
self.male.setCursor(QCursor(Qt.CursorShape.PointingHandCursor))
self.female = QRadioButton(self)
self.female.move(780, 315)
self.female.setStyleSheet('background-color: #174728 ; color: #D2DCC4 ')
self.female.setText("Female")
self.female.setFont(genderSize)
self.female.setCursor(QCursor(Qt.CursorShape.PointingHandCursor))
self.registerButton = QPushButton(self)
self.registerButton.setText("Register")
self.registerButton.setFixedSize(172, 44)
self.registerButton.setStyleSheet('''
border: 1px solid rgba(255, 255, 255, 0.8);
border-radius: 20px;
color: rgba(23, 71, 40, 1);
background-color: #D2DCC4
''')
self.registerButton.move(873, 545)
self.registerButton.setFont(registerText)
self.registerButton.setCursor(QCursor(Qt.CursorShape.PointingHandCursor))
self.fit = QCheckBox(self)
self.fit.move(781, 486)
self.fit.setText("Fit our body")
self.fit.setFont(genderSize)
self.fit.setStyleSheet('background-color: #174728 ; color: #D2DCC4 ')
self.fit.setCursor(QCursor(Qt.CursorShape.PointingHandCursor))
self.thin = QCheckBox(self)
self.thin.move(781, 516)
self.thin.setText("Thin")
self.thin.setFont(genderSize)
self.thin.setStyleSheet('background-color: #174728 ; color: #D2DCC4 ')
self.thin.setCursor(QCursor(Qt.CursorShape.PointingHandCursor))
def register(self):
if (self.nameInput == '' or self.age == '' or self.height == '' or self.weight == '' or (not self.male and not self.female) or self.fit or self.thin):
msgBox = QMessageBox()
msgBox.setText("<p>Please fill out the form properly!</p>")
msgBox.setWindowTitle("Registration Failed")
msgBox.setIcon(QMessageBox.Icon.Warning)
msgBox.setStyleSheet("background-color: white")
msgBox.setStandardButtons(QMessageBox.StandardButton.Ok)
msgBox.exec()
c = self.conn.cursor()
if (self.female):
if (self.thin):
c.execute(
f"INSERT INTO user (name, height, weight, goal, gender, age) VALUES ('{self.nameInput.text()}', '{self.height.text()}', '{self.weight.text()}', 'thin', 'female', '{self.age.text()}')"
)
self.conn.commit()
elif (self.fit):
c.execute(
f"INSERT INTO user (name, height, weight, goal, gender, age) VALUES ('{self.nameInput.text()}', '{self.height.text()}', '{self.weight.text()}', 'fit', 'female', '{self.age.text()}')"
)
self.conn.commit()
else:
c.execute(
f"INSERT INTO user (name, height, weight, goal, gender, age) VALUES ('{self.nameInput.text()}', '{self.height.text()}', '{self.weight.text()}', 'fit, thin', 'female', '{self.age.text()}')"
)
self.conn.commit()
if (self.male):
if (self.thin):
c.execute(
f"INSERT INTO user (name, height, weight, goal, gender, age) VALUES ('{self.nameInput.text()}', '{self.height.text()}', '{self.weight.text()}', 'thin', 'male', '{self.age.text()}')"
)
self.conn.commit()
elif (self.fit):
c.execute(
f"INSERT INTO user (name, height, weight, goal, gender, age) VALUES ('{self.nameInput.text()}', '{self.height.text()}', '{self.weight.text()}', 'fit', 'male', '{self.age.text()}')"
)
self.conn.commit()
else:
c.execute(
f"INSERT INTO user (name, height, weight, goal, gender, age) VALUES ('{self.nameInput.text()}', '{self.height.text()}', '{self.weight.text()}', 'fit, thin', 'male', '{self.age.text()}')"
)
self.conn.commit()
if __name__ == "__main__":
app = QApplication(sys.argv)
window = register()
window.show()
app.exec()
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment