-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalendar_class.py
42 lines (30 loc) · 1.18 KB
/
calendar_class.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import sqlite3
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
sqlConnect = sqlite3.connect("products.db")
cur = sqlConnect.cursor()
class Calendar(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle('Calendar')
self.setWindowIcon(QIcon("icons/calendar.svg"))
self.UI()
self.show()
def UI(self):
vbox = QVBoxLayout()
self.setGeometry(1000, 300, 350, 300)
cal = QCalendarWidget(self)
cal.setGridVisible(True)
cal.clicked[QDate].connect(self.showDate)
vbox.addWidget(cal)
self.lbl = QLabel(self)
date = cal.selectedDate()
self.lbl.setText('{}/{}/{}'.format(date.day(), date.month(), date.year()))
vbox.addWidget(self.lbl)
self.setLayout(vbox)
def showDate(self, date):
date_format = '{}/{}/{}'.format(date.day(), date.month(), date.year())
query = "SELECT COUNT(selling_id) FROM sellings WHERE selling_date = ?"
number_of_records = cur.execute(query, (date_format,)).fetchall()
self.lbl.setText(date_format + " - " + str(number_of_records[0][0]) + " records found.")