-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseedbank.py
109 lines (82 loc) · 3.74 KB
/
seedbank.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/python3
import sqlite3
from os import path
import tkinter as tk
import time
class GardenDB:
def __init__(self, db_file):
self.db_file = db_file
self.db = None
def first_time(self):
self.db.execute('''CREATE TABLE journal
(date text,
time text,
weather text,
notes text)''')
self.db.execute('''CREATE TABLE plants
(common_name text,
latin_name text)''')
self.db.execute('''CREATE TABLE seed_notes
(common_name text,
company text,
date text,
quantity text)''')
self.db.execute('''CREATE TABLE plant_notes
(common_name text,
days_to_germinate int,
bugs text,
general_note text''')
def add_journal_note(date, notes):
c.execute("INSERT INTO journal (date, notes) VALUES (date, notes)")
def add_weather(date, time, weather):
c.execute("INSERT INTO journal (date, notes) VALUES (date, notes)")
def setup(self):
first_time = False
if not path.exists(self.db_file):
first_time = True
self.db = sqlite3.connect(self.db_file)
if first_time:
self.first_time()
def teardown(self):
self.db.close()
class GardenGui:
def __init__(self):
self.window = tk.Tk()
self.frame = tk.Frame()
self.menubar = tk.Menu(self.window)
file_menu = tk.Menu(self.menubar, tearoff=0)
new_menu = tk.Menu(file_menu, tearoff=0)
file_menu.add_cascade(label="New", menu=new_menu)
file_menu.add_command(label="Save", command=self.entry_type_changed)
file_menu.add_separator()
file_menu.add_command(label="Exit", command=self.window.quit)
self.menubar.add_cascade(label="File", menu=file_menu)
new_menu.add_command(label="Plant", command=self.entry_type_changed)
new_menu.add_command(label="Weather Observation", command=self.entry_type_changed)
new_menu.add_command(label="Seed Note", command=self.entry_type_changed)
new_menu.add_command(label="Bug Note", command=self.entry_type_changed)
new_menu.add_command(label="Germination Note", command=self.entry_type_changed)
new_menu.add_command(label="General Note", command=self.entry_type_changed)
self.window.config(menu=self.menubar)
# New entry type
self.entry_type = tk.StringVar()
self.weather_selected = tk.Radiobutton(master=self.frame, text="Weather",
variable=self.entry_type, value = "weather",
command=self.entry_type_changed)
self.weather_selected.pack(side=tk.LEFT)
self.journal_note_selected = tk.Radiobutton(master=self.frame, text="Note",
variable=self.entry_type, value = "note",
command=self.entry_type_changed)
self.journal_note_selected.pack(side=tk.LEFT)
self.frame.pack()
self.window.mainloop()
def entry_type_changed(self):
print("Entry type changed!!!!")
def main():
gdb = GardenDB("garden.db")
gdb.setup()
gg = GardenGui()
#gg.start()
gdb.teardown()
if __name__ == "__main__":
main()