From 548b48acf4d8d20ba7d596a2fdd579b03807764c Mon Sep 17 00:00:00 2001
From: Egor Deev <67710823+IGlek@users.noreply.github.com>
Date: Wed, 22 Dec 2021 15:00:37 +0700
Subject: [PATCH] v. 2.3
---
main.py | 235 +++++++++++++++++++------
rasp.ui | 521 +++++++++++++++++++++++++++++++++++++------------------
table.db | Bin 24576 -> 28672 bytes
3 files changed, 537 insertions(+), 219 deletions(-)
diff --git a/main.py b/main.py
index 555f923..708abc8 100644
--- a/main.py
+++ b/main.py
@@ -11,6 +11,10 @@ if hasattr(QtCore.Qt, 'AA_EnableHighDpiScaling'):
if hasattr(QtCore.Qt, 'AA_UseHighDpiPixmaps'):
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True)
+# ВСТАВИТЬ В ИНТЕРФЕЙС ПОСЛЕ ФОРМАТИРОВАНИЯ
+# self.setWindowTitle('Icon')
+# self.setWindowIcon(QtGui.QIcon('web.png'))
+
class MyWidget(QMainWindow): # Ui_MainWindow
def __init__(self):
@@ -30,12 +34,18 @@ class MyWidget(QMainWindow): # Ui_MainWindow
self.check_but3.clicked.connect(self.check)
# ЗАМЕТКИ
- self.complete.clicked.connect(self.add_notes) # ДОБАВЛЕНИЕ
+ self.showing.clicked.connect(self.show_note) # ПОКАЗАТЬ
+ self.complete.clicked.connect(self.check_note) # ВЫПОЛНИТЬ
+ self.added.clicked.connect(self.add_note) # ДОБАВЛЕНИЕ
+ self.demonstr.clicked.connect(self.update_note) # РЕДАКТИРОВАТЬ
+ self.updat.clicked.connect(self.update_note)
# ДАННЫЕ ТАБЛИЦЫ
- self.table()
+ self.table_rasp()
+ self.table_note()
+ self.table_note_date()
- def table(self):
+ def table_rasp(self):
try:
# РАСПИСАНИЕ
with self.connection:
@@ -78,58 +88,28 @@ class MyWidget(QMainWindow): # Ui_MainWindow
except Exception:
pass
- # ЗАПОЛНЕНИЕ ВЫПАДАЮЩИХ СПИСКОВ CHOOSE 1 / 2
- try:
- with self.connection:
- notes = self.cursor.execute('SELECT `note` FROM `notes`').fetchall()
- notes = [i[0] for i in notes]
- for choose_obj in [self.choose, self.choose_2]:
- choose_obj.clear()
- if self.choose == choose_obj:
- choose_obj.insertItem(0, "Все за этот день!")
- choose_obj.insertItems(1, notes)
- else:
- choose_obj.insertItems(0, notes)
- except Exception:
- pass
-
- # НАСТРОЙКА ДИСПЛЕЕВ ДАТ
- now = QtCore.QDateTime.currentDateTime()
- for date in [self.date_1, self.date_2, self.date_3]:
- date.setDateTime(now)
- date.setDateRange(QtCore.QDate.currentDate().addDays(-365), QtCore.QDate.currentDate().addDays(365))
- if self.date_1 == date:
- date.setDisplayFormat("dd.MM.yyyy")
-
- # ВСЕ ЗАМЕТКИ
- with self.connection:
- note = self.cursor.execute("SELECT `date`, `note` FROM notes").fetchall()
- maintable = self.maintable
- maintable.setColumnCount(2)
- maintable.setRowCount(0)
- maintable.setHorizontalHeaderLabels(["Дата", "Заметка"])
-
- for i, row in enumerate(note):
- maintable.setRowCount(maintable.rowCount() + 1)
- for j, elem in enumerate(row):
- maintable.setItem(i, j, QTableWidgetItem(str(elem)))
- maintable.horizontalHeader().setStretchLastSection(True)
-
# ЗАМЕТКИ ПОД РАСПИСАНИЕМ
with self.connection:
- note = self.cursor.execute("SELECT `date`, `note` FROM notes").fetchall()
+ note = self.cursor.execute("SELECT `date`, `day`, `note` FROM notes").fetchall()
notes = [self.Mon_note, self.Tue_note, self.Wed_note, self.Thu_note, self.Fri_note, self.Sat_note]
+ # СОРТИРОВКА ДАТ
+ note = [[dt.datetime.strptime(dat, "%H:%M %d.%m.%Y"), d, nt] for dat, d, nt in note]
+ note.sort()
+ note = [[dt.datetime.strftime(dat, "%d.%m %H:%M "), d, nt] for dat, d, nt in note]
+
week = {0: [], 1: [], 2: [], 3: [], 4: [], 5: []}
for i in note:
- weekday = dt.datetime.weekday(i[0])
- if weekday != 6:
- week[weekday].append(i)
+ if i[1] != 6:
+ week[i[1]].append((i[0], i[2]))
for write in notes:
write.setColumnCount(2)
write.setRowCount(0)
write.setHorizontalHeaderLabels(["Дата", "Заметка"])
+ header = write.horizontalHeader()
+ header.setSectionResizeMode(0, QtWidgets.QHeaderView.ResizeToContents)
+ header.setSectionResizeMode(1, QtWidgets.QHeaderView.Stretch)
for i, row in enumerate(week[notes.index(write)]):
write.setRowCount(write.rowCount() + 1)
@@ -140,6 +120,61 @@ class MyWidget(QMainWindow): # Ui_MainWindow
except Exception:
QMessageBox.about(self, 'Ошибка!', "Таблица данных не найдена!")
+ def table_note(self):
+ try:
+ # ЗАПОЛНЕНИЕ ВЫПАДАЮЩИХ СПИСКОВ CHOOSE 1 / 2
+ try:
+ with self.connection:
+ notes = self.cursor.execute('SELECT `date`, `note` FROM `notes`').fetchall()
+
+ # СОРТИРОВКА ДАТ
+ notes = [[dt.datetime.strptime(dat, "%H:%M %d.%m.%Y"), nt] for dat, nt in notes]
+ notes.sort()
+ notes = [nt for dat, nt in notes]
+
+ notes = [f"{i + 1}. {nt}" for i, nt in enumerate(notes)]
+ for choose_obj in [self.choose, self.choose_2]:
+ choose_obj.clear()
+ choose_obj.insertItems(0, notes)
+ except Exception:
+ pass
+
+ # ВСЕ ЗАМЕТКИ
+ with self.connection:
+ note = self.cursor.execute("SELECT `date`, `note` FROM notes").fetchall()
+
+ # СОРТИРОВКА ДАТ
+ note = [[dt.datetime.strptime(dat, "%H:%M %d.%m.%Y"), nt] for dat, nt in note]
+ note.sort()
+ note = [[dt.datetime.strftime(dat, "%d.%m.%Y %H:%M "), nt] for dat, nt in note]
+
+ maintable = self.maintable
+ maintable.setColumnCount(2)
+ maintable.setRowCount(0)
+ maintable.setHorizontalHeaderLabels(["Дата", "Заметка"])
+ header = maintable.horizontalHeader()
+ header.setSectionResizeMode(0, QtWidgets.QHeaderView.ResizeToContents)
+ header.setSectionResizeMode(1, QtWidgets.QHeaderView.Stretch)
+
+ for i, row in enumerate(note):
+ maintable.setRowCount(maintable.rowCount() + 1)
+ for j, elem in enumerate(row):
+ maintable.setItem(i, j, QTableWidgetItem(str(elem)))
+ maintable.horizontalHeader().setStretchLastSection(True)
+ except Exception:
+ QMessageBox.about(self, 'Ошибка!', "Таблица данных не найдена!")
+
+ def table_note_date(self):
+ try:
+ # НАСТРОЙКА ДИСПЛЕЕВ ДАТ
+ now = QtCore.QDateTime.currentDateTime()
+ for date in [self.date_1, self.date_2]:
+ date.setDateTime(now)
+ date.setDateRange(QtCore.QDate.currentDate().addDays(-365), QtCore.QDate.currentDate().addDays(365))
+ date.setDisplayFormat("HH:mm dd.MM.yyyy")
+ except Exception:
+ QMessageBox.about(self, 'Ошибка!', "Неудалось вывести указанное время!")
+
# РАСПИСАНИЕ
def add(self):
day = self.weekday1.currentIndex()
@@ -181,7 +216,7 @@ class MyWidget(QMainWindow): # Ui_MainWindow
choose_obj.clear()
choose_obj.insertItem(0, "Новый предмет")
self.add_line.clear()
- self.table()
+ self.table_rasp()
else:
for choose_obj in [self.choose_obj1, self.choose_obj2]:
choose_obj.clear()
@@ -198,7 +233,7 @@ class MyWidget(QMainWindow): # Ui_MainWindow
with self.connection:
self.cursor.execute(f"UPDATE `lessons` SET `name` = ? WHERE `name` = ?", (txt, obj))
self.upd_line.clear()
- self.table()
+ self.table_rasp()
else:
QMessageBox.about(self, 'Ошибка!', "Вы не ввели новое название!")
@@ -212,7 +247,7 @@ class MyWidget(QMainWindow): # Ui_MainWindow
if obj == 0 or obj == less:
with self.connection:
self.cursor.execute(f"UPDATE `timetable` SET `less_{less}` = ? WHERE `id` = ?", (None, wkd))
- self.table()
+ self.table_rasp()
def delete(self):
index = self.choose_obj3.currentText()
@@ -229,7 +264,7 @@ class MyWidget(QMainWindow): # Ui_MainWindow
if ids == lessons[less - 1]:
with self.connection:
self.cursor.execute(f"UPDATE `timetable` SET `less_{less}` = ? WHERE `id` = ?", (None, day))
- self.table()
+ self.table_rasp()
def check(self):
index, sender = self.choose_obj4.currentText(), self.sender().text()
@@ -251,14 +286,108 @@ class MyWidget(QMainWindow): # Ui_MainWindow
elif sender == "Отменить":
tables[day - 1].item(less - 1, 0).setBackground(QtGui.QColor(255, 255, 255))
else:
- self.table()
+ self.table_rasp()
# ЗАМЕТКИ
- def add_notes(self):
- ind = self.choose.currentIndex()
- if ind:
- pass
+ def show_note(self):
+ tp = self.choosedate.currentIndex()
+ if tp == 0:
+ self.table_note()
+ elif tp == 1 or tp == 2:
+ with self.connection:
+ note = self.cursor.execute("SELECT `date`, `note` FROM notes").fetchall()
+ maintable = self.maintable
+ maintable.setColumnCount(2)
+ maintable.setRowCount(0)
+ maintable.setHorizontalHeaderLabels(["Дата", "Заметка"])
+ if tp == 1:
+ dates = ['.'.join(reversed(str(dt.date.today() + dt.timedelta(days=i)).split('-'))) for i in range(30)]
+ else:
+ dates = ['.'.join(reversed(str(dt.date.today() + dt.timedelta(days=i)).split('-'))) for i in range(7)]
+
+ notes = [i for i in note if i[0][-10:] in dates]
+
+ if notes:
+ for i, row in enumerate(notes):
+ maintable.setRowCount(maintable.rowCount() + 1)
+ for j, elem in enumerate(row):
+ maintable.setItem(i, j, QTableWidgetItem(str(elem)))
+ maintable.horizontalHeader().setStretchLastSection(True)
+ else:
+ QMessageBox.about(self, 'Нет Заметок!', "На данные даты заметки отсутствуют!")
+
+ def check_note(self):
+ note = self.choose.currentText()
+ if note:
+ ids = note.split(".")[0]
+
+ with self.connection:
+ notes = self.cursor.execute("SELECT `id` FROM `notes`").fetchall()
+ ids = notes[int(ids) - 1][0]
+
+ with self.connection:
+ self.cursor.execute("DELETE FROM `notes` WHERE `id` = ?", (ids, ))
+ self.table_rasp() # после вёрстки удалить !!!
+ self.table_note()
+ else:
+ QMessageBox.about(self, 'Нет заметки!', "Чтобы выполнить заметку, необходимо её хотя бы иметь!")
+
+ def add_note(self):
+ date = self.date_1.dateTime().toString("HH:mm dd.MM.yyyy")
+ txt = self.write.toPlainText()
+ day = self.date_1.dateTime().toString()[:2]
+
+ if txt:
+ for i, elem in enumerate(["Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Вс"]):
+ if day == elem:
+ day = i
+ break
+ with self.connection:
+ self.cursor.execute("INSERT INTO `notes` (`date`, `day`, `note`) VALUES(?,?,?)", (date, day, txt))
+ self.table_rasp() # после вёрстки удалить !!!
+ self.table_note()
+ else:
+ QMessageBox.about(self, 'Отсутствует информация!',
+ "Для добавления заметки вы должны заполнить текстовое поле!")
+
+ def update_note(self):
+ sender = self.sender().text()
+ z = self.choose_2.currentText()
+ if z:
+ ids = z.split(".")[0]
+
+ with self.connection:
+ notes = self.cursor.execute("SELECT `id` FROM `notes`").fetchall()
+ ids = notes[int(ids) - 1][0]
+
+ if sender == "Показать":
+ with self.connection:
+ note = self.cursor.execute(f"SELECT `date`, `note` FROM notes WHERE `id` = {ids}").fetchone()
+
+ # ОТОБРАЖЕНИЕ ДАТЫ ИЗ БАЗЫ
+ datetime = note[0].split()
+ time = datetime[0].split(":")
+ date = datetime[1].split('.')
+ now = QtCore.QDateTime(int(date[2]), int(date[1]), int(date[0]), int(time[0]), int(time[1]))
+ self.date_2.setDateTime(now)
+
+ self.write_2.setPlainText(note[1])
+ elif sender == "Обновить":
+ date = self.date_2.dateTime().toString("HH:mm dd.MM.yyyy")
+ txt = self.write_2.toPlainText()
+
+ with self.connection:
+ self.cursor.execute(f"UPDATE `notes` SET `date` = ?, `note` = ? WHERE `id` = ?", (date, txt, ids))
+
+ self.write_2.clear()
+ self.table_rasp() # после вёрстки удалить !!!
+ self.table_note()
+ self.table_note_date()
+ else:
+ QMessageBox.about(self, 'Нет заметки!', "Чтобы изменить заметку, необходимо её хотя бы иметь!")
+
+ # ЗАКРЫТИЕ ОКНА
def closeEvent(self, event):
self.connection.close()
diff --git a/rasp.ui b/rasp.ui
index 44e49cd..8313030 100644
--- a/rasp.ui
+++ b/rasp.ui
@@ -6,8 +6,8 @@
0
0
- 1192
- 809
+ 1069
+ 813
@@ -23,8 +23,8 @@
-
- -
+
+
-
@@ -385,6 +385,48 @@
-
+ -
+
+
+
+ 0
+ 40
+
+
+
+
+ 16777215
+ 16777215
+
+
+
+
+ -1
+
+
+
+ QPushButton {
+ padding:10px;
+ color: #fffff;
+ font-size: 18px;
+ border-radius: 10px;
+ border: 1px solid #3873d9;
+ background-color: white; }
+
+QPushButton:hover{
+ background-color: rgb(171, 211, 247);
+ effect = QtWidgets.QGraphicsDropShadowEffect(QPushButton)
+ effect.setOffset(0, 0)
+ effect.setBlurRadius(20)
+ effect.setColor(QColor(57, 219, 255))
+ QPushButton.setGraphicsEffect(effect)
+}
+
+
+ Заметки
+
+
+
-
@@ -893,8 +935,6 @@ QPushButton:hover{
-1
- 50
- false
@@ -987,8 +1027,6 @@ QPushButton:hover{
-1
- 50
- false
@@ -1188,8 +1226,8 @@ QPushButton:hover{
Заметки
-
-
-
+
+
-
@@ -1197,9 +1235,14 @@ QPushButton:hover{
16777215
+
+
+ 10
+
+
- -
+
-
@@ -1236,6 +1279,129 @@ QPushButton:hover{
0
+
+
+ Показать
+
+
+
-
+
+
+
+ 231
+ 0
+
+
+
+
+ 231
+ 16777215
+
+
+
+
+ 50
+ false
+
+
+
+
-
+
+
+
+ 211
+ 51
+
+
+
+
+ 211
+ 51
+
+
+
+
+ -1
+
+
+
+ QPushButton {
+ padding:10px;
+ color: #fffff;
+ font-size: 18px;
+ border-radius: 10px;
+ border: 1px solid #3873d9;
+ background-color: white; }
+
+QPushButton:hover{
+ background-color: rgb(171, 211, 247);
+ effect = QtWidgets.QGraphicsDropShadowEffect(QPushButton)
+ effect.setOffset(0, 0)
+ effect.setBlurRadius(20)
+ effect.setColor(QColor(57, 219, 255))
+ QPushButton.setGraphicsEffect(effect)
+}
+
+
+ Показать
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
-
+
+
+
+ 0
+ 51
+
+
+
+
+ 16777215
+ 51
+
+
+
+
+ 11
+ 75
+ true
+
+
+
-
+
+ За всё время
+
+
+ -
+
+ На месяц
+
+
+ -
+
+ На неделю
+
+
+
+
+ -
+
+
+
+
+
+
+
Сделать
@@ -1255,6 +1421,12 @@ QPushButton:hover{
16777215
+
+
+ 50
+ false
+
+
-
@@ -1270,6 +1442,11 @@ QPushButton:hover{
51
+
+
+ -1
+
+
QPushButton {
padding:10px;
@@ -1293,38 +1470,6 @@ QPushButton:hover{
- -
-
-
-
- 211
- 51
-
-
-
-
- 211
- 51
-
-
-
-
- 12
- 50
- false
-
-
-
- Qt::LeftToRight
-
-
- Qt::AlignCenter
-
-
- QAbstractSpinBox::UpDownArrows
-
-
-
-
@@ -1348,6 +1493,11 @@ QPushButton:hover{
51
+
+
+ 11
+
+
-
@@ -1371,6 +1521,12 @@ QPushButton:hover{
0
+
+
+ 50
+ false
+
+
-
@@ -1389,8 +1545,6 @@ QPushButton:hover{
-1
- 50
- false
@@ -1417,7 +1571,7 @@ QPushButton:hover{
-
-
+
211
@@ -1466,9 +1620,15 @@ QPushButton:hover{
0
+
+
+ 50
+ false
+
+
-
-
+
211
@@ -1484,8 +1644,6 @@ QPushButton:hover{
-1
- 50
- false
@@ -1507,12 +1665,35 @@ QPushButton:hover{
}
- Обновить
+ Показать
-
-
+
+
+
+ 211
+ 51
+
+
+
+
+ 211
+ 51
+
+
+
+
+ 11
+ 75
+ true
+
+
+
+
+ -
+
211
@@ -1537,22 +1718,6 @@ QPushButton:hover{
- -
-
-
-
- 211
- 51
-
-
-
-
- 211
- 51
-
-
-
-
-
@@ -1562,100 +1727,45 @@ QPushButton:hover{
-
-
-
-
-
- -
-
-
-
- 260
- 250
-
-
-
-
- 260
- 250
-
-
-
-
- 10
- 75
- true
-
-
-
- Просмотр заметки
-
-
- Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
-
-
-
-
-
-
-
- 0
- 31
-
-
-
-
- 16777215
- 31
-
-
-
-
- 10
- 75
- true
-
-
-
-
-
- За всё время
+
-
+
+
+
+ 160
+ 0
+
-
- -
-
- На месяц
+
+
+ 50
+ false
+
-
- -
-
- На неделю
-
-
-
-
- -
-
-
- -
-
-
-
- 0
- 41
-
-
-
-
- 16777215
- 41
-
-
-
-
- -1
-
-
-
- QPushButton {
+
+
-
+
+
+ -
+
+
+
+ 140
+ 51
+
+
+
+
+ 140
+ 51
+
+
+
+
+ -1
+
+
+
+ QPushButton {
padding:10px;
color: #fffff;
font-size: 18px;
@@ -1671,13 +1781,87 @@ QPushButton:hover{
effect.setColor(QColor(57, 219, 255))
QPushButton.setGraphicsEffect(effect)
}
-
-
- Показать
-
-
-
-
+
+
+ Обновить
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+ 231
+ 0
+
+
+
+
+ 231
+ 16777215
+
+
+
+
+ 50
+ false
+
+
+
+
+
+ 10
+ 10
+ 211
+ 51
+
+
+
+
+ 211
+ 51
+
+
+
+
+ 211
+ 51
+
+
+
+
+ -1
+
+
+
+ QPushButton {
+ padding:10px;
+ color: #fffff;
+ font-size: 18px;
+ border-radius: 10px;
+ border: 1px solid #3873d9;
+ background-color: white; }
+
+QPushButton:hover{
+ background-color: rgb(171, 211, 247);
+ effect = QtWidgets.QGraphicsDropShadowEffect(QPushButton)
+ effect.setOffset(0, 0)
+ effect.setBlurRadius(20)
+ effect.setColor(QColor(57, 219, 255))
+ QPushButton.setGraphicsEffect(effect)
+}
+
+
+ Расписание
+
+
@@ -1699,6 +1883,11 @@ QPushButton:hover{
&Sign in
+
+
+ Путь к файлу Таблицы
+
+
diff --git a/table.db b/table.db
index d5f25093325baa04f0af047b98243da33724bb9e..937adf13bcf996c373c8af905fa8f791dda8bf78 100644
GIT binary patch
delta 1650
zcmb_c&2JM&6rb7kN9@=$HmG$eG}#m-f{=A~#&(RIqLQWr0*;Lm1LYJgviXpjAnc83
z4%Nn`5}>x~hi`2U{0UK`V
zf4DwKyBcdD4F~BB++&*8E`#}SF<&T3`4hR^fK*bovTv6UPJ+
zm%hHBm8aD??V_bm&tBBZ)oEr;e(LMCZECd39~&OVwN(Ab&hy<`8T?KR1SN1h?}(;}
zR6O)mG1$n_l}MOAMyVlzoGl@@RU#wtq{H**)skwrOPAHk*)wXTtj$*DwVCRSlu_m~>HP{cu)ZSWZZ>3DZ`Ns5
zeQgbdGcw-6cs8-Wy^w9+u==HpdzH*vtEH-X0D4LNv?p(du^Wz;O10acJy&vC7`&he
zLi7&(iO$iFNt65u-|ID^_xQY64(#5}l`LlxXHIYx?Ods1x6@u9P-@X_JdtIv!y8WP
zy0K&|LTxlbS_XN&bq%ydW4U#`wE&X2YRV?MW^oo`Z4MyXb%+j#
yFgLA?fCPHeOg}srx{p4g&*)1_N2t+p{9pQsSHyUm*BqlBbBu`QNCc0F1L0S;+y4Xr
delta 376
zcmZp8z}Rqrae}m9p%})5CuPfAP!{{
z1o@7Ep^=q`U0ht8u`zQp50A}cE?%C=xjf2~m+}a2_T}FqzzbBu%zuN4{|5h4{%@NV
z6AtlD4B(i2Ltl=CgOyo)^DljN0Zx!P0t^iNSD^CTnmUTEMg~TPx`u|j#s*m_Y1zdo
cS!u;7X&J>S*%?4yMhcLZl~I}o(J{de02rEQTmS$7