75 lines
1.9 KiB
Python
75 lines
1.9 KiB
Python
import tkinter as tk
|
|
import tkinter.ttk as ttk
|
|
import os
|
|
from configparser import ConfigParser
|
|
|
|
substances = ['Water','Propanol','Aceton']
|
|
labels = ['x','y','z','volume','z/ml','reakVolume']
|
|
entrys = []
|
|
|
|
config = ConfigParser()
|
|
|
|
def load_config():
|
|
config.read(os.path.join(os.path.dirname(__file__), "test.ini"),)
|
|
|
|
root = tk.Tk()
|
|
infobar = tk.StringVar()
|
|
#configue root
|
|
root.title("Jfs Labrobot")
|
|
root.geometry('800x500+300+300')
|
|
|
|
load_config()
|
|
substances = config.sections()
|
|
|
|
|
|
def init_chem():
|
|
c =0
|
|
r = 0
|
|
for p in substances:
|
|
frame = ttk.LabelFrame(root,text=p)
|
|
frame.grid(column=c,row=r)
|
|
c +=1
|
|
if c > 3:
|
|
c=0
|
|
r +=1
|
|
|
|
for i in range(len(labels)):
|
|
tk.Label(frame,text=labels[i]).grid(row=i,column=0)
|
|
var = tk.StringVar()
|
|
entry = tk.Entry(frame,width=10,textvariable=var)
|
|
var.set(config[p][labels[i]])
|
|
entry.grid(row=i,column=1,sticky='w')
|
|
entrys.append([p,labels[i],entry])
|
|
|
|
init_chem()
|
|
|
|
def showit():
|
|
for x in entrys:
|
|
for p in substances:
|
|
for x in entrys:
|
|
if x[0] == p :
|
|
print(f'{x[1]} : {x[2].get()} ')
|
|
#print(x[0],x[1],x[2].get())
|
|
|
|
btn =tk.Button(root,text='Ok',command=showit)
|
|
btn.grid(row=99,column=0,sticky='we')
|
|
|
|
|
|
|
|
tk.Button(root,text='Load',command = load_config).grid(row=100,column=0,sticky='ew')
|
|
|
|
|
|
def conf_write():
|
|
config = ConfigParser()
|
|
#config.read(os.path.join(os.path.dirname(__file__), "test.ini"),)
|
|
for p in substances:
|
|
config[p] = {}
|
|
for x in entrys:
|
|
if x[0] == p:
|
|
config[p][x[1]] = x[2].get()
|
|
with open(os.path.join(os.path.dirname(__file__), "test.ini"),'w') as f:
|
|
config.write(f)
|
|
tk.Button(root,text='Save',command = conf_write).grid(row=100,column=1,sticky='ew')
|
|
|
|
|
|
root.mainloop() |