-
Notifications
You must be signed in to change notification settings - Fork 1
/
Application.py
46 lines (36 loc) · 1.3 KB
/
Application.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from interactions import EraseTaskInteraction, NewTaskInteraction, WatchTaskInteraction
from libs import pyhk
import sqlite3
import sys
__author__ = 'keinmark'
# Initialize the database on startup if
# app is started first time
def initialize_db():
connection = sqlite3.connect("stasks.db")
cursor = connection.cursor()
cursor.execute("""
CREATE TABLE IF NOT EXISTS tasks (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title varchar(255) NOT NULL,
insertTS TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
done INTEGER DEFAULT 0,
doneTS TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)
""")
connection.commit()
# Starting the control flow
initialize_db()
# Create instances of interactions
newTaskInteraction = NewTaskInteraction.NewTaskInteraction()
watchTaskInteraction = WatchTaskInteraction.WatchTaskInteraction()
eraseTaskInteraction = EraseTaskInteraction.EraseTaskInteraction()
#create pyhk class instance
hot = pyhk.pyhk()
#add hotkey
hot.addHotkey(newTaskInteraction.get_hotkey(), newTaskInteraction.on_key_execute)
hot.addHotkey(watchTaskInteraction.get_hotkey(), watchTaskInteraction.on_key_execute)
hot.addHotkey(eraseTaskInteraction.get_hotkey(), eraseTaskInteraction.on_key_execute)
#exit our tool
hot.addHotkey(['Shift', 'Alt', '0'], sys.exit)
#start looking for hotkey.
hot.start()