-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviewer.py
More file actions
38 lines (26 loc) · 875 Bytes
/
viewer.py
File metadata and controls
38 lines (26 loc) · 875 Bytes
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
import tkinter as tk
from tkinter import ttk
import mysql.connector
def connectdb():
return mysql.connector.connect(host="localhost",user="root",password="12345",database="attendance_db")
def getdata():
conn = connectdb()
cursor = conn.cursor()
cursor.execute("SELECT * FROM attendance")
rows = cursor.fetchall()
conn.close()
return rows
root = tk.Tk()
root.title("Attendance Viewer")
root.geometry("600x400")
root.configure(bg="#f0f0f0")
tree = ttk.Treeview(root, columns=("ID", "Name", "Timestamp"), show='headings')
tree.heading("ID", text="ID")
tree.heading("Name", text="Name")
tree.heading("Timestamp", text="Timestamp")
tree.pack(fill=tk.BOTH, expand=True, padx=10, pady=10)
def load_data():
for row in getdata():
tree.insert("", tk.END, values=row)
load_data()
root.mainloop()