-
Notifications
You must be signed in to change notification settings - Fork 2
/
ICA_super.py
71 lines (51 loc) · 2.12 KB
/
ICA_super.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
from tkinter import *
from tkinter import messagebox
from tkinter.ttk import Combobox
from datetime import datetime
from time import sleep
import SQLConnection
versionNumber = "(Version 3.0 FINAL)"
class icaSCREENS():
'''
Base class for all screens. Currently will only contain the root,
clear the screen, and swap to other screens.
'''
screenSTACK = []
def __init__(self,window): #all screens must contain the root window
global versionNumber
self.versionNumber = versionNumber
self.root = window
self.root.protocol("WM_DELETE_WINDOW", self.exitICA)
# insert as "<KEYTYPE>",functionCall.
self.keyBinds = {}
self.SQL = None
self.clockConnectionVar = None
self.clockConnection()
def clearSCREEN(self):
#will clear the screen of everything
for widget in self.root.winfo_children():
widget.destroy()
def swapTO(self,newSCREEN, data): #pass the class of the screen you want to go to along with the window
self.clearSCREEN()
newSCREEN(self.root, data)
def bindKey(self,key,functionCall): # pass a key you want to bind and the function it should call
self.root.bind(key,functionCall)
self.keyBinds[key] = functionCall
def removeKeyBind(self,key): # will remove the bind and free the key for another bind
self.root.unbind(key)
del self.keyBinds[key]
def rebindKey(self,key,functionCall): # will rebind the key to another feature
self.root.unbind(key)
self.bindKey(key,functionCall)
def exitICA(self): #prompt user if they want to close program
userChoice = messagebox.askyesno("Exiting ICA","Are you sure you want to exit ICA?")
if userChoice:
self.SQL.closeConnection()
self.root.destroy()
def escapePress(self,event):
self.exitICA()
def clockConnection(self):
if not self.SQL == None:
self.SQL.closeConnection()
self.SQL = SQLConnection.SQLConnection()
self.clockConnectionVar = self.root.after(15*60*1000, self.clockConnection)