|
1 | 1 | # importing the modules
|
2 | 2 | import tkinter as tk
|
3 | 3 | from tkinter import messagebox
|
| 4 | +from tkinter import ttk |
4 | 5 | import datetime
|
5 | 6 | import database
|
6 | 7 |
|
@@ -41,21 +42,85 @@ def store_food():
|
41 | 42 | def show_exercise():
|
42 | 43 | con = database.connect()
|
43 | 44 | cor = con.cursor()
|
44 | | - cor.execute('''SELECT * from exercise''') |
45 | | - rows = cor.fetchall() |
| 45 | + try: |
| 46 | + cor.execute('''SELECT * from exercise''') |
| 47 | + rows = cor.fetchall() |
| 48 | + new = tk.Tk() |
| 49 | + new.title("Exercise Log") |
| 50 | + new.geometry("650x500") |
46 | 51 |
|
47 | | - for row in rows: |
48 | | - print(row) |
| 52 | + frm = tk.Frame(new) |
| 53 | + frm.pack(side=tk.LEFT, padx=20) |
| 54 | + |
| 55 | + tv = ttk.Treeview(frm, selectmode='browse') |
| 56 | + tv.pack() |
| 57 | + verscrlbar = ttk.Scrollbar(new, |
| 58 | + orient="vertical", |
| 59 | + command=tv.yview) |
| 60 | + |
| 61 | + verscrlbar.pack(side='right', fill='x') |
| 62 | + |
| 63 | + tv.configure(xscrollcommand=verscrlbar.set) |
| 64 | + |
| 65 | + tv["columns"] = ("1", "2", "3") |
| 66 | + tv['show'] = 'headings' |
| 67 | + |
| 68 | + tv.column("1", width=50, anchor='c') |
| 69 | + tv.column("2", width=250, anchor='c') |
| 70 | + tv.column("3", width=400, anchor='w') |
| 71 | + |
| 72 | + tv.heading("1", text="Sl.No") |
| 73 | + tv.heading("2", text="Time") |
| 74 | + tv.heading("3", text="Data") |
| 75 | + |
| 76 | + for i in rows: |
| 77 | + tv.insert("", "end", values=i) |
| 78 | + |
| 79 | + new.mainloop() |
| 80 | + except: |
| 81 | + messagebox.showerror("Error", "Some Error Occurred") |
49 | 82 |
|
50 | 83 |
|
51 | 84 | def show_food():
|
52 | 85 | con = database.connect()
|
53 | 86 | cor = con.cursor()
|
54 | | - cor.execute('''SELECT * from food''') |
55 | | - rows = cor.fetchall() |
| 87 | + try: |
| 88 | + cor.execute('''SELECT * from food''') |
| 89 | + rows = cor.fetchall() |
| 90 | + new = tk.Tk() |
| 91 | + new.title("Food Log") |
| 92 | + new.geometry("650x500") |
| 93 | + |
| 94 | + frm = tk.Frame(new) |
| 95 | + frm.pack(side=tk.LEFT, padx=20) |
| 96 | + |
| 97 | + tv = ttk.Treeview(frm, selectmode='browse') |
| 98 | + tv.pack() |
| 99 | + verscrlbar = ttk.Scrollbar(new, |
| 100 | + orient="vertical", |
| 101 | + command=tv.yview) |
| 102 | + |
| 103 | + verscrlbar.pack(side='right', fill='x') |
| 104 | + |
| 105 | + tv.configure(xscrollcommand=verscrlbar.set) |
| 106 | + |
| 107 | + tv["columns"] = ("1", "2", "3") |
| 108 | + tv['show'] = 'headings' |
| 109 | + |
| 110 | + tv.column("1", width=50, anchor='c') |
| 111 | + tv.column("2", width=250, anchor='c') |
| 112 | + tv.column("3", width=400, anchor='w') |
| 113 | + |
| 114 | + tv.heading("1", text="Sl.No") |
| 115 | + tv.heading("2", text="Time") |
| 116 | + tv.heading("3", text="Data") |
| 117 | + |
| 118 | + for i in rows: |
| 119 | + tv.insert("", "end", values=i) |
56 | 120 |
|
57 | | - for row in rows: |
58 | | - print(row) |
| 121 | + new.mainloop() |
| 122 | + except: |
| 123 | + messagebox.showerror("Error", "Some Error Occurred") |
59 | 124 |
|
60 | 125 |
|
61 | 126 | def delete_exercise_log():
|
|
0 commit comments