Skip to content
This repository was archived by the owner on Dec 22, 2023. It is now read-only.

Py Organiser #319

Merged
merged 11 commits into from
Oct 5, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Scripts/Miscellaneous/PyOrganiser/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bin/
__pycache__/
lib/
lib64
pyvenv.cfg
13 changes: 13 additions & 0 deletions Scripts/Miscellaneous/PyOrganiser/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Organiser application

- Add plans to your day
- Organise your day
- Keep track abouts all meetings and todos

# Installing

`pip install requirements.txt`

# Demo

<img src="demo.png"/>
1 change: 1 addition & 0 deletions Scripts/Miscellaneous/PyOrganiser/data.db
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"18-05-2020": [{"name": null, "todos": []}]}
Binary file added Scripts/Miscellaneous/PyOrganiser/demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Scripts/Miscellaneous/PyOrganiser/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
144 changes: 144 additions & 0 deletions Scripts/Miscellaneous/PyOrganiser/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
import sys
import json
from PyQt5 import QtCore, QtGui, QtWidgets, uic
from PyQt5.QtCore import Qt


qt_creator_file = "mainwindow.ui"
Ui_MainWindow, QtBaseClass = uic.loadUiType(qt_creator_file)
tick = QtGui.QImage('tick.png')
untick = QtGui.QImage('todo.png')


class TodoModel(QtCore.QAbstractListModel):
def __init__(self, *args, todos=None, database=None, ** kwargs):
super(TodoModel, self).__init__(*args, **kwargs)
self.todos = todos or []
self.database = database or {}

def data(self, index, role):
if role == Qt.DisplayRole:
_, text = self.todos[index.row()]
return text

if role == Qt.DecorationRole:
status, _ = self.todos[index.row()]
if status:
return tick
return untick

def rowCount(self):
return len(self.todos)


class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
def __init__(self):
QtWidgets.QMainWindow.__init__(self)
Ui_MainWindow.__init__(self)
self.setupUi(self)
self.onDateChanged()
self.dateEdit.dateChanged.connect(self.onDateChanged)
self.todoView.setModel(self.model)
self.addButton.pressed.connect(self.add)
self.deleteButton.pressed.connect(self.delete)
self.completeButton.pressed.connect(self.complete)
self.inCompleteButton.pressed.connect(self.incomplete)

def add(self):
"""
Add an item to our todo list, getting the text from the QLineEdit .todoEdit
and then clearing it.
"""
text = self.todoEdit.text()
if text: # Don't add empty strings.
# Access the list via the model.
self.model.todos.append((False, text))
# Trigger refresh.
self.model.layoutChanged.emit()
# Empty the input
self.todoEdit.setText("")
self.save()
self.changeProgress()

def delete(self):
indexes = self.todoView.selectedIndexes()
if indexes:
# Indexes is a list of a single item in single-select mode.
index = indexes[0]
# Remove the item and refresh.
del self.model.todos[index.row()]
self.model.layoutChanged.emit()
# Clear the selection (as it is no longer valid).
self.todoView.clearSelection()
self.save()
self.changeProgress()

def complete(self):
indexes = self.todoView.selectedIndexes()
if indexes:
index = indexes[0]
row = index.row()
text = self.model.todos[row][1]
self.model.todos[row] = (True, text)
# .dataChanged takes top-left and bottom right, which are equal
# for a single selection.
self.model.dataChanged.emit(index, index)
# Clear the selection (as it is no longer valid).
self.todoView.clearSelection()
self.save()
self.changeProgress()

def incomplete(self):
indexes = self.todoView.selectedIndexes()
if indexes:
index = indexes[0]
row = index.row()
text = self.model.todos[row][1]
self.model.todos[row] = (False, text)
# .dataChanged takes top-left and bottom right, which are equal
# for a single selection.
self.model.dataChanged.emit(index, index)
# Clear the selection (as it is no longer valid).
self.todoView.clearSelection()
self.save()
self.changeProgress()

def changeProgress(self):
total = len(self.model.todos)
done = 0
for item in self.model.todos:
if(item[0]):
done += 1
self.progressBar.setValue(int(float(done / total) * 100))

