-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
74 lines (62 loc) · 3.08 KB
/
main.py
File metadata and controls
74 lines (62 loc) · 3.08 KB
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
import tkinter as tk
from tkinter import messagebox
import sqlite3 as sql
from login import LoginFrame
from menu import MenuFrame
from peopleForm import PeopleFormFrame
from peopleList import PeopleListFrame
from joining import JoiningFrame
class Main(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
self.geometry("900x600")
self.title("Main Menu")
self.loggedInUser = ""
self.db = sql.connect("demoFile.sqlite")
self.frames = [ LoginFrame(self), MenuFrame(self),
PeopleFormFrame(self), PeopleListFrame(self),
JoiningFrame(self)]
self.switchFrame(0)
def successfulLogin(self,username):
self.loggedInUser = username
print("Logged in as", username)
self.switchFrame(1)
def switchFrame(self, frameNum):
# hide all frames except the one chosen
for i in range(len(self.frames)):
frame = self.frames[i]
if i == frameNum:
frame.grid(row=0, column=0, sticky="NSWE")
frame.loadUp()
else:
frame.grid_forget()
def createDemoData():
db = sql.connect("demoFile.sqlite")
c = db.cursor()
c.execute("DROP TABLE IF EXISTS tblPeople")
c.execute("CREATE TABLE tblPeople (personID INTEGER PRIMARY KEY AUTOINCREMENT, username TEXT, firstName TEXT, surname TEXT, form TEXT, password TEXT)")
c.execute("INSERT INTO tblPeople VALUES (NULL,?,?,?,?,?)", ['snallon','Steve', 'Nallon', '7SAP','maggie'])
c.execute("INSERT INTO tblPeople VALUES (NULL,?,?,?,?,?)", ['myarwood','Mike', 'Yarwood', '8JML','bob'])
c.execute("INSERT INTO tblPeople VALUES (NULL,?,?,?,?,?)", ['jculshaw','Jon', 'Culshaw', '8JML',"frank"])
c.execute("INSERT INTO tblPeople VALUES (NULL,?,?,?,?,?)", ['rbremner','Rory', 'Bremner', '7SAP',"paddy"])
c.execute("INSERT INTO tblPeople VALUES (NULL,?,?,?,?,?)", ['scoogan','Steve', 'Coogan', '7SAP',"alan"])
c.execute("DROP TABLE IF EXISTS tblActivities")
c.execute("CREATE TABLE tblActivities (activityID INTEGER PRIMARY KEY AUTOINCREMENT, activityname TEXT, day INT)")
c.execute("INSERT INTO tblActivities VALUES (NULL,?,?)", ["Badminton", 1])
c.execute("INSERT INTO tblActivities VALUES (NULL,?,?)", ["Cricket", 1])
c.execute("INSERT INTO tblActivities VALUES (NULL,?,?)", ["Tennis", 3])
c.execute("INSERT INTO tblActivities VALUES (NULL,?,?)", ["Knitting", 3])
c.execute("INSERT INTO tblActivities VALUES (NULL,?,?)", ["Board Games", 2])
c.execute("INSERT INTO tblActivities VALUES (NULL,?,?)", ["Dog Training", 4])
c.execute("DROP TABLE IF EXISTS tblJoining")
c.execute("CREATE TABLE tblJoining (joiningID INTEGER PRIMARY KEY AUTOINCREMENT, personID INT, activityID INT)")
db.commit()
r = c.execute("SELECT * FROM tblPeople")
results = r.fetchall()
print(results)
r = c.execute("SELECT * FROM tblActivities")
results = r.fetchall()
print(results)
createDemoData()
app = Main()
app.mainloop()