Skip to content
This repository was archived by the owner on Mar 31, 2020. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
80224ce
Added basic project information
kosayoda Feb 22, 2019
cb78b1d
Updated Project Information
kosayoda Feb 22, 2019
7afacae
Updated gitignore to ignore .vscode
kosayoda Feb 25, 2019
da3f4cd
Added basic GUI init code.
kosayoda Feb 25, 2019
e929ae1
Moved and renamed main ui file from ui_main to ui, in the ui/ folder.…
kosayoda Feb 26, 2019
c37d91d
Added generated .ui files from QtDesigner and their respective conver…
kosayoda Feb 26, 2019
995b964
Added basic GUI for Task Creation. Includes button and name shuffling.
kosayoda Feb 26, 2019
d8f33f5
Added basic GUI for adding the Title, Description and Deadline when c…
kosayoda Feb 26, 2019
eafef9e
Added documentation for the classes involving the addtion of a Task
kosayoda Feb 27, 2019
7d6ea0b
First commit
remytanx Feb 27, 2019
fcf3489
Merge branch 'master' of https://github.com/kosayoda/code-jam-4
remytanx Feb 27, 2019
599772d
Removing versions
remytanx Feb 27, 2019
39e6518
Third Commit
remytanx Feb 27, 2019
e0e1a9d
Moving 'readWrite' folder into 'ui' folder
remytanx Feb 27, 2019
7791309
This is my first commit test
Feb 27, 2019
be41a9e
Merge branch 'master' of https://github.com/kosayoda/code-jam-4
kosayoda Feb 27, 2019
d4d6dcb
Modified deadline-input-combobox to use math equations as options rat…
kosayoda Feb 27, 2019
7e717db
Added passive aggresive label to the Add Deadline window. Also added …
kosayoda Feb 27, 2019
c4f55f2
Added label to the Add Task Window. Adjusted valid y values for rando…
kosayoda Feb 27, 2019
3eec1ae
Added label and reference text to the Get Title window. There is now …
kosayoda Feb 27, 2019
9c01dbe
Added 'Mark' data field in the data structure
remytanx Feb 28, 2019
d4e7dfb
Added label and reference text to the Get Description window. Added f…
kosayoda Feb 28, 2019
5186b87
Changes made:
Feb 28, 2019
b322d4b
Error check for file exist and file empty
remytanx Feb 28, 2019
c5e7511
Merge branch 'master' of https://github.com/kosayoda/code-jam-4
kosayoda Feb 28, 2019
d2ad6be
Updated main ui to close all windows when the main window is closed
kosayoda Feb 28, 2019
60d3326
Added returning of value from the Get Deadline window. Also fixed a b…
kosayoda Feb 28, 2019
792327d
Change Mark to True
Milkological Feb 28, 2019
8e9c3cb
Change Mark to False
Milkological Feb 28, 2019
05d1fbd
Change WriteFile method
Milkological Feb 28, 2019
e278f20
Change WriteFile Method
Milkological Feb 28, 2019
d419f6e
Merge branch 'master' of https://github.com/kosayoda/code-jam-4
Milkological Feb 28, 2019
bfba2c9
Modified self.buttons to store the actual button object rather than t…
kosayoda Feb 28, 2019
94a781b
Cleaned up the DataComm class
kosayoda Feb 28, 2019
fe0e9b6
Fixed issue of the DataComm instance recreating on every task. The in…
kosayoda Feb 28, 2019
be89932
Added the Table Model to be used in the TableView of the application
kosayoda Mar 1, 2019
55a5a4a
Modified the main ui window to update the table upon initialization
kosayoda Mar 1, 2019
0d26d6b
Change Back rw
Mar 1, 2019
59686ca
Change the functions to display the table
Mar 1, 2019
9345cb5
Indentation
remytanx Mar 1, 2019
1850d74
I found the bug with the table but unable to solve
Mar 1, 2019
07c22e1
Fixed name conflict in table_model.py resulting in a list not callabl…
kosayoda Mar 1, 2019
12fa9e5
Modified the Task Table to properly fit the available space
kosayoda Mar 1, 2019
117c559
Created a timer to continuously update the task table
kosayoda Mar 2, 2019
07c1ff8
Cleaned up rw.py to conform to pep8-compliant variable names
kosayoda Mar 2, 2019
df5b7bd
Modiied datacomm to allow easier addition of passive aggressive messages
kosayoda Mar 2, 2019
6c4fcc7
Added Mark Task as Done functionality.
kosayoda Mar 2, 2019
ab3c01f
Added more passive aggressive messages
kosayoda Mar 2, 2019
f2dca20
Updated documentation for the UI
kosayoda Mar 2, 2019
940cad1
Edit button done with edit button disabled...
remytanx Mar 2, 2019
13bda96
Removed useless self useless import
remytanx Mar 2, 2019
fc7f196
Removed unwanted files
kosayoda Mar 2, 2019
61134e7
Added path and dependencies to project, fixed most lint errors in code
kosayoda Mar 3, 2019
ff7b9dc
Adding the edit_task
remytanx Mar 3, 2019
0200179
Remove unnecessary statements
remytanx Mar 3, 2019
b05e8b6
Removed unused imports, linted and removed need of global import
kosayoda Mar 3, 2019
3179d45
Updated README
kosayoda Mar 3, 2019
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
3 changes: 2 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[flake8]
max-line-length=100
application_import_names=projectt
ignore=P102,B311,W503,E226,S311,W504,F821
exclude=__pycache__, venv, .venv, tests
exclude=__pycache__, venv, .venv, tests, ui_*.py
import-order-style=pycharm
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ venv.bak/

# mypy
.mypy_cache/

# vscode stuff
.vscode/
4 changes: 3 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ verify_ssl = true
flake8 = "*"

[packages]
pyside2 = "*"

[requires]
python_version = "3.7"

[scripts]
lint = "python -m flake8"
lint = "python -m flake8"
start = "python -m project"
45 changes: 29 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,57 @@

The theme for this code jam will be **This app hates you!**. You will be creating an application using a GUI library of your choice in Python. The application must serve a real purpose, but must also fit the theme.

You can use any GUI library that you wish to use, but you have to make _a desktop app_. For example, you may use frameworks like PySide, PyQt, tkinter, or wxPython. You can even use stuff like Kivy or PyGame, although we do not recommend that you do. You may not, however, use webframeworks like Django or Flask, and you may not use anything that turns HTML and CSS into a desktop app that runs as a browser.
You can use any GUI library that you wish to use, but you have to make _a desktop app_. For example, you may use frameworks like PySide, PyQt, tkinter, or wxPython. You can even use stuff like Kivy or PyGame, although we do not recommend that you do. You may not, however, use webframeworks like Django or Flask, and you may not use anything that turns HTML and CSS into a desktop app that runs as a browser.

Here are a couple of examples of what we mean by an application that "serves a real purpose but also fits the theme":
* A calculator app that calculates the right answers, but represents the answer in a way that's completely impractical.
* An image resizer where you have to specify which part of the image to resize, specify how much force to apply to the resize operation in newtons, and then manually resize the image by turning a crank.
* An alarm clock app that plays a very loud sound effect every 5 minutes reminding you that your alarm will ring in 6 hours. The closer it gets to the 6 hour mark, the lower the volume of the sound effect. When the time is up, the sound effect is virtually inaudible.

Remember that teamwork is not optional for our code jams - You must find a way to work together. For this jam, we've assigned a leader for each team based on their responses to the application form. Remember to listen to your leader, and communicate with the rest of your team!
- A calculator app that calculates the right answers, but represents the answer in a way that's completely impractical.
- An image resizer where you have to specify which part of the image to resize, specify how much force to apply to the resize operation in newtons, and then manually resize the image by turning a crank.
- An alarm clock app that plays a very loud sound effect every 5 minutes reminding you that your alarm will ring in 6 hours. The closer it gets to the 6 hour mark, the lower the volume of the sound effect. When the time is up, the sound effect is virtually inaudible.

Remember that teamwork is not optional for our code jams - You must find a way to work together. For this jam, we've assigned a leader for each team based on their responses to the application form. Remember to listen to your leader, and communicate with the rest of your team!

**Remember to provide instructions on how to set up and run your app at the bottom of this README**.

# Tips

