This commit is contained in:
Egor Deev 2021-11-30 21:28:23 +07:00 committed by GitHub
parent 46d6d720fa
commit 0106d7bbff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 688 additions and 524 deletions

40
main.py
View file

@ -21,10 +21,14 @@ class MyWidget(QMainWindow): # Ui_MainWindow
self.cursor = self.connection.cursor()
# РАСПИСАНИЕ
self.add_but.clicked.connect(self.add) # ДОБАВЛЕНИЕ ПРЕДМЕТОВ
self.upd_but.clicked.connect(self.upd) # ИЗМЕНЕНИЕ ПРЕДМЕТОВ
self.clear_but.clicked.connect(self.clear) # УБИРАНИЕ ПРЕДМЕТОВ
self.del_but.clicked.connect(self.delete) # УДАЛЕНИЕ ПРЕДМЕТОВ
self.add_but.clicked.connect(self.add) # ДОБАВЛЕНИЕ
self.upd_but.clicked.connect(self.upd) # ИЗМЕНЕНИЕ
self.clear_but.clicked.connect(self.clear) # УБИРАНИЕ
self.del_but.clicked.connect(self.delete) # УДАЛЕНИЕ
self.check_but1.clicked.connect(self.check) # ВЫДЕЛЕНИЕ
self.check_but2.clicked.connect(self.check)
self.check_but3.clicked.connect(self.check)
# ДАННЫЕ ТАБЛИЦЫ
self.table()
@ -54,15 +58,15 @@ class MyWidget(QMainWindow): # Ui_MainWindow
for i, row in enumerate(subjects):
day.setRowCount(day.rowCount() + 1)
for j, elem in enumerate(row):
day.setItem(i, j, QTableWidgetItem(str(elem)))
day.setItem(i, j, QTableWidgetItem(elem))
day.horizontalHeader().setStretchLastSection(True)
# ЗАПОЛНЕНИЕ ВЫПАДАЮЩИХ СПИСКОВ ADD / UPD / DEL
# ЗАПОЛНЕНИЕ ВЫПАДАЮЩИХ СПИСКОВ ADD / UPD / DEL / CHECK
try:
with self.connection:
lessons = self.cursor.execute('SELECT `name` FROM `lessons`').fetchall()
lessons = [i[0] for i in lessons]
for choose_obj in [self.choose_obj1, self.choose_obj2, self.choose_obj3]:
for choose_obj in [self.choose_obj1, self.choose_obj2, self.choose_obj3, self.choose_obj4]:
choose_obj.clear()
if choose_obj == self.choose_obj1:
choose_obj.insertItem(0, "Новый предмет")
@ -201,6 +205,28 @@ class MyWidget(QMainWindow): # Ui_MainWindow
self.cursor.execute(f"UPDATE `timetable` SET `less_{less}` = ? WHERE `id` = ?", (None, day))
self.table()
def check(self):
index, sender = self.choose_obj4.currentText(), self.sender().text()
with self.connection:
ids = self.cursor.execute("SELECT `id` FROM `lessons` WHERE `name` = ?", (index,)).fetchone()[0]
tables = [self.Mon_school, self.Tue_school, self.Wed_school,
self.Thu_school, self.Fri_school, self.Sat_school]
for day in range(1, 7):
with self.connection:
lessons = self.cursor.execute("SELECT * FROM `timetable` WHERE `id` = ?", (day,)).fetchone()
lessons = list(lessons)[2:]
if ids in lessons:
for less in range(1, 9):
if ids == lessons[less - 1]:
if sender == "Выделить":
tables[day - 1].item(less - 1, 0).setBackground(QtGui.QColor(0, 150, 100))
elif sender == "Отменить":
tables[day - 1].item(less - 1, 0).setBackground(QtGui.QColor(255, 255, 255))
else:
self.table()
def notes(self):
pass

706
rasp.ui
View file

