Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 86f195c

Browse files
Updated The main.py file
1 parent a3db397 commit 86f195c

File tree

1 file changed

+73
-8
lines changed

1 file changed

+73
-8
lines changed

‎Health_Log_Book/main.py‎

Lines changed: 73 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# importing the modules
22
import tkinter as tk
33
from tkinter import messagebox
4+
from tkinter import ttk
45
import datetime
56
import database
67

@@ -41,21 +42,85 @@ def store_food():
4142
def show_exercise():
4243
con = database.connect()
4344
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")
4651

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")
4982

5083

5184
def show_food():
5285
con = database.connect()
5386
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)
56120

57-
for row in rows:
58-
print(row)
121+
new.mainloop()
122+
except:
123+
messagebox.showerror("Error", "Some Error Occurred")
59124

60125

61126
def delete_exercise_log():

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /