cantera/interfaces/python/MixMaster/ThermoProp.py
Ray Speth 6cb4bd93ce Cleaned up whitespace in all Python files using reindent.py
4 spaces per indentation level, no tabs, no trailing whitespace,
and a single newline at end of each file.
2012-02-27 18:13:05 +00:00

66 lines
2 KiB
Python

from Tkinter import *
from UnitChooser import UnitVar
_tv = ['Temperature','Internal Energy','Enthalpy']
_pv = ['Pressure', 'Density']
def badpair(a,b):
if a.name in _tv:
if not b.name in _pv:
return 1
else:
if not b.name in _tv:
return 1
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()