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

Commit 0564112

Browse files
authored
Merge pull request #319 from swaroopmaddu/master
Py Organiser
2 parents 2ebc573 + f98f6a4 commit 0564112

File tree

12 files changed

+379
-0
lines changed

12 files changed

+379
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
bin/
2+
__pycache__/
3+
lib/
4+
lib64
5+
pyvenv.cfg
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Organiser application
2+
This application was built with the PyQt5 Python
3+
4+
- Add plans to your day
5+
- Organise your day
6+
- Keep track abouts all meetings and todos
7+
8+
9+
# Installing
10+
11+
`pip install -r requirements.txt`
12+
13+
# How to run the script
14+
`python main.py`
15+
16+
# Screenshot
17+
<img src="media/demo.png"/>
18+
19+
## *Author Name*
20+
21+
[Swaroop Maddu](https://github.com/swaroopmaddu)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"18-05-2020": [{"name": null, "todos": []}]}
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
import sys
2+
import json
3+
from PyQt5 import QtCore, QtGui, QtWidgets,uic
4+
from PyQt5.QtCore import Qt
5+
6+
qt_creator_file = "media/mainwindow.ui"
7+
Ui_MainWindow, QtBaseClass = uic.loadUiType(qt_creator_file)
8+
tick = QtGui.QImage('media/tick.png')
9+
untick = QtGui.QImage('media/todo.png')
10+
11+
12+
class TodoModel(QtCore.QAbstractListModel):
13+
def __init__(self, *args, todos=None, database=None, ** kwargs):
14+
super(TodoModel, self).__init__(*args, **kwargs)
15+
self.todos = todos or []
16+
self.database = database or {}
17+
18+
def data(self, index, role):
19+
if role == Qt.DisplayRole:
20+
_, text = self.todos[index.row()]
21+
return text
22+
23+
if role == Qt.DecorationRole:
24+
status, _ = self.todos[index.row()]
25+
if status:
26+
return tick
27+
return untick
28+
29+
def rowCount(self, index):
30+
return len(self.todos)
31+
32+
33+
class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
34+
def __init__(self):
35+
QtWidgets.QMainWindow.__init__(self)
36+
Ui_MainWindow.__init__(self)
37+
self.setupUi(self)
38+
self.onDateChanged()
39+
self.dateEdit.dateChanged.connect(self.onDateChanged)
40+
self.todoView.setModel(self.model)
41+
self.addButton.pressed.connect(self.add)
42+
self.deleteButton.pressed.connect(self.delete)
43+
self.completeButton.pressed.connect(self.complete)
44+
self.inCompleteButton.pressed.connect(self.incomplete)
45+
46+
def add(self):
47+
"""
48+
Add an item to our todo list, getting the text from the QLineEdit .todoEdit
49+
and then clearing it.
50+
"""
51+
text = self.todoEdit.text()
52+
if text: # Don't add empty strings.
53+
# Access the list via the model.
54+
self.model.todos.append((False, text))
55+
# Trigger refresh.
56+
self.model.layoutChanged.emit()
57+
# Empty the input
58+
self.todoEdit.setText("")
59+
self.save()
60+
self.changeProgress()
61+
62+
def delete(self):
63+
indexes = self.todoView.selectedIndexes()
64+
if indexes:
65+
# Indexes is a list of a single item in single-select mode.
66+
index = indexes[0]
67+
# Remove the item and refresh.
68+
del self.model.todos[index.row()]
69+
self.model.layoutChanged.emit()
70+
# Clear the selection (as it is no longer valid).
71+
self.todoView.clearSelection()
72+
self.save()
73+
self.changeProgress()
74+
75+
def complete(self):
76+
indexes = self.todoView.selectedIndexes()
77+
if indexes:
78+
index = indexes[0]
79+
row = index.row()
80+
text = self.model.todos[row][1]
81+
self.model.todos[row] = (True, text)
82+
# .dataChanged takes top-left and bottom right, which are equal
83+
# for a single selection.
84+
self.model.dataChanged.emit(index, index)
85+
# Clear the selection (as it is no longer valid).
86+
self.todoView.clearSelection()
87+
self.save()
88+
self.changeProgress()
89+
90+
def incomplete(self):
91+
indexes = self.todoView.selectedIndexes()
92+
if indexes:
93+
index = indexes[0]
94+
row = index.row()
95+
text = self.model.todos[row][1]
96+
self.model.todos[row] = (False, text)
97+
# .dataChanged takes top-left and bottom right, which are equal
98+
# for a single selection.
99+
self.model.dataChanged.emit(index, index)
100+
# Clear the selection (as it is no longer valid).
101+
self.todoView.clearSelection()
102+
self.save()
103+
self.changeProgress()
104+
105+
def changeProgress(self):
106+
total = len(self.model.todos)
107+
done = 0
108+
for item in self.model.todos:
109+
if(item[0]):
110+
done += 1
111+
self.progressBar.setValue(int(float(done / total) * 100))
112+
113+
def onDateChanged(self):
114+
self.date = self.dateEdit.dateTime().toString('dd-MM-yyyy')
115+
self.model = TodoModel()
116+
self.load()
117+
self.todoView.setModel(self.model)
118+
119+
def load(self):
120+
try:
121+
with open('data.db', 'r') as f:
122+
jsondata = json.load(f)
123+
try:
124+
k = jsondata[self.date][0]
125+
except KeyError :
126+
jsondata[self.date] = [{'name': None, 'todos': []}]
127+
k = jsondata[self.date][0]
128+
self.model.database = jsondata
129+
self.model.todos = k["Topics"]
130+
self.changeProgress()
131+
except Exception as e:
132+
print(e)
133+
pass
134+
135+
def save(self):
136+
with open('data.db', 'w') as f:
137+
json.dump(self.model.database, f)
138+
139+
140+
app = QtWidgets.QApplication(sys.argv)
141+
window = MainWindow()
142+
window.show()
143+
app.exec_()
22.4 KB
Loading
21.2 KB
Loading
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>MainWindow</class>
4+
<widget class="QMainWindow" name="MainWindow">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>653</width>
10+
<height>500</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>CS2021</string>
15+
</property>
16+
<property name="windowIcon">
17+
<iconset>
18+
<normaloff>icon.png</normaloff>icon.png</iconset>
19+
</property>
20+
<widget class="QWidget" name="centralwidget">
21+
<widget class="QListView" name="todoView">
22+
<property name="geometry">
23+
<rect>
24+
<x>10</x>
25+
<y>70</y>
26+
<width>631</width>
27+
<height>311</height>
28+
</rect>
29+
</property>
30+
<property name="selectionMode">
31+
<enum>QAbstractItemView::SingleSelection</enum>
32+
</property>
33+
</widget>
34+
<widget class="QWidget" name="widget" native="true">
35+
<property name="geometry">
36+
<rect>
37+
<x>9</x>
38+
<y>356</y>
39+
<width>184</width>
40+
<height>45</height>
41+
</rect>
42+
</property>
43+
</widget>
44+
<widget class="QLineEdit" name="todoEdit">
45+
<property name="geometry">
46+
<rect>
47+
<x>10</x>
48+
<y>400</y>
49+
<width>521</width>
50+
<height>31</height>
51+
</rect>
52+
</property>
53+
</widget>
54+
<widget class="QPushButton" name="addButton">
55+
<property name="geometry">
56+
<rect>
57+
<x>540</x>
58+
<y>400</y>
59+
<width>101</width>
60+
<height>27</height>
61+
</rect>
62+
</property>
63+
<property name="text">
64+
<string>Add Todo</string>
65+
</property>
66+
</widget>
67+
<widget class="QPushButton" name="completeButton">
68+
<property name="geometry">
69+
<rect>
70+
<x>439</x>
71+
<y>440</y>
72+
<width>91</width>
73+
<height>27</height>
74+
</rect>
75+
</property>
76+
<property name="text">
77+
<string>Complete</string>
78+
</property>
79+
</widget>
80+
<widget class="QPushButton" name="inCompleteButton">
81+
<property name="geometry">
82+
<rect>
83+
<x>9</x>
84+
<y>440</y>
85+
<width>91</width>
86+
<height>27</height>
87+
</rect>
88+
</property>
89+
<property name="text">
90+
<string>Incomplete</string>
91+
</property>
92+
</widget>
93+
<widget class="QProgressBar" name="progressBar">
94+
<property name="geometry">
95+
<rect>
96+
<x>110</x>
97+
<y>440</y>
98+
<width>321</width>
99+
<height>23</height>
100+
</rect>
101+
</property>
102+
<property name="value">
103+
<number>0</number>
104+
</property>
105+
</widget>
106+
<widget class="QLabel" name="label">
107+
<property name="geometry">
108+
<rect>
109+
<x>150</x>
110+
<y>10</y>
111+
<width>331</width>
112+
<height>41</height>
113+
</rect>
114+
</property>
115+
<property name="font">
116+
<font>
117+
<pointsize>22</pointsize>
118+
<weight>75</weight>
119+
<italic>true</italic>
120+
<bold>true</bold>
121+
</font>
122+
</property>
123+
<property name="layoutDirection">
124+
<enum>Qt::LeftToRight</enum>
125+
</property>
126+
<property name="text">
127+
<string>Py Organiser</string>
128+
</property>
129+
</widget>
130+
<widget class="QPushButton" name="deleteButton">
131+
<property name="geometry">
132+
<rect>
133+
<x>540</x>
134+
<y>440</y>
135+
<width>101</width>
136+
<height>27</height>
137+
</rect>
138+
</property>
139+
<property name="text">
140+
<string>Delete</string>
141+
</property>
142+
</widget>
143+
<widget class="QDateEdit" name="dateEdit">
144+
<property name="geometry">
145+
<rect>
146+
<x>540</x>
147+
<y>10</y>
148+
<width>110</width>
149+
<height>28</height>
150+
</rect>
151+
</property>
152+
<property name="dateTime">
153+
<datetime>
154+
<hour>0</hour>
155+
<minute>0</minute>
156+
<second>0</second>
157+
<year>2020</year>
158+
<month>5</month>
159+
<day>18</day>
160+
</datetime>
161+
</property>
162+
<property name="displayFormat">
163+
<string>dd/MM/yyyy</string>
164+
</property>
165+
<property name="calendarPopup">
166+
<bool>true</bool>
167+
</property>
168+
</widget>
169+
</widget>
170+
<widget class="QStatusBar" name="statusbar"/>
171+
</widget>
172+
<resources/>
173+
<connections/>
174+
</ui>
629 Bytes
Loading
276 Bytes
Loading
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
appdirs==1.4.3
2+
CacheControl==0.12.6
3+
certifi==2019.11.28
4+
chardet==3.0.4
5+
colorama==0.4.3
6+
contextlib2==0.6.0
7+
distlib==0.3.0
8+
distro==1.4.0
9+
html5lib==1.0.1
10+
idna==2.8
11+
ipaddr==2.2.0
12+
lockfile==0.12.2
13+
msgpack==0.6.2
14+
packaging==20.3
15+
pep517==0.8.2
16+
progress==1.5
17+
pyparsing==2.4.6
18+
PyQt5==5.15.1
19+
PyQt5-sip==12.8.1
20+
pytoml==0.1.21
21+
requests==2.22.0
22+
retrying==1.3.3
23+
six==1.14.0
24+
urllib3==1.25.8
25+
webencodings==0.5.1

Scripts/Web_Scrappers/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

design.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# Form implementation generated from reading ui file 'mainwindow.ui'
4+
#
5+
# Created by: PyQt5 UI code generator 5.13.0
6+
#
7+
# WARNING! All changes made in this file will be lost!
8+
9+

0 commit comments

Comments
 (0)