good morning all
i am by know means a programmer, with that said i try.
i have this file made from bits and pieces:
Code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
from tkinter import *
from datetime import datetime
import os
root = Tk()
root.geometry( "400x200" )
def show01():
label001.config( text = clicked001.get() )
insulin = open("insulin.txt", "a")
now = datetime.now()
date = now.strftime(" %d/%m/%Y ")
time = now.strftime(" %H:%M:%S:%f ")
insulin.write(f' {time}')
insulin.write(f' {date}')
insulin.write(f' {label001 }\n')
insulin.close()
pop001 = [
"20 units novolog",
"21 units novolog",
"22 units novolog",
"23 units novolog",
"24 units novolog",
"25 units novolog",
"26 units novolog",
"27 units novolog",
"28 units novolog",
"29 units novolog",
"51 units basaglar",
"52 units basaglar",
"53 units basaglar",
"54 units basaglar",
"55 units basaglar",
"56 units basaglar",
"57 units basaglar",
"58 units basaglar",
"59 units basaglar",
"60 units basaglar"
]
clicked001 = StringVar()
clicked001.set( "24 units novolog" )
drop001 = OptionMenu( root , clicked001 , *pop001 )
drop001.place(x=20, y=20)
button001 = Button( root , text = "click Me" , command = show01 ).place(x=175, y=20)
label001 = Label( root , text = " " )
label001.place(x=275, y=20)
def show02():
label002.config( text = clicked002.get() )
pop002 = [
"3 x eggs",
"oatmeal",
"salad",
"peanuts",
"porkchops",
"1 x hamburg",
"2 x hamburg",
"shepards pie",
"3 x pizza",
"5 x pizza",
"ice cream",
"ice cream cake",
"cake"
]
clicked002 = StringVar()
clicked002.set( "3 x eggs" )
drop002 = OptionMenu( root , clicked002 , *pop002 )
drop002.place(x=20, y=55)
button002 = Button( root , text = "click Me" , command = show02 ).place(x=175, y=55)
label002 = Label( root , text = " " )
label002.place(x=275, y=55)
root.mainloop()
the code is not finished.
it will run, a work in progress.
goal is to record insulin and food intake.
in two text files with time and date stamp.
my first problem is when i try to record the contents of insulin spin box.
line 19 :
Code:
insulin.write(f' {label001 }\n')
what ever i put in there it isn't giving me what i need:
Code:
22:46:08:956981 11/09/2022 PY_VAR0
22:46:30:507360 11/09/2022 PY_VAR0
23:11:18:516333 11/09/2022 <bound method Variable.set of <tkinter.StringVar object at 0x7f66369ab250>>
23:12:51:642025 11/09/2022 PY_VAR2
23:13:23:440598 11/09/2022 PY_VAR3
23:13:24:232237 11/09/2022 PY_VAR4
23:14:48:589680 11/09/2022 .!label
i have tried several things, the out put should look like:
Code:
23:14:48:589680 11/09/2022 (contents of spin box)
def show02 works but it doesn't time and date stamp.
i'm going to have the same thing with time/date with it too.
p.s.
after i have the two files, i'm going to try to use that data in a existing data base .sqlite from my glucose meter.
thanks in advance for any help or guidance.