def onDateChanged(self):
self.date = self.dateEdit.dateTime().toString('dd-MM-yyyy')
self.model = TodoModel()
self.load()
self.todoView.setModel(self.model)

def load(self):
try:
with open('data.db', 'r') as f:
jsondata = json.load(f)
try:
k = jsondata[self.date][0]
except KeyError :
jsondata[self.date] = [{'name': None, 'todos': []}]
k = jsondata[self.date][0]
self.model.database = jsondata
self.model.todos = k["Topics"]
self.changeProgress()
except Exception as e:
print(e)
pass

def save(self):
with open('data.db', 'w') as f:
json.dump(self.model.database, f)


app = QtWidgets.QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec_()
174 changes: 174 additions & 0 deletions Scripts/Miscellaneous/PyOrganiser/mainwindow.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>653</width>
<height>500</height>
</rect>
</property>
<property name="windowTitle">
<string>Organizer</string>
</property>
<property name="windowIcon">
<iconset>
<normaloff>../Downloads/file.png</normaloff>../Downloads/file.png</iconset>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QListView" name="todoView">
<property name="geometry">
<rect>
<x>10</x>
<y>70</y>
<width>631</width>
<height>311</height>
</rect>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
</widget>
<widget class="QWidget" name="widget" native="true">
<property name="geometry">
<rect>
<x>9</x>
<y>356</y>
<width>184</width>
<height>45</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="todoEdit">
<property name="geometry">
<rect>
<x>10</x>
<y>400</y>
<width>521</width>
<height>31</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="addButton">
<property name="geometry">
<rect>
<x>540</x>
<y>400</y>
<width>101</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Add Todo</string>
</property>
</widget>
<widget class="QPushButton" name="completeButton">
<property name="geometry">
<rect>
<x>439</x>
<y>440</y>
<width>91</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Complete</string>
</property>
</widget>
<widget class="QPushButton" name="inCompleteButton">
<property name="geometry">
<rect>
<x>9</x>
<y>440</y>
<width>91</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Incomplete</string>
</property>
</widget>
<widget class="QProgressBar" name="progressBar">
<property name="geometry">
<rect>
<x>110</x>
<y>440</y>
<width>321</width>
<height>23</height>
</rect>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>230</x>
<y>10</y>
<width>201</width>
<height>41</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>22</pointsize>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
</font>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Day Scheduler</string>
</property>
</widget>
<widget class="QPushButton" name="deleteButton">
<property name="geometry">
<rect>
<x>540</x>
<y>440</y>
<width>101</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Delete</string>
</property>
</widget>
<widget class="QDateEdit" name="dateEdit">
<property name="geometry">
<rect>
<x>540</x>
<y>10</y>
<width>110</width>
<height>28</height>
</rect>
</property>
<property name="dateTime">
<datetime>
<hour>0</hour>
<minute>0</minute>
<second>0</second>
<year>2020</year>
<month>5</month>
<day>18</day>
</datetime>
</property>
<property name="displayFormat">
<string>dd/MM/yyyy</string>
</property>
<property name="calendarPopup">
<bool>true</bool>
</property>
</widget>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>
25 changes: 25 additions & 0 deletions Scripts/Miscellaneous/PyOrganiser/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
appdirs==1.4.3
CacheControl==0.12.6
certifi==2019.11.28
chardet==3.0.4
colorama==0.4.3
contextlib2==0.6.0
distlib==0.3.0
distro==1.4.0
html5lib==1.0.1
idna==2.8
ipaddr==2.2.0
lockfile==0.12.2
msgpack==0.6.2
packaging==20.3
pep517==0.8.2
progress==1.5
pyparsing==2.4.6
PyQt5==5.15.1
PyQt5-sip==12.8.1
pytoml==0.1.21
requests==2.22.0
retrying==1.3.3
six==1.14.0
urllib3==1.25.8
webencodings==0.5.1
Binary file added Scripts/Miscellaneous/PyOrganiser/tick.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Scripts/Miscellaneous/PyOrganiser/todo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions Scripts/Web_Scrappers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@