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

Merge branch 'listLatihan' into 'develop'

List latihan

See merge request !1
parents 1a8cb2f8 0fb32e2a
Branches
Tags
2 merge requests!7Plan,!1List latihan
import sqlite3 import sqlite3
import sys import sys
import textwrap import textwrap
from functools import partial
from PyQt6.QtCore import Qt from PyQt6.QtCore import Qt, QSize
from PyQt6.QtGui import QIcon, QPixmap, QCursor, QFont from PyQt6.QtGui import QIcon, QPixmap, QCursor, QFont, QMovie
from PyQt6.QtWidgets import (QWidget, QApplication, QMainWindow, QWidget, QGridLayout, from PyQt6.QtWidgets import (QWidget, QApplication, QWidget,
QGroupBox, QRadioButton, QCheckBox, QMessageBox, QLabel, QVBoxLayout, QHBoxLayout, QPushButton, QScrollArea, QDialog)
QLabel, QLineEdit, QVBoxLayout, QHBoxLayout, QPushButton, QScrollArea)
# from PyQt6 import QtWidgets # from PyQt6 import QtWidgets
background = '#5A8D6C' background = '#5A8D6C'
...@@ -14,6 +14,10 @@ button_color = '#174728' ...@@ -14,6 +14,10 @@ button_color = '#174728'
text_color = '#EEEEE2' text_color = '#EEEEE2'
card_color = '#D2DCC4' card_color = '#D2DCC4'
imgPath = None
descLat = None
titleLat = None
class listLatihan2(QWidget): class listLatihan2(QWidget):
...@@ -21,7 +25,8 @@ class listLatihan2(QWidget): ...@@ -21,7 +25,8 @@ class listLatihan2(QWidget):
super().__init__() super().__init__()
self.con = sqlite3.connect('fitu.db') self.con = sqlite3.connect('fitu.db')
self.listLat = self.fetchListLatihan() self.listLat = self.fetchListLatihan()
self.count = 0
self.setUpListLatihanWindow() self.setUpListLatihanWindow()
self.setupGUI() self.setupGUI()
...@@ -37,7 +42,11 @@ class listLatihan2(QWidget): ...@@ -37,7 +42,11 @@ class listLatihan2(QWidget):
self.setWindowIcon(QIcon("img/logo.png")) self.setWindowIcon(QIcon("img/logo.png"))
self.setWindowTitle("Fit-U - Daftar Latihan") self.setWindowTitle("Fit-U - Daftar Latihan")
self.setStyleSheet('background-color: #5A8D6C;') self.setStyleSheet('background-color: #5A8D6C;')
def openDetail(self, count, listLat):
popup = MyPopup(count, listLat)
popup.exec()
def setupGUI(self): def setupGUI(self):
buttonFont = QFont() buttonFont = QFont()
...@@ -63,14 +72,14 @@ class listLatihan2(QWidget): ...@@ -63,14 +72,14 @@ class listLatihan2(QWidget):
homeButton.setStyleSheet(f''' homeButton.setStyleSheet(f'''
QPushButton {{ QPushButton {{
color: {text_color}; color: {text_color};
background-color: {button_color}; background-color: {background};
border: none; border: none;
border-radius: 20px; border-radius: 20px;
}} }}
''') ''')
homeButton.setFont(buttonFont) homeButton.setFont(buttonFont)
homeButton.setFixedSize(96, 42) #pake ini buat kalau dia buletan homeButton.setFixedSize(96, 42) #pake ini buat kalau dia buletan
homeButton.move(507, 53) homeButton.move(507, 58)
homeButton.setCursor( homeButton.setCursor(
QCursor(Qt.CursorShape.PointingHandCursor)) QCursor(Qt.CursorShape.PointingHandCursor))
...@@ -109,16 +118,17 @@ class listLatihan2(QWidget): ...@@ -109,16 +118,17 @@ class listLatihan2(QWidget):
# tombol list # tombol list
listButton = QPushButton(self) listButton = QPushButton(self)
listButton.setText('List') listButton.setText('List')
listButton.setFixedSize(96, 42)
listButton.setStyleSheet(f''' listButton.setStyleSheet(f'''
QPushButton {{ QPushButton {{
color: {text_color}; color: {text_color};
background-color: {background}; background-color: {button_color};
border: none; border: none;
border-radius: 20px; border-radius: 20px;
}} }}
''') ''')
listButton.setFont(buttonFont) listButton.setFont(buttonFont)
listButton.move(898, 58) listButton.move(870, 53)
listButton.setCursor( listButton.setCursor(
QCursor(Qt.CursorShape.PointingHandCursor)) QCursor(Qt.CursorShape.PointingHandCursor))
...@@ -147,7 +157,7 @@ class listLatihan2(QWidget): ...@@ -147,7 +157,7 @@ class listLatihan2(QWidget):
# scroll.setWidget(greenCard) # scroll.setWidget(greenCard)
scroll = QScrollArea(self) scroll = QScrollArea(self)
scroll.setGeometry(0, 150, 1280,570) # mengatur posisi dan ukuran QScrollArea scroll.setGeometry(0, 150, 1265,570) # mengatur posisi dan ukuran QScrollArea
scroll.setStyleSheet("background-color: #5A8D6C;border-radius: none;") scroll.setStyleSheet("background-color: #5A8D6C;border-radius: none;")
scrollWidget = QWidget(scroll) scrollWidget = QWidget(scroll)
scrollLayout = QVBoxLayout(scrollWidget) scrollLayout = QVBoxLayout(scrollWidget)
...@@ -158,18 +168,20 @@ class listLatihan2(QWidget): ...@@ -158,18 +168,20 @@ class listLatihan2(QWidget):
scroll_bar_style = """ scroll_bar_style = """
QScrollBar:vertical { QScrollBar:vertical {
background-color: #D2DCC4; background-color: #D2DCC4;
width: 20px; width: 15px;
margin: 20px 0 20px 0; margin: 20px 0 20px 0;
} }
QScrollBar::handle:vertical { QScrollBar::handle:vertical {
background-color: #174728; background-color: #174728;
border-radius: 10px; border-radius: 6px;
} }
QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical { QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical {
height: 20px; height: 20px;
background-color: #D2DCC4; background-color: #D2DCC4;
subcontrol-origin: margin; subcontrol-origin: margin;
subcontrol-position: top; subcontrol-position: top;
border-top-left-radius: 6px;
border-top-right-radius: 6px;
} }
QScrollBar::add-line:vertical { QScrollBar::add-line:vertical {
top: 0; top: 0;
...@@ -180,43 +192,145 @@ class listLatihan2(QWidget): ...@@ -180,43 +192,145 @@ class listLatihan2(QWidget):
""" """
scroll.verticalScrollBar().setStyleSheet(scroll_bar_style) scroll.verticalScrollBar().setStyleSheet(scroll_bar_style)
count = 0 count = 0
for j in range(4): for j in range(5):
hbox = QHBoxLayout() hbox = QHBoxLayout()
hbox.setContentsMargins(10, 0, 0, 0) hbox.setContentsMargins(10, 0, 0, 0)
for i in range (4): if(j<4):
card = QLabel(self) for i in range (4):
card.setFixedSize(266, 266) card = QPushButton(self)
card.setStyleSheet(styleSheetCard) card.setFixedSize(266, 266)
pathImg = QPixmap('img/logo.png') card.setStyleSheet(styleSheetCard)
image = QLabel(card)
image.setPixmap(pathImg.scaled(100,100)) pathImg = QPixmap(self.listLat[count][6])
image.move(83, 10) image = QLabel(card)
title = QLabel(card) image.setPixmap(pathImg.scaled(100,100))
title.setText(f'<font style="font-size:24px;font-family="Sogoe UI;" ><b>{self.listLat[count][1]}<b>') image.move(83, 10)
title.move(10, 120)
repDur = QLabel(card) title = QLabel(card)
if(count<8): title.setText(f'<font style="font-size:24px;font-family="Sogoe UI;" ><b>{self.listLat[count][1]}<b>')
repDur.setText(f'<font style="font-size:14px;font-family="Sogoe UI;"><b>{self.listLat[count][4]} Detik<b>') title.setStyleSheet("color: #174728")
repDur.move(203, 130) title.move(10, 120)
else:
repDur.setText(f'<font style="font-size:14px;font-family="Sogoe UI;"><b>{self.listLat[count][5]} Repetisi<b>') repDur = QLabel(card)
repDur.move(187,130) if(count<8):
desc = QLabel(card) repDur.setText(f'<font style="font-size:14px;font-family="Sogoe UI;"><b>{self.listLat[count][4]} Detik<b>')
t = f'<font style="font-size:12px;font-family="Sogoe UI;">{self.listLat[count][2]}' repDur.setStyleSheet("color: #174728")
desc.setText(t) repDur.move(203, 130)
desc.move(10, 170) else:
desc.setWordWrap(True) repDur.setText(f'<font style="font-size:14px;font-family="Sogoe UI;"><b>{self.listLat[count][5]} Repetisi<b>')
desc.setFixedWidth(245) repDur.setStyleSheet("color: #174728")
hbox.addWidget(card) repDur.move(187,130)
count+=1
desc = QLabel(card)
t = f'<font style="font-size:12px;font-family="Sogoe UI;">{self.listLat[count][2]}'
if(len(t)> 200):
t = t[0:200]+f" <font color='blue';>See More..."
desc.setText(t)
desc.move(10, 170)
desc.setWordWrap(True)
desc.setFixedWidth(245)
desc.setFixedHeight(70)
desc.setAlignment(Qt.AlignmentFlag.AlignJustify)
desc.setStyleSheet("color: #174728")
self.count = count
hbox.addWidget(card)
card.clicked.connect(partial(self.openDetail, self.count, self.listLat))
card.setCursor(QCursor(Qt.CursorShape.PointingHandCursor))
count+=1
else:
box = QLabel()
box.setFixedHeight(12)
scrollLayout.addWidget(box)
scrollLayout.addLayout(hbox) scrollLayout.addLayout(hbox)
scrollLayout.setSpacing(50) scrollLayout.setSpacing(50)
scroll.setWidget(scrollWidget) scroll.setWidget(scrollWidget)
class MyPopup(QDialog):
def __init__(self, count, listLat):
super().__init__()
self.setWindowFlags(Qt.WindowType.FramelessWindowHint)
self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
styleSheet = (
"background-color: #5A8D6C;"
"border-radius: 20px;"
)
styleSheet2 = (
"background-color: #D2DCC4;"
"border-radius: 20px;"
)
bg = QLabel(self)
bg.setFixedSize(942, 464)
bg.move(198, 164)
bg.setStyleSheet("background-color: black; border-radius: 20px; color: #174728;")
label = QLabel(bg)
label.setFixedSize(938,460)
label.move(2,2)
label.setStyleSheet(styleSheet2)
okButton = QPushButton(label)
okButton.setText("OK")
okButton.setFixedSize(70, 40)
okButton.move(840, 395)
okButton.setStyleSheet("color: #D2DCC4; background-color: #174728;font-weight: bold; font-size: 15px;")
okButton.setCursor(QCursor(Qt.CursorShape.PointingHandCursor))
okButton.clicked.connect(self.close)
pathGif = QMovie(listLat[count][6])
pathGif.setScaledSize(QSize(325,325))
pathGif.setSpeed(100)
gif = QLabel(bg)
gif.setMovie(pathGif)
gif.move(40,60)
gif.setStyleSheet("background-color: #D2DCC4;")
pathGif.start()
garis = QLabel(bg)
garis.setFixedSize(2,440)
garis.setStyleSheet("background-color: #174728;")
garis.move(400,10)
title = QLabel(bg)
title.setText(f'<font style="font-size:60px;font-family="Sogoe UI; ><b>{listLat[count][1]}<b>')
title.setStyleSheet("color: #174728; background-color: #D2DCC4;")
title.move(420, 40)
goal = QLabel(bg)
goal.setText(f'<font style="font-size:26px;font-family="Sogoe UI; ><b>{listLat[count][3]}<b>')
goal.setStyleSheet("color: #174728; background-color: #D2DCC4;")
goal.move(420, 130)
repDur = QLabel(bg)
if(count<8):
repDur.setText(f'<font style="font-size:17px;font-family="Sogoe UI;"><b>{listLat[count][4]} Detik<b>')
repDur.move(760, 140)
else:
repDur.setText(f'<font style="font-size:17px;font-family="Sogoe UI;"><b>{listLat[count][5]} Repetisi<b>')
repDur.move(740, 140)
repDur.setStyleSheet("color: #174728; background-color: #D2DCC4;")
desc = QLabel(bg)
desc.setText(f'<font style="font-size:14px;font-family="Sogoe UI; ><b>{listLat[count][2]}<b>')
desc.setStyleSheet("color: #174728; background-color: #D2DCC4;")
desc.setAlignment(Qt.AlignmentFlag.AlignJustify)
desc.move(420, 180)
desc.setWordWrap(True)
desc.setFixedWidth(410)
if __name__ == '__main__': if __name__ == '__main__':
app = QApplication(sys.argv) app = QApplication(sys.argv)
ex = listLatihan2() ex = listLatihan2()
......
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