@ -6,12 +6,18 @@
<rect>
<x>0</x>
<y>0</y>
<width>1002</width>
<height>817</height>
<width>1192</width>
<height>809</height>
</rect>
</property>
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="windowTitle">
<string>MainWindow</string>
<string>School Table</string>
</property>
<property name="styleSheet">
<string notr="true"/>
@ -20,6 +26,12 @@
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="currentIndex">
<number>0</number>
</property>
@ -68,52 +80,6 @@
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QWidget" name="Monday" native="true">
<property name="minimumSize">
<size>
<width>240</width>
<height>370</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QLabel" name="Mon">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">QLable { font-size: 14px; }</string>
</property>
<property name="text">
<string>Понедельник</string>
</property>
</widget>
</item>
<item>
<widget class="QTableWidget" name="Mon_school"/>
</item>
<item>
<widget class="QTableWidget" name="Mon_note">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>80</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="2">
<widget class="QWidget" name="Wednesday" native="true">
<property name="minimumSize">
@ -234,8 +200,279 @@
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QWidget" name="Monday" native="true">
<property name="minimumSize">
<size>
<width>240</width>
<height>370</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QLabel" name="Mon">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">QLable { font-size: 14px; }</string>
</property>
<property name="text">
<string>Понедельник</string>
</property>
</widget>
</item>
<item>
<widget class="QTableWidget" name="Mon_school"/>
</item>
<item>
<widget class="QTableWidget" name="Mon_note">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>80</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="3">
<widget class="QWidget" name="Check_Obj" native="true">
<property name="minimumSize">
<size>
<width>190</width>
<height>0</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QWidget" name="fake2" native="true"/>
</item>
<item>
<widget class="QGroupBox" name="Check">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>210</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="title">
<string>Предмет</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<layout class="QVBoxLayout" name="verticalLayout_18">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<widget class="QComboBox" name="choose_obj4">
<property name="minimumSize">
<size>
<width>0</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="check_but1">
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="font">
<font>
<pointsize>-1</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">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)
}</string>
</property>
<property name="text">
<string>Выделить</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="check_but2">
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="font">
<font>
<pointsize>-1</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">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)
}</string>
</property>
<property name="text">
<string>Отменить</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="check_but3">
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="font">
<font>
<pointsize>-1</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">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)
}</string>
</property>
<property name="text">
<string>Очистить</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="1">
<widget class="QWidget" name="Friday" native="true">
<property name="minimumSize">
<size>
<width>240</width>
<height>370</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_11">
<item>
<widget class="QLabel" name="Fri">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">QLable { font-size: 14px; }</string>
</property>
<property name="text">
<string>Пятница</string>
</property>
</widget>
</item>
<item>
<widget class="QTableWidget" name="Fri_school"/>
</item>
<item>
<widget class="QTableWidget" name="Fri_note">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>80</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="3">
<widget class="QWidget" name="Add_Upd" native="true">
<widget class="QWidget" name="AToolBars" native="true">
<property name="minimumSize">
<size>
<width>190</width>
@ -248,37 +485,29 @@
<height>16777215</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QWidget" name="fake4" native="true"/>
</item>
<item>
<widget class="QGroupBox" name="Add">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>170</height>
</size>
</property>
<widget class="QTabWidget" name="Toolbar1">
<property name="font">
<font>
<pointsize>10</pointsize>
<pointsize>8</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="title">
<string>Добавить предмет</string>
<property name="currentIndex">
<number>0</number>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<layout class="QVBoxLayout" name="verticalLayout_15">
<widget class="QWidget" name="Add">
<attribute name="title">
<string>Добавить</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QWidget" name="combo1" native="true">
<property name="minimumSize">
<size>
<width>152</width>
<width>148</width>
<height>30</height>
</size>
</property>
@ -305,10 +534,15 @@
<widget class="QComboBox" name="weekday1">
<property name="minimumSize">
<size>
<width>72</width>
<width>69</width>
<height>25</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<item>
<property name="text">
<string>Пн</string>
@ -345,10 +579,15 @@
<widget class="QComboBox" name="object1">
<property name="minimumSize">
<size>
<width>71</width>
<width>69</width>
<height>25</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<item>
<property name="text">
<string>След.</string>
@ -407,6 +646,11 @@
<height>25</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
</item>
<item>
@ -417,6 +661,11 @@
<height>25</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
</item>
<item>
@ -460,40 +709,100 @@ QPushButton:hover{
</item>
</layout>
</widget>
</item>
<widget class="QWidget" name="Del">
<attribute name="title">
<string>Удалить</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_14">
<item>
<widget class="QWidget" name="fake1" native="true"/>
</item>
<item>
<widget class="QGroupBox" name="Upd">
<property name="maximumSize">
<widget class="QComboBox" name="choose_obj3">
<property name="minimumSize">
<size>
<width>16777215</width>
<height>170</height>
<width>0</width>
<height>32</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="fake1" native="true"/>
</item>
<item>
<widget class="QPushButton" name="del_but">
<property name="minimumSize">
<size>
<width>0</width>
<height>37</height>
</size>
</property>
<property name="font">
<font>
<pointsize>-1</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">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)
}</string>
</property>
<property name="text">
<string>Удалить</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QTabWidget" name="Toolbar2">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="title">
<string>Изменть предмет</string>
<property name="currentIndex">
<number>0</number>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<layout class="QVBoxLayout" name="verticalLayout_16">
<widget class="QWidget" name="Upd">
<attribute name="title">
<string>Изменить</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_15">
<item>
<widget class="QComboBox" name="choose_obj2">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
<height>30</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
</item>
<item>
@ -501,9 +810,14 @@ QPushButton:hover{
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
<height>30</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
</widget>
</item>
<item>
@ -511,18 +825,20 @@ QPushButton:hover{
<property name="minimumSize">
<size>
<width>0</width>
<height>35</height>
<height>40</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>37</height>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>-1</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
@ -550,105 +866,11 @@ QPushButton:hover{
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="1">
<widget class="QWidget" name="Friday" native="true">
<property name="minimumSize">
<size>
<width>240</width>
<height>370</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_11">
<item>
<widget class="QLabel" name="Fri">
<property name="font">
<font>
<pointsize>14</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">QLable { font-size: 14px; }</string>
</property>
<property name="text">
<string>Пятница</string>
</property>
</widget>
</item>
<item>
<widget class="QTableWidget" name="Fri_school"/>
</item>
<item>
<widget class="QTableWidget" name="Fri_note">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>80</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="3">
<widget class="QWidget" name="Clear_Del" native="true">
<property name="minimumSize">
<size>
<width>190</width>
<height>0</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QWidget" name="fake3" native="true"/>
</item>
<item>
<widget class="QGroupBox" name="Clear">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>170</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="title">
<string>Убрать предмет</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<layout class="QVBoxLayout" name="verticalLayout_17">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<widget class="QWidget" name="Clear">
<attribute name="title">
<string>Убрать</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_16">
<item>
<widget class="QComboBox" name="weekday3">
<property name="minimumSize">
@ -657,6 +879,11 @@ QPushButton:hover{
<height>30</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<item>
<property name="text">
<string>Везде</string>
@ -702,6 +929,11 @@ QPushButton:hover{
<height>30</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<item>
<property name="text">
<string>Все</string>
@ -787,114 +1019,20 @@ QPushButton:hover{
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="fake2" native="true"/>
</item>
<item>
<widget class="QGroupBox" name="Del">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>170</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="title">
<string>Удалить предмет</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<layout class="QVBoxLayout" name="verticalLayout_18">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<widget class="QComboBox" name="choose_obj3">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="del_but">
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<property name="font">
<font>
<pointsize>-1</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">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)
}</string>
</property>
<property name="text">
<string>Удалить</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
<zorder>Add_Upd</zorder>
<zorder>Saturday</zorder>
<zorder>Friday</zorder>
<zorder>Thursday</zorder>
<zorder>Wednesday</zorder>
<zorder>Tuesday</zorder>
<zorder>Monday</zorder>
<zorder>Clear_Del</zorder>
<zorder>Check_Obj</zorder>
<zorder>AToolBars</zorder>
</widget>
<widget class="QWidget" name="note">
<attribute name="title">

BIN
table.db

Binary file not shown.