forked from falselunatic/Hostel-Management-Web-Application
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhash1.py
59 lines (53 loc) · 1.71 KB
/
hash1.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
import tkinter as tk
from tkinter import *
from PIL import Image,ImageTk #pip install pillow
from tkinter import ttk
import random
from time import strftime
from datetime import datetime
import mysql.connector
from tkinter import messagebox
class App(object):
def __init__(self):
self.root = tk.Tk()
self.root.wm_title("where is student")
#self.root.wm_iconbitmap("@icon2.xbm")
self.label = tk.Label(self.root, text="Set ")
self.label.pack()
self.enr = tk.StringVar()
self.hashtable=[[],] * 10
tk.Entry(self.root, textvariable=self.enr).pack()
self.buttontext = tk.StringVar()
self.buttontext.set("Calculate")
tk.Button(self.root,
textvariable=self.buttontext,
command=self.clicked1).pack()
def hashFunction(capacity,key):
sum=0
while(key>0):
sum+=key%1000
key=key//1000
return sum % capacity
def insertData(self,key, data):
index = self.hashFunction(10,key)
self.hashTable[index] = [key, data]
return
def checkhash(self,n):
i=self.hashFunction(n,10)
if self.hashTable[i][1]==0:
return "CHECKED-OUT"
else:
return "CHECKED-IN"
text_display = checkhash(self.enr)
self.label = tk.Label(self.root, text=text_display)
self.label.pack()
self.root.mainloop()
def clicked1(self):
enr = self.enr.get()
self.label.configure(text=enr)
def button_click(self, e):
pass
App.insertData(0,12301032021,0)
App.insertData(0,43201022022,1)
App.insertData(0,21301022020,0)
App()