class ThermoProp: def __init__(self, master, thermoframe, row, name, value, units, defaultunit=0): self.value = DoubleVar() self.thermoframe = thermoframe self.entry = UnitVar(master, units, defaultunit) self.entry.grid(column=1, row=row, sticky=W) self.entry.v.config(state=DISABLED, bg='lightgray') self.checked = IntVar() self.checked.set(0) self.name = name self.c = Checkbutton(master, text=name, variable=self.checked, onvalue=1, offvalue=0, command=self.check) self.c.grid(column=0, row=row, sticky=W + N) def check(self): if self == self.thermoframe.last1: self.checked.set(1) return elif self == self.thermoframe.last2: self.checked.set(1) self.thermoframe.last2 = self.thermoframe.last1 self.thermoframe.last1 = self return # elif badpair(self, self.thermoframe.last1): # self.checked.set(0) # return self._check() self.thermoframe.last2.checked.set(0) self.thermoframe.last2._check() self.thermoframe.last2 = self.thermoframe.last1 self.thermoframe.last1 = self def _check(self): if self.isChecked(): self.entry.v.config(state=NORMAL, bg='white') else: self.entry.v.config(state=DISABLED, bg='lightgray') def isChecked(self): return self.checked.get() def set(self, value): self.entry.set(value) def get(self): return self.entry.get()
class ThermoProp: def __init__(self, master, thermoframe, row, name, value, units, defaultunit=0): self.value = DoubleVar() self.thermoframe = thermoframe self.entry = UnitVar(master,units,defaultunit) self.entry.grid(column=1,row=row,sticky=W) self.entry.v.config(state=DISABLED,bg='lightgray') self.checked=IntVar() self.checked.set(0) self.name = name self.c=Checkbutton(master, text=name, variable=self.checked, onvalue=1, offvalue=0, command=self.check ) self.c.grid(column=0,row=row, sticky=W+N) def check(self): if self == self.thermoframe.last1: self.checked.set(1) return elif self == self.thermoframe.last2: self.checked.set(1) self.thermoframe.last2 = self.thermoframe.last1 self.thermoframe.last1 = self return # elif badpair(self, self.thermoframe.last1): # self.checked.set(0) # return self._check() self.thermoframe.last2.checked.set(0) self.thermoframe.last2._check() self.thermoframe.last2 = self.thermoframe.last1 self.thermoframe.last1 = self def _check(self): if self.isChecked(): self.entry.v.config(state=NORMAL,bg='white') else: self.entry.v.config(state=DISABLED,bg='lightgray') def isChecked(self): return self.checked.get() def set(self, value): self.entry.set(value) def get(self): return self.entry.get()
def __init__(self, master, thermoframe, row, name, value, units, defaultunit=0): self.value = DoubleVar() self.thermoframe = thermoframe self.entry = UnitVar(master, units, defaultunit) self.entry.grid(column=1, row=row, sticky=W) self.entry.v.config(state=DISABLED, bg='lightgray') self.checked = IntVar() self.checked.set(0) self.name = name self.c = Checkbutton(master, text=name, variable=self.checked, onvalue=1, offvalue=0, command=self.check) self.c.grid(column=0, row=row, sticky=W + N)
def __init__(self, master, thermoframe, row, name, value, units, defaultunit=0): self.value = DoubleVar() self.thermoframe = thermoframe self.entry = UnitVar(master,units,defaultunit) self.entry.grid(column=1,row=row,sticky=W) self.entry.v.config(state=DISABLED,bg='lightgray') self.checked=IntVar() self.checked.set(0) self.name = name self.c=Checkbutton(master, text=name, variable=self.checked, onvalue=1, offvalue=0, command=self.check ) self.c.grid(column=0,row=row, sticky=W+N)
def show(self, event): self.new = Toplevel() self.new.title(self.sp.symbol) #self.new.transient(self.master) self.new.bind("<Return>", self.update, "+") self.cpr = 0.0 self.t = 0.0 self.cpl = 0.0 self.tl = 0.0 self.cpp = [[(0.0, 0.0, 'red')]] # elemental composition self.eframe = Frame(self.new) self.eframe.config(relief=GROOVE, bd=4) self.eframe.grid(row=0, column=0, columnspan=10, sticky=E + W) r = 1 Label(self.eframe,text='Atoms:')\ .grid(row=0,column=0,sticky=N+W) for el, c in self.sp.composition(): Label(self.eframe, text=` int(c) ` + ' ' + el).grid(row=0, column=r) r = r + 1 # thermodynamic properties self.thermo = Frame(self.new) self.thermo.config(relief=GROOVE, bd=4) self.thermo.grid(row=1, column=0, columnspan=10, sticky=N + E + W) Label(self.thermo, text='Standard Heat of Formation at 298 K: ').grid(row=0, column=0, sticky=W) Label(self.thermo, text='%8.2f kJ/mol' % (self.sp.hf0 * 1.0e-6)).grid(row=0, column=1, sticky=W) Label(self.thermo, text='Molar Mass: ').grid(row=1, column=0, sticky=W) Label(self.thermo, text=self.sp.molecularWeight).grid(row=1, column=1, sticky=W) labels = ['Temperature', 'c_p', 'Enthalpy', 'Entropy'] units = [temperature, specificEntropy, specificEnergy, specificEntropy] whichone = [0, 1, 1, 1] r = 2 self.prop = [] for prop in labels: Label(self.thermo, text=prop).grid(row=r, column=0, sticky=W) p = UnitVar(self.thermo, units[r - 2], whichone[r - 2]) p.grid(row=r, column=1, sticky=W) p.v.config(state=DISABLED, bg='lightgray') self.prop.append(p) r = r + 1 tmin = self.sp.minTemp tmax = self.sp.maxTemp cp = self.sp.cp_R(tmin) hh = self.sp.enthalpy_RT(tmin) ss = self.sp.entropy_R(tmin) self.prop[0].bind("<Any-Enter>", self.decouple) self.prop[0].bind("<Any-Leave>", self.update) self.prop[0].bind("<Key>", self.update) self.prop[0].v.config(state=NORMAL, bg='white') self.prop[0].set(300.0) self.graphs = Frame(self.new) self.graphs.config(relief=GROOVE, bd=4) self.graphs.grid(row=2, column=0, columnspan=10, sticky=E + W) self.cpdata = [] self.hdata = [] self.sdata = [] t = tmin n = int((tmax - tmin) / 100.0) while t <= tmax: self.cpdata.append((t, self.sp.cp_R(t))) self.hdata.append((t, self.sp.enthalpy_RT(t))) self.sdata.append((t, self.sp.entropy_R(t))) t = t + n # specific heat Label(self.graphs, text='c_p/R').grid(row=0, column=0, sticky=W + E) ymin, ymax, dtick = self.plotLimits(self.cpdata) self.cpg = Graph(self.graphs, '', tmin, tmax, ymin, ymax, pixelX=150, pixelY=150) self.cpg.canvas.config(bg='white') self.cpg.grid(row=1, column=0, columnspan=2, sticky=W + E) self.ticks(ymin, ymax, dtick, tmin, tmax, self.cpg) # enthalpy Label(self.graphs, text='enthalpy/RT').grid(row=0, column=3, sticky=W + E) ymin, ymax, dtick = self.plotLimits(self.hdata) self.hg = Graph(self.graphs, '', tmin, tmax, ymin, ymax, pixelX=150, pixelY=150) self.hg.canvas.config(bg='white') self.hg.grid(row=1, column=3, columnspan=2, sticky=W + E) self.ticks(ymin, ymax, dtick, tmin, tmax, self.hg) # entropy Label(self.graphs, text='entropy/R').grid(row=0, column=5, sticky=W + E) ymin, ymax, dtick = self.plotLimits(self.sdata) self.sg = Graph(self.graphs, '', tmin, tmax, ymin, ymax, pixelX=150, pixelY=150) self.sg.canvas.config(bg='white') self.sg.grid(row=1, column=5, columnspan=2, sticky=W + E) self.ticks(ymin, ymax, dtick, tmin, tmax, self.sg) n = int((tmax - tmin) / 100.0) t = tmin self.cpp = [] for t, cp in self.cpdata: self.cpg.join([(t, cp, 'red')]) for t, h in self.hdata: self.hg.join([(t, h, 'green')]) for t, s in self.sdata: self.sg.join([(t, s, 'blue')]) self.cpdot = self.cpg.plot(tmin, cp, 'red') self.hdot = self.hg.plot(tmin, hh, 'green') self.sdot = self.sg.plot(tmin, ss, 'blue') b = Button(self.new, text=' OK ', command=self.finished, default=ACTIVE) #ed=Button(self.new,text='Edit',command=testit) b.grid(column=0, row=4, sticky=W) #ed.grid(column=1,row=4,sticky=W) self.scfr = Frame(self.new) self.scfr.config(relief=GROOVE, bd=4) self.scfr.grid(row=3, column=0, columnspan=10, sticky=N + E + W) self.sc = Scale(self.scfr, command=self.update, variable=self.prop[0].x, orient='horizontal', digits=7, length=400) self.sc.config(cnf={'from': tmin, 'to': tmax}) self.sc.bind('<Any-Enter>', self.couple) self.scfr.bind('<Any-Leave>', self.decouple) self.sc.grid(row=0, column=0, columnspan=10)
def show(self, event): self.new=Toplevel() self.new.title(self.sp.symbol) #self.new.transient(self.master) self.new.bind("<Return>", self.update,"+") self.cpr = 0.0 self.t = 0.0 self.cpl = 0.0 self.tl = 0.0 self.cpp = [[(0.0, 0.0, 'red')]] # elemental composition self.eframe = Frame(self.new) self.eframe.config(relief=GROOVE,bd=4) self.eframe.grid(row=0,column=0,columnspan=10,sticky=E+W) r = 1 Label(self.eframe,text='Atoms:')\ .grid(row=0,column=0,sticky=N+W) for el, c in self.sp.composition(): Label(self.eframe,text=`int(c)`+' '+el).grid(row=0,column=r) r = r + 1 # thermodynamic properties self.thermo = Frame(self.new) self.thermo.config(relief=GROOVE,bd=4) self.thermo.grid(row=1,column=0,columnspan=10,sticky=N+E+W) Label(self.thermo,text = 'Standard Heat of Formation at 298 K: ').grid(row=0, column=0, sticky=W) Label(self.thermo,text = '%8.2f kJ/mol' % (self.sp.hf0*1.0e-6)).grid(row=0, column=1, sticky=W) Label(self.thermo,text = 'Molar Mass: ').grid(row=1, column=0, sticky=W) Label(self.thermo,text = self.sp.molecularWeight).grid(row=1, column=1, sticky=W) labels = ['Temperature', 'c_p', 'Enthalpy', 'Entropy'] units = [temperature, specificEntropy, specificEnergy, specificEntropy] whichone = [0, 1, 1, 1] r = 2 self.prop = [] for prop in labels: Label(self.thermo,text=prop).grid(row=r,column=0,sticky=W) p = UnitVar(self.thermo,units[r-2],whichone[r-2]) p.grid(row=r,column=1,sticky=W) p.v.config(state=DISABLED,bg='lightgray') self.prop.append(p) r = r + 1 tmin = self.sp.minTemp tmax = self.sp.maxTemp cp = self.sp.cp_R(tmin) hh = self.sp.enthalpy_RT(tmin) ss = self.sp.entropy_R(tmin) self.prop[0].bind("<Any-Enter>", self.decouple) self.prop[0].bind("<Any-Leave>", self.update) self.prop[0].bind("<Key>", self.update) self.prop[0].v.config(state=NORMAL,bg='white') self.prop[0].set(300.0) self.graphs = Frame(self.new) self.graphs.config(relief=GROOVE,bd=4) self.graphs.grid(row=2,column=0,columnspan=10,sticky=E+W) self.cpdata = [] self.hdata = [] self.sdata = [] t = tmin n = int((tmax - tmin)/100.0) while t <= tmax: self.cpdata.append((t,self.sp.cp_R(t))) self.hdata.append((t,self.sp.enthalpy_RT(t))) self.sdata.append((t,self.sp.entropy_R(t))) t = t + n # specific heat Label(self.graphs,text='c_p/R').grid(row=0,column=0,sticky=W+E) ymin, ymax, dtick = self.plotLimits(self.cpdata) self.cpg = Graph(self.graphs,'',tmin,tmax,ymin,ymax, pixelX=150,pixelY=150) self.cpg.canvas.config(bg='white') self.cpg.grid(row=1,column=0,columnspan=2,sticky=W+E) self.ticks(ymin, ymax, dtick, tmin, tmax, self.cpg) # enthalpy Label(self.graphs,text='enthalpy/RT').grid(row=0,column=3,sticky=W+E) ymin, ymax, dtick = self.plotLimits(self.hdata) self.hg = Graph(self.graphs,'',tmin,tmax,ymin,ymax, pixelX=150,pixelY=150) self.hg.canvas.config(bg='white') self.hg.grid(row=1,column=3,columnspan=2,sticky=W+E) self.ticks(ymin, ymax, dtick, tmin, tmax, self.hg) # entropy Label(self.graphs,text='entropy/R').grid(row=0,column=5,sticky=W+E) ymin, ymax, dtick = self.plotLimits(self.sdata) self.sg = Graph(self.graphs,'',tmin,tmax,ymin,ymax, pixelX=150,pixelY=150) self.sg.canvas.config(bg='white') self.sg.grid(row=1,column=5,columnspan=2,sticky=W+E) self.ticks(ymin, ymax, dtick, tmin, tmax, self.sg) n = int((tmax - tmin)/100.0) t = tmin self.cpp = [] for t, cp in self.cpdata: self.cpg.join([(t,cp,'red')]) for t, h in self.hdata: self.hg.join([(t,h,'green')]) for t, s in self.sdata: self.sg.join([(t,s,'blue')]) self.cpdot = self.cpg.plot(tmin,cp,'red') self.hdot = self.hg.plot(tmin,hh,'green') self.sdot = self.sg.plot(tmin,ss,'blue') b=Button(self.new,text=' OK ',command=self.finished, default=ACTIVE) #ed=Button(self.new,text='Edit',command=testit) b.grid(column=0, row=4,sticky=W) #ed.grid(column=1,row=4,sticky=W) self.scfr = Frame(self.new) self.scfr.config(relief=GROOVE,bd=4) self.scfr.grid(row=3,column=0,columnspan=10,sticky=N+E+W) self.sc = Scale(self.scfr,command=self.update,variable = self.prop[0].x, orient='horizontal',digits=7,length=400) self.sc.config(cnf={'from':tmin,'to':tmax}) self.sc.bind('<Any-Enter>',self.couple) self.scfr.bind('<Any-Leave>',self.decouple) self.sc.grid(row=0,column=0,columnspan=10)