Skip to content
Snippets Groups Projects
Commit 1a8cb2f8 authored by Eunice Sarah Siregar's avatar Eunice Sarah Siregar
Browse files

feat: update plan2

parent 74fddc6e
1 merge request!7Plan
from PyQt6.QtWidgets import QApplication
import sys
import sqlite3
from register import register
from dashboard import dashboard
from listLatihan import listLatihan
from tesBacaDB import tesBacaDB
from listlatihan2 import listLatihan2
from tesBacaDB import tesBaca
class controller:
def __init__(self):
self.tesBacaDB = tesBacaDB()
self.conn = sqlite3.connect('fitu.db')
self.tesBacaDB = tesBaca()
self.registerWin = register()
self.registerWin.switch.connect(self.fromRegister)
self.dashboard = dashboard()
self.dashboard.switch.connect(self.fromDashboard)
self.listLatihan = listLatihan()
self.listLatihan.switch.connect(self.fromListLatihan)
# self.dashboard.switch.connect(self.fromDashboard)
# self.listLatihan = listLatihan2()
# self.listLatihan.switch.connect(self.fromListLatihan)
pass
def start(self):
# nanti disini kasih validasi dulu, user udah ada apa belum
self.registerWin.show()
c = self.conn.cursor()
c.execute("SELECT * FROM user")
count = c.fetchone()
if (count != None):
# print("dashboard")
self.dashboard.show()
else:
self.registerWin.show()
def fromRegister(self):
self.registerWin.close()
self.dashboard.show()
def fromDashboard(self, page):
self.registerWin.close()
if (page == "listLatihan"):
self.listLatihan.show()
# def fromDashboard(self, page):
# self.registerWin.close()
# if (page == "listLatihan"):
# self.listLatihan.show()
def fromListLatihan(self, page):
self.listLatihan.close()
if (page == "dashboard"):
self.dashboard.show()
# def fromListLatihan(self, page):
# self.listLatihan.close()
# if (page == "dashboard"):
# self.dashboard.show()
if __name__ == "__main__":
app = QApplication(sys.argv)
......
import sqlite3
from PyQt6.QtWidgets import QApplication, QLabel, QWidget, QLineEdit, QPushButton, QRadioButton, QCheckBox, QMessageBox
from PyQt6.QtGui import QFont, QPixmap, QCursor, QMovie, QIcon
from PyQt6.QtCore import Qt, QSize
from PyQt6.QtCore import Qt, QSize, QUrl, QTimer, QTime
from PyQt6.QtMultimedia import QSoundEffect
import time
import sys
conn = sqlite3.connect("fitu.db")
c = conn.cursor()
......@@ -11,6 +13,11 @@ class plan(QWidget):
def __init__(self):
super().__init__()
self.index = 0
# self.remaining_time = 0
self.timer = QTimer(self)
self.timer.timeout.connect(self.updateTimer)
self.remaining_time = 60 # initial value in seconds
self.timer.start(1000) # set timer to update every second
self.setUpWindowPlan()
# self.setUpRegisterWindow()
......@@ -19,9 +26,22 @@ class plan(QWidget):
self.setFixedSize(1280, 720)
self.setUpPlan()
def setUpPlan(self):
def updateTimer(self):
if self.remaining_time > 0:
self.remaining_time -= 1
minutes = self.remaining_time // 60
seconds = self.remaining_time % 60
self.timer_label.setText(f"{minutes:02d}:{seconds:02d}")
else:
self.timer.stop()
QMessageBox.information(self, "Time's up!", "The countdown timer has ended.")
def resetTimer(self):
self.remaining_time = 60
self.timer.start(1000)
self.timer_label.setText("01:00")
def setUpPlan(self):
self.setStyleSheet('background-color: #5A8D6C')
backButton = QPushButton("<", self)
......@@ -58,6 +78,40 @@ class plan(QWidget):
prevButton.move(513, 581)
prevButton.clicked.connect(self.prevEx)
# filename = "img/BGM NKCTHI.mp3"
# effect = QSoundEffect(self)
# effect.setSource(QUrl.fromLocalFile(filename))
# # possible bug: QSoundEffect::Infinite cannot be used in setLoopCount
# effect.setLoopCount(-2)
# effect.play()
# if self.index == len(latihan)/2 - 1:
# nextButton.setEnabled(False)
# titleProgram = c.execute(f"SELECT name FROM program WHERE program_id = {programId}").fetchone()
# nameExe = c.execute(f"SELECT name FROM daftar_latihan WHERE exercise_id in (SELECT exercise_id FROM latihan_program)").fetchall()
# date = time.strftime("%Y-%m-%d", time.localtime())
# totDuration = c.execute(f"SELECT SUM(duration) FROM daftar_latihan WHERE exercise_id in (SELECT exercise_id FROM latihan_program)").fetchone()
# c.execute("INSERT INTO riwayat_latihan program_id, name, title_program, date, tot_duration VALUES ({programId}, {nameExe}, {titleProgram}, {date}, {totDuration})")
# duration = QLabel(self)
self.repLabel = QLabel(self)
self.repLabel.setFont(QFont("Arial", 20, QFont.Weight.Bold))
self.repLabel.setStyleSheet("color: #EEEEE2")
self.repLabel.move(547, 510)
self.timer_label = QLabel(self)
self.timer_label.setGeometry(0, 0, 200, 50)
self.timer_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.timer_label.move(547, 510)
self.timer_label.setFont(QFont("Arial", 20, QFont.Weight.Bold))
self.timer_label.setStyleSheet("background-color: #EEEEE2; border-radius: 10px; border: 2px")
durationCount = c.execute(f"SELECT duration FROM daftar_latihan WHERE exercise_id in (SELECT exercise_id FROM latihan_program WHERE program_id = 1)").fetchall()
repCount = c.execute(f"SELECT repetition FROM daftar_latihan WHERE exercise_id in (SELECT exercise_id FROM latihan_program WHERE program_id = 1)").fetchall()
print(repCount[self.index][0])
if durationCount[self.index][0] != None and repCount[self.index][0] == None:
self.updateTimer()
elif durationCount[self.index][0] == None and repCount[self.index][0] != None:
self.repLabel.setText(repCount[self.index][0])
def prevEx(self):
......@@ -69,6 +123,7 @@ class plan(QWidget):
self.movie.setScaledSize(QSize(330, 305))
self.movie.setSpeed(60)
print("kiri:" + str(self.index))
self.resetTimer()
def nextEx(self):
......@@ -80,6 +135,7 @@ class plan(QWidget):
self.movie.setScaledSize(QSize(330, 305))
self.movie.setSpeed(100)
print("kanan:" + str(self.index))
self.resetTimer()
if __name__ == "__main__":
......
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