* Please lint your code, and listen to the linter. We recommend **flake8**, and you can use `pipenv run lint` to run it. We will be evaluating your style, and unlinted code will lead to point deductions.
* Remember to work closely with the rest of your team. We will deduct points for poor teamwork.
* Don't overcomplicate this. It's better to write a relatively simple app that is 100% feature complete than failing to finish a more ambitious project.
* For information on how the Code Jam will be judged, please see [this document](https://wiki.pythondiscord.com/wiki/jams/judging).
- Please lint your code, and listen to the linter. We recommend **flake8**, and you can use `pipenv run lint` to run it. We will be evaluating your style, and unlinted code will lead to point deductions.
- Remember to work closely with the rest of your team. We will deduct points for poor teamwork.
- Don't overcomplicate this. It's better to write a relatively simple app that is 100% feature complete than failing to finish a more ambitious project.
- For information on how the Code Jam will be judged, please see [this document](https://wiki.pythondiscord.com/wiki/jams/judging).

# Setting Up

You should be using [Pipenv](https://pipenv.readthedocs.io/en/latest/). Take a look
You should be using [Pipenv](https://pipenv.readthedocs.io/en/latest/). Take a look
[at the documentation](https://pipenv.readthedocs.io/en/latest/) if you've never used it before. In short:

* Setting up for development: `pipenv install --dev`
* Running the application (assuming you use our project layout): `pipenv run start`
- Setting up for development: `pipenv install --dev`
- Running the application (assuming you use our project layout): `pipenv run start`

# Project Information

`# TODO`
#### Team

Lingering loops

#### Members

[kosayoda#8868](https://github.com/kosayoda "kosa") | [Milkological#4356](https://github.com/Milkological "Milkological") | [remyx#0040](https://github.com/remytanx "remyx")

## Description

`# TODO`
Tired of not remembering all your TODOs? Want someplace to put all those pesky tasks you have to do? This is the app for you!

## Requirements

- Python 3.7
- PySide2

## Setup & Installation

`# TODO`
- Download the ZIP file and extract
- Run `pipenv run start` in the root folder

## How do I use this thing?

`# TODO`
Click buttons and hope for the best!
13 changes: 13 additions & 0 deletions project/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import sys
from PySide2.QtWidgets import QApplication
from .ui.ui import MainApplication


def main():
app = QApplication(sys.argv)
_ = MainApplication()
sys.exit(app.exec_())


if __name__ == "__main__":
main()
133 changes: 133 additions & 0 deletions project/ui/add_task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
from collections import namedtuple
from random import randint, shuffle

from PySide2.QtWidgets import QWidget

from .get_deadline import AddDeadline
from .get_desc import AddDesc
from .get_title import AddTitle
from .ui_files.ui_add_task import Ui_task_form


class AddTask(QWidget, Ui_task_form):
"""
Class containing the window for Adding a Task.

Attributes:
width (int): Width of the window
height (int): Height of the window
windows (list of object): A list of windows opened so they do not get
garbage collected
task (dict): The task to be added.
Format: {
"Title": "Eat water",
"Description": "Eat chunky water",
"Deadline": 9999999991,
}
datacomm (object): The Data Communication object used to update the table
model and communicate with the file writing class.
"""

def __init__(self, datacomm):
super().__init__()
self.width, self.height = 650, 500

self.init_UI()
self.bind_buttons()
self.windows = []
self.task = {}

self.datacomm = datacomm

def init_UI(self):
"""
Load the .ui-converted .py file, set the size and display the window.
"""
self.setupUi(self)
self.setFixedSize(self.width, self.height)

self.buttons = [getattr(self, i)
for i in vars(self) if i.endswith("button")]
self.button_text = ["Add Title",
"Add Deadline", "Done", "Add Description"]
self.move_buttons()

self.show()

def randomize_names(self):
"""
Randomizes the names of the buttons. The tooltip remains unchanged.
"""
shuffle(self.button_text)
for index, button in enumerate(self.buttons):
button.setText(self.button_text[index])

def move_buttons(self):
"""
Moves the buttons to a random position in the window without overlapping.
"""
def overlap(box_1, box_2):
"""
Checks if two boxes overlap.

Args:
box_1 (namedtuple: int, int, int, int): The first box
box_2 (namedtuple: int, int, int, int): The second box

Returns:
bool: True if the boxes overlap each other. False otherwise.
"""
return (box_1.x1 < box_2.x2 and box_2.x1 < box_1.x2) and (
box_1.y1 < box_2.y2 and box_2.y1 < box_1.y2)

min_y = 70
max_x, max_y = self.width - 250, self.height - 25

Box = namedtuple("Box", ["x1", "x2", "y1", "y2"])
boxes = []

for button in self.buttons:
while True:
rand_x, rand_y = randint(0, max_x), randint(min_y, max_y)
cur_box = Box(rand_x, rand_x + 250, rand_y, rand_y + 25)

if any(overlap(cur_box, box) for box in boxes):
# Retry if box overlaps any other box already set
continue
else:
button.move(rand_x, rand_y)
boxes.append(cur_box)
break

def bind_buttons(self):
"""
Binds each button to their respective functions.
"""
for button in self.buttons:
# call function related to button pressed
button.clicked.connect(self.button_pressed)
# randomize button positions
button.clicked.connect(self.move_buttons)
# randomize button names
button.clicked.connect(self.randomize_names)

def button_pressed(self):
func_dict = {
"form_title_button": AddTitle,
"form_desc_button": AddDesc,
"form_date_button": AddDeadline,
"form_done_button": self.done,
}
button_name = self.sender().objectName()
if button_name != "form_done_button":
form = func_dict[button_name](self.task)
self.windows.append(form)
else:
func_dict[button_name]()

def done(self):
"""
Adds task to through the data communication and closes the window.
"""
self.datacomm.add_task(self.task)
self.close()
62 changes: 62 additions & 0 deletions project/ui/datacomm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

import datetime
from .read_write.rw import ReadWrite
from random import choice, randint


class DataComm:
def __init__(self):
self.file = ReadWrite()
self.data = self.file.read_input()
self.header = ('Title', 'Description', 'Deadline', 'Completed')
self.update()

# Takes a random task and deletes it
def delete_task(self):
if self.data:
self.data.pop(randint(0, len(self.data) - 1))
self.update()

# Adds in a new task
def add_task(self, d):
task = dict()
passive_agressive_titles = [
"You misclicked, right? Of course you did.",
"A task with no title? Seriously?",
"Do you even have a task?",
"Dude, tasks without a title?",
"Wow, no goals? Or have you simply forgotten?",
"Dang, never knew task titles were optional.."
]
passive_agressive_descriptions = [
"What?",
"You can't even describe your task?",
"Elaborate it somehow...",
"Now, this is just plain lazy",
"Not sure why you left this blank, hm?",
]
passive_agressive_deadlines = [
"I guess deadlines just aren't real to you",
"So your task is probably just a dream",
"You miss the deadlines just like how storm trooper misses Jedi",
"Did you know that the ultimate inspiration is the deadline?",
"Oh, I didn't know you don't like having deadlines.. Explains a lot",
"Not saying you're unproductive, but...",
]
task["Title"] = d.get("Title", choice(passive_agressive_titles))
task["Description"] = d.get("Description", choice(
passive_agressive_descriptions))
task["Deadline"] = d.get(
"Deadline", choice(passive_agressive_deadlines))
if isinstance(task["Deadline"], int):
task['Deadline'] = str(
datetime.datetime.utcfromtimestamp(int(task['Deadline']))
)
task['Completed'] = False
self.data.append(task)
self.update()

def update(self, table_model=None):
self.file.write_file(self.data)
self.tup = [tuple(d.values()) for d in self.data]
return self.tup
39 changes: 39 additions & 0 deletions project/ui/edit_task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import random
from PySide2 import QtCore, QtWidgets


class MyWidget(QtWidgets.QWidget):
count = 0

def __init__(self):
QtWidgets.QWidget.__init__(self)
self.setWindowTitle("Edit Task")
self.resize(300, 200)

self.greetings = [
"Are you sure you wanna edit?",
"It is weird that you want to edit.",
"Why do you want to edit?",
"I do not think that is a wise choice",
"Beep! Beep! Wrong choice!"
]

self.button = QtWidgets.QPushButton("Click to edit")
self.text = QtWidgets.QLabel("Edit Task?")
self.text.setAlignment(QtCore.Qt.AlignCenter)

self.layout = QtWidgets.QVBoxLayout()
self.layout.addWidget(self.text)
self.layout.addWidget(self.button)
self.setLayout(self.layout)

self.button.clicked.connect(self.magic)

def magic(self):
if MyWidget.count < 5:
self.text.setText(random.choice(self.greetings))
MyWidget.count += 1
else:
self.text = QtWidgets.QLabel("Sorry! Wrong Answer! Function is disabled..")
self.button.setEnabled(False)
self.button.setDisabled(True)
Loading