From 110a1387bc8b3d593fb8e1ece5c99413d8b8391d Mon Sep 17 00:00:00 2001 From: jens Date: Fri, 17 Dec 2021 23:09:01 +0100 Subject: [PATCH] chemicals now ok --- gui/{test.ini => chemicals.ini} | 21 ++++--- gui/config.ini | 3 +- gui/testtk.py | 108 +++++++++++++++++--------------- 3 files changed, 70 insertions(+), 62 deletions(-) rename gui/{test.ini => chemicals.ini} (69%) diff --git a/gui/test.ini b/gui/chemicals.ini similarity index 69% rename from gui/test.ini rename to gui/chemicals.ini index 22b2a03..c561307 100644 --- a/gui/test.ini +++ b/gui/chemicals.ini @@ -1,22 +1,22 @@ [Water] x = 50 -y = +y = 10 z = -volume = -z/ml = 1 +volume = 100 +z/ml = 0.1 reakvolume = 100 [Propanol] x = 100 -y = +y = 10 z = volume = z/ml = 1 -reakvolume = 200 +reakvolume = 500 [Aceton] x = 150 -y = +y = 20 z = volume = z/ml = 1 @@ -24,7 +24,7 @@ reakvolume = 500 [Mausi] x = 200 -y = +y = 30 z = volume = z/ml = 1 @@ -32,8 +32,9 @@ reakvolume = 1000 [Hasi] x = 200 -y = -z = +y = 40 +z = 12 volume = z/ml = 1 -reakvolume = 1000 \ No newline at end of file +reakvolume = 1000 + diff --git a/gui/config.ini b/gui/config.ini index da59585..a941dd8 100644 --- a/gui/config.ini +++ b/gui/config.ini @@ -15,10 +15,11 @@ tiphub = 16.5 [chemblock] chemx = 200.0 chemy = 50.0 -chemvol = 60.0 +chemvol = 200.0 chemz = 70.0 deltaz = 0.5 tauch = 0.0 +reapart = 100.0 [reacblock] rxoffset = 225.0 diff --git a/gui/testtk.py b/gui/testtk.py index fc38f8d..2ce2ce8 100644 --- a/gui/testtk.py +++ b/gui/testtk.py @@ -3,73 +3,79 @@ import tkinter.ttk as ttk import os from configparser import ConfigParser +## chemicals 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() - +clabels = ['x','y','z','volume','z/ml','reakVolume'] +centrys = [] +chem_config = ConfigParser() +def load_chem_config(): + chem_config.read(os.path.join(os.path.dirname(__file__), "chemicals.ini"),) +def conf_chem_write(): + for p in substances: + chem_config[p] = {} + for x in centrys: + if x[0] == p: + chem_config[p][x[1]] = x[2].get() + with open(os.path.join(os.path.dirname(__file__), "chemicals.ini"),'w') as f: + chem_config.write(f) def init_chem(): c =0 r = 0 for p in substances: - frame = ttk.LabelFrame(root,text=p) + frame = ttk.LabelFrame(chemframe,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) + for i in range(len(clabels)): + tk.Label(frame,text=clabels[i]).grid(row=i,column=0) var = tk.StringVar() entry = tk.Entry(frame,width=10,textvariable=var) - var.set(config[p][labels[i]]) + var.set(chem_config[p][clabels[i]]) entry.grid(row=i,column=1,sticky='w') - entrys.append([p,labels[i],entry]) + centrys.append([p,clabels[i],entry]) + +root = tk.Tk() + +##init +load_chem_config() +substances = chem_config.sections() + +#configue root +root.title("Jfs Labrobot") +root.geometry('800x500+300+300') +notebook = ttk.Notebook(root) +notebook.grid(sticky='news',padx=5,pady=5) +notebook.enable_traversalrightmainframe = ttk.Frame(notebook) +## mainframe +mainframe = ttk.Frame(notebook) +mainframe.columnconfigure(0,weight=1) +notebook.add(mainframe,text='main',underline=0) +fra1 = ttk.LabelFrame(mainframe,text=' Test') +fra1.grid(row=0,column=0,sticky='nw') +chemsub = tk.StringVar() +chemlab = tk.StringVar() +chemit = tk.StringVar() + +def doit(*args): + chemit.set(str(chem_config[chemsub.get()][chemlab.get()])) + +chemopt = ttk.OptionMenu(fra1,chemsub,substances[0],*substances,command=doit) +chemopt.grid(row=0,column=0,sticky='e') +chemopt1 = ttk.OptionMenu(fra1,chemlab,clabels[0],*clabels,command=doit) +chemopt1.grid(row=0,column=1,sticky='e') +chemerg = ttk.Label(fra1,textvariable=chemit) +chemerg.grid(row=0,column=2,sticky='ne') + +##chemicals +chemframe = ttk.Frame(notebook) +notebook.add(chemframe,text='chemicals',underline=0) 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') +tk.Button(chemframe,text='Load',command = load_chem_config).grid(row=100,column=0,sticky='ew') +tk.Button(chemframe,text='Save',command = conf_chem_write).grid(row=100,column=1,sticky='ew') root.mainloop() \ No newline at end of file