This repository was archived by the owner on Dec 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 262
Py Organiser #319
Merged
Merged
Py Organiser #319
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
84347f7
Py Organiser
swaroopmaddu dd484a7
Update Readme
swaroopmaddu 3edbe6a
Bug fix
swaroopmaddu 7ca27b7
Merge branch 'master' of https://github.com/swaroopmaddu/Python_and_t…
swaroopmaddu 3e8de6d
Bug fix
swaroopmaddu ff435f9
Moved all media files to a specific folder
swaroopmaddu f637d5f
Updated Readme
swaroopmaddu 17d9e3a
Updated Readme
swaroopmaddu e12e911
Updated config
swaroopmaddu 00d0a98
Updated config
swaroopmaddu f98f6a4
Fix errors
swaroopmaddu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
bin/ | ||
__pycache__/ | ||
lib/ | ||
lib64 | ||
pyvenv.cfg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Organiser application | ||
This application was built with the PyQt5 Python | ||
|
||
- Add plans to your day | ||
- Organise your day | ||
- Keep track abouts all meetings and todos | ||
|
||
|
||
# Installing | ||
|
||
`pip install -r requirements.txt` | ||
|
||
# How to run the script | ||
`python main.py` | ||
|
||
# Screenshot | ||
<img src="media/demo.png"/> | ||
|
||
## *Author Name* | ||
|
||
[Swaroop Maddu](https://github.com/swaroopmaddu) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"18-05-2020": [{"name": null, "todos": []}]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
import sys | ||
import json | ||
from PyQt5 import QtCore, QtGui, QtWidgets,uic | ||
from PyQt5.QtCore import Qt | ||
|
||
qt_creator_file = "media/mainwindow.ui" | ||
Ui_MainWindow, QtBaseClass = uic.loadUiType(qt_creator_file) | ||
tick = QtGui.QImage('media/tick.png') | ||
untick = QtGui.QImage('media/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, index): | ||
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_() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>CS2021</string> | ||
</property> | ||
<property name="windowIcon"> | ||
<iconset> | ||
<normaloff>icon.png</normaloff>icon.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>150</x> | ||
<y>10</y> | ||
<width>331</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>Py Organiser</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> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# Form implementation generated from reading ui file 'mainwindow.ui' | ||
# | ||
# Created by: PyQt5 UI code generator 5.13.0 | ||
# | ||
# WARNING! All changes made in this file will be lost! | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.