mirror of
https://github.com/EDeev/school_table.git
synced 2026-06-19 14:31:01 +03:00
v. 3.1
This commit is contained in:
parent
19d36e9c77
commit
c1120de07e
1 changed files with 23 additions and 12 deletions
35
main.py
35
main.py
|
|
@ -12,10 +12,6 @@ if hasattr(QtCore.Qt, 'AA_EnableHighDpiScaling'):
|
||||||
if hasattr(QtCore.Qt, 'AA_UseHighDpiPixmaps'):
|
if hasattr(QtCore.Qt, 'AA_UseHighDpiPixmaps'):
|
||||||
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True)
|
QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True)
|
||||||
|
|
||||||
# ВСТАВИТЬ В ИНТЕРФЕЙС ПОСЛЕ ФОРМАТИРОВАНИЯ
|
|
||||||
# self.setWindowTitle('Icon')
|
|
||||||
# self.setWindowIcon(QtGui.QIcon('web.png'))
|
|
||||||
|
|
||||||
|
|
||||||
class Ui_MainWindow(object):
|
class Ui_MainWindow(object):
|
||||||
def setupUi(self, MainWindow):
|
def setupUi(self, MainWindow):
|
||||||
|
|
@ -1211,17 +1207,22 @@ class MyWidget(QMainWindow, Ui_MainWindow):
|
||||||
elif tp == 1 or tp == 2:
|
elif tp == 1 or tp == 2:
|
||||||
with self.connection:
|
with self.connection:
|
||||||
note = self.cursor.execute("SELECT `date`, `note` FROM notes").fetchall()
|
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()
|
||||||
|
|
||||||
maintable = self.maintable
|
maintable = self.maintable
|
||||||
maintable.setColumnCount(2)
|
maintable.setColumnCount(2)
|
||||||
maintable.setRowCount(0)
|
maintable.setRowCount(0)
|
||||||
maintable.setHorizontalHeaderLabels(["Дата", "Заметка"])
|
maintable.setHorizontalHeaderLabels(["Дата", "Заметка"])
|
||||||
|
|
||||||
if tp == 1:
|
if tp == 1:
|
||||||
dates = ['.'.join(reversed(str(dt.date.today() + dt.timedelta(days=i)).split('-'))) for i in range(30)]
|
dates = [dt.date.today() + dt.timedelta(days=i) for i in range(30)]
|
||||||
else:
|
else:
|
||||||
dates = ['.'.join(reversed(str(dt.date.today() + dt.timedelta(days=i)).split('-'))) for i in range(7)]
|
dates = [dt.date.today() + dt.timedelta(days=i) for i in range(7)]
|
||||||
|
|
||||||
notes = [i for i in note if i[0][-10:] in dates]
|
notes = [[dt.datetime.strftime(dat, "%d.%m.%Y %H:%M "), nt] for dat, nt in note if dat.date() in dates]
|
||||||
|
|
||||||
if notes:
|
if notes:
|
||||||
for i, row in enumerate(notes):
|
for i, row in enumerate(notes):
|
||||||
|
|
@ -1238,8 +1239,13 @@ class MyWidget(QMainWindow, Ui_MainWindow):
|
||||||
ids = note.split(".")[0]
|
ids = note.split(".")[0]
|
||||||
|
|
||||||
with self.connection:
|
with self.connection:
|
||||||
notes = self.cursor.execute("SELECT `id` FROM `notes`").fetchall()
|
notes = self.cursor.execute("SELECT `id`, `date` FROM `notes`").fetchall()
|
||||||
ids = notes[int(ids) - 1][0]
|
|
||||||
|
notes = [[dt.datetime.strptime(dat, "%H:%M %d.%m.%Y"), ids] for ids, dat in notes]
|
||||||
|
notes.sort()
|
||||||
|
notes = [idp for dat, idp in notes]
|
||||||
|
|
||||||
|
ids = notes[int(ids) - 1]
|
||||||
|
|
||||||
with self.connection:
|
with self.connection:
|
||||||
self.cursor.execute("DELETE FROM `notes` WHERE `id` = ?", (ids, ))
|
self.cursor.execute("DELETE FROM `notes` WHERE `id` = ?", (ids, ))
|
||||||
|
|
@ -1273,8 +1279,13 @@ class MyWidget(QMainWindow, Ui_MainWindow):
|
||||||
ids = z.split(".")[0]
|
ids = z.split(".")[0]
|
||||||
|
|
||||||
with self.connection:
|
with self.connection:
|
||||||
notes = self.cursor.execute("SELECT `id` FROM `notes`").fetchall()
|
notes = self.cursor.execute("SELECT `id`, `date` FROM `notes`").fetchall()
|
||||||
ids = notes[int(ids) - 1][0]
|
|
||||||
|
notes = [[dt.datetime.strptime(dat, "%H:%M %d.%m.%Y"), ids] for ids, dat in notes]
|
||||||
|
notes.sort()
|
||||||
|
notes = [idp for dat, idp in notes]
|
||||||
|
|
||||||
|
ids = notes[int(ids) - 1]
|
||||||
|
|
||||||
if sender == "Показать":
|
if sender == "Показать":
|
||||||
with self.connection:
|
with self.connection:
|
||||||
|
|
@ -1311,4 +1322,4 @@ if __name__ == '__main__':
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
ex = MyWidget()
|
ex = MyWidget()
|
||||||
ex.show()
|
ex.show()
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
||||||
Loading…
Add table
Reference in a new issue