def __init__(self, config=None, parent=None): super(Widget, self).__init__(parent) layout = QtWidgets.QGridLayout(self) layout.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Method:")), 1, 1) self.method = QtWidgets.QComboBox() for Z in Z_list: name = Z.__name__[2:].replace("_", "-") year = re.search("((\d+))", Z.__doc__).group(0) doc = "%s (%s)" % (name, year) self.method.addItem(doc) layout.addWidget(self.method, 1, 2) layout.addWidget(QtWidgets.QLabel("Pr min:"), 2, 1) self.Prmin = Entrada_con_unidades(float, width=60, decimales=1) layout.addWidget(self.Prmin, 2, 2) layout.addWidget(QtWidgets.QLabel("Pr max:"), 3, 1) self.Prmax = Entrada_con_unidades(float, width=60, decimales=1) layout.addWidget(self.Prmax, 3, 2) layout.addWidget(QtWidgets.QLabel("Tr:"), 4, 1) self.Tr = QtWidgets.QLineEdit() layout.addWidget(self.Tr, 4, 2) self.lineconfig = LineConfig( "line", QtWidgets.QApplication.translate("pychemqt", "Reduced temperature style line")) layout.addWidget(self.lineconfig, 5, 1, 1, 2) self.cruxconfig = LineConfig( "crux", QtWidgets.QApplication.translate("pychemqt", "Crux style line")) layout.addWidget(self.cruxconfig, 6, 1, 1, 2) layout.addItem( QtWidgets.QSpacerItem(10, 0, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 10, 1, 1, 3) if config and config.has_section("Standing_Katz"): self.method.setCurrentIndex( config.getint("Standing_Katz", "method")) self.Prmin.setValue(config.getfloat("Standing_Katz", "Prmin")) self.Prmax.setValue(config.getfloat("Standing_Katz", "Prmax")) self.Tr.setText(config.get("Standing_Katz", "Tr")) self.lineconfig.setConfig(config, "Standing_Katz") self.cruxconfig.setConfig(config, "Standing_Katz")
def __init__(self, config=None, parent=None): super(Widget, self).__init__(parent) layout = QtWidgets.QGridLayout(self) layout.addWidget( QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Method:")), 1, 1) self.metodos = QtWidgets.QComboBox() for f in f_list: line = f.__doc__.split("\n")[1] year = line.split(" ")[-1] name = line.split(" ")[-3] doc = name + " " + year self.metodos.addItem(doc) layout.addWidget(self.metodos, 1, 2) self.fanning = QtWidgets.QCheckBox( QtWidgets.QApplication.translate( "pychemqt", "Calculate fanning friction factor")) layout.addWidget(self.fanning, 2, 1, 1, 2) layout.addWidget(QtWidgets.QLabel("ε/d:"), 3, 1) self.ed = QtWidgets.QLineEdit() layout.addWidget(self.ed, 3, 2) self.lineconfig = LineConfig( "line", QtWidgets.QApplication.translate("pychemqt", "Relative roughtness style line")) layout.addWidget(self.lineconfig, 4, 1, 1, 2) self.cruxconfig = LineConfig( "crux", QtWidgets.QApplication.translate("pychemqt", "Crux style line")) layout.addWidget(self.cruxconfig, 5, 1, 1, 2) layout.addItem( QtWidgets.QSpacerItem(10, 0, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 10, 1, 1, 3) if config and config.has_section("Moody"): self.metodos.setCurrentIndex(config.getint("Moody", 'method')) self.fanning.setChecked(config.getboolean("Moody", 'fanning')) self.ed.setText(config.get("Moody", "ed")) self.lineconfig.setConfig(config, "Moody") self.cruxconfig.setConfig(config, "Moody")
def __init__(self, config=None, parent=None): super(Widget, self).__init__(parent) layout = QtWidgets.QGridLayout(self) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Method:")), 1, 1) self.metodos = QtWidgets.QComboBox() for f in f_list: line = f.__doc__.split("\n")[1] year = line.split(" ")[-1] name = line.split(" ")[-3] doc = name + " " + year self.metodos.addItem(doc) layout.addWidget(self.metodos, 1, 2) self.fanning = QtWidgets.QCheckBox(QtWidgets.QApplication.translate( "pychemqt", "Calculate fanning friction factor")) layout.addWidget(self.fanning, 2, 1, 1, 2) layout.addWidget(QtWidgets.QLabel("ε/d:"), 3, 1) self.ed = QtWidgets.QLineEdit() layout.addWidget(self.ed, 3, 2) self.lineconfig = LineConfig( "line", QtWidgets.QApplication.translate( "pychemqt", "Relative roughtness style line")) layout.addWidget(self.lineconfig, 4, 1, 1, 2) self.cruxconfig = LineConfig( "crux", QtWidgets.QApplication.translate( "pychemqt", "Crux style line")) layout.addWidget(self.cruxconfig, 5, 1, 1, 2) layout.addItem(QtWidgets.QSpacerItem( 10, 0, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 10, 1, 1, 3) if config and config.has_section("Moody"): self.metodos.setCurrentIndex(config.getint("Moody", 'method')) self.fanning.setChecked(config.getboolean("Moody", 'fanning')) self.ed.setText(config.get("Moody", "ed")) self.lineconfig.setConfig(config, "Moody") self.cruxconfig.setConfig(config, "Moody")
def __init__(self, config, parent=None): """constructor, config optional parameter to input project config""" super(Widget, self).__init__(parent) lyt = QtWidgets.QGridLayout(self) lyt.setContentsMargins(0, 0, 0, 0) scroll = QtWidgets.QScrollArea() scroll.setFrameStyle(QtWidgets.QFrame.NoFrame) lyt.addWidget(scroll) dlg = QtWidgets.QWidget() layout = QtWidgets.QGridLayout(dlg) groupType = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("pychemqt", "Chart type")) groupLayout = QtWidgets.QVBoxLayout(groupType) self.checkASHRAE = QtWidgets.QRadioButton( QtWidgets.QApplication.translate("pychemqt", "ASHRAE Chart, W vs Tdb")) groupLayout.addWidget(self.checkASHRAE) self.checkMollier = QtWidgets.QRadioButton( QtWidgets.QApplication.translate("pychemqt", "Mollier Chart ix")) groupLayout.addWidget(self.checkMollier) layout.addWidget(groupType, 0, 1, 1, 2) self.virial = QtWidgets.QCheckBox( QtWidgets.QApplication.translate("pychemqt", "Use virial equation of state")) layout.addWidget(self.virial, 1, 1, 1, 2) self.coolProp = QtWidgets.QCheckBox( QtWidgets.QApplication.translate( "pychemqt", "Use external library coolProp (faster)")) self.coolProp.setEnabled(False) layout.addWidget(self.coolProp, 2, 2) self.refprop = QtWidgets.QCheckBox( QtWidgets.QApplication.translate( "pychemqt", "Use external library refprop (fastest)")) self.refprop.setEnabled(False) layout.addWidget(self.refprop, 3, 2) layout.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 4, 1) self.satlineconfig = LineConfig( "saturation", QtWidgets.QApplication.translate("pychemqt", "Saturation Line Style")) layout.addWidget(self.satlineconfig, 5, 1, 1, 2) self.cruxlineconfig = LineConfig( "crux", QtWidgets.QApplication.translate("pychemqt", "Crux Line Style")) layout.addWidget(self.cruxlineconfig, 6, 1, 1, 2) group = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("pychemqt", "Isolines")) layout.addWidget(group, 7, 1, 1, 2) layoutgroup = QtWidgets.QGridLayout(group) self.comboIsolineas = QtWidgets.QComboBox() layoutgroup.addWidget(self.comboIsolineas, 1, 1) self.Isolineas = QtWidgets.QStackedWidget() self.comboIsolineas.currentIndexChanged.connect( self.Isolineas.setCurrentIndex) layoutgroup.addWidget(self.Isolineas, 2, 1) for name, unit, text in self.lineas: self.comboIsolineas.addItem(text) self.Isolineas.addWidget(Isolinea(unit, name, config, "Psychr")) layout.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 10, 2) scroll.setWidget(dlg) if os.environ["CoolProp"]: self.virial.toggled.connect(self.coolProp.setEnabled) if os.environ["refprop"]: self.virial.toggled.connect(self.refprop.setEnabled) if config.has_section("Psychr"): if config.getboolean("Psychr", 'chart'): self.checkASHRAE.setChecked(True) else: self.checkMollier.setChecked(True) self.virial.setChecked(config.getboolean("Psychr", 'virial')) self.coolProp.setChecked(config.getboolean("Psychr", 'coolprop')) self.refprop.setChecked(config.getboolean("Psychr", 'refprop')) self.satlineconfig.setConfig(config, "Psychr") self.cruxlineconfig.setConfig(config, "Psychr")
class Widget(QtWidgets.QWidget): """Phychrometric chart configuration""" lineas = [("IsoTdb", unidades.Temperature, QtWidgets.QApplication.translate("pychemqt", "Iso dry bulb temperature")), ("IsoW", float, QtWidgets.QApplication.translate("pychemqt", "Iso absolute humidity")), ("IsoHR", unidades.SpecificHeat, QtWidgets.QApplication.translate("pychemqt", "Iso relative humidity")), ("IsoTwb", unidades.Temperature, QtWidgets.QApplication.translate("pychemqt", "Iso wet bulb temperature")), ("Isochor", unidades.SpecificVolume, QtWidgets.QApplication.translate("pychemqt", "Isochor"))] def __init__(self, config, parent=None): """constructor, config optional parameter to input project config""" super(Widget, self).__init__(parent) lyt = QtWidgets.QGridLayout(self) lyt.setContentsMargins(0, 0, 0, 0) scroll = QtWidgets.QScrollArea() scroll.setFrameStyle(QtWidgets.QFrame.NoFrame) lyt.addWidget(scroll) dlg = QtWidgets.QWidget() layout = QtWidgets.QGridLayout(dlg) groupType = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("pychemqt", "Chart type")) groupLayout = QtWidgets.QVBoxLayout(groupType) self.checkASHRAE = QtWidgets.QRadioButton( QtWidgets.QApplication.translate("pychemqt", "ASHRAE Chart, W vs Tdb")) groupLayout.addWidget(self.checkASHRAE) self.checkMollier = QtWidgets.QRadioButton( QtWidgets.QApplication.translate("pychemqt", "Mollier Chart ix")) groupLayout.addWidget(self.checkMollier) layout.addWidget(groupType, 0, 1, 1, 2) self.virial = QtWidgets.QCheckBox( QtWidgets.QApplication.translate("pychemqt", "Use virial equation of state")) layout.addWidget(self.virial, 1, 1, 1, 2) self.coolProp = QtWidgets.QCheckBox( QtWidgets.QApplication.translate( "pychemqt", "Use external library coolProp (faster)")) self.coolProp.setEnabled(False) layout.addWidget(self.coolProp, 2, 2) self.refprop = QtWidgets.QCheckBox( QtWidgets.QApplication.translate( "pychemqt", "Use external library refprop (fastest)")) self.refprop.setEnabled(False) layout.addWidget(self.refprop, 3, 2) layout.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 4, 1) self.satlineconfig = LineConfig( "saturation", QtWidgets.QApplication.translate("pychemqt", "Saturation Line Style")) layout.addWidget(self.satlineconfig, 5, 1, 1, 2) self.cruxlineconfig = LineConfig( "crux", QtWidgets.QApplication.translate("pychemqt", "Crux Line Style")) layout.addWidget(self.cruxlineconfig, 6, 1, 1, 2) group = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("pychemqt", "Isolines")) layout.addWidget(group, 7, 1, 1, 2) layoutgroup = QtWidgets.QGridLayout(group) self.comboIsolineas = QtWidgets.QComboBox() layoutgroup.addWidget(self.comboIsolineas, 1, 1) self.Isolineas = QtWidgets.QStackedWidget() self.comboIsolineas.currentIndexChanged.connect( self.Isolineas.setCurrentIndex) layoutgroup.addWidget(self.Isolineas, 2, 1) for name, unit, text in self.lineas: self.comboIsolineas.addItem(text) self.Isolineas.addWidget(Isolinea(unit, name, config, "Psychr")) layout.addItem( QtWidgets.QSpacerItem(10, 10, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 10, 2) scroll.setWidget(dlg) if os.environ["CoolProp"]: self.virial.toggled.connect(self.coolProp.setEnabled) if os.environ["refprop"]: self.virial.toggled.connect(self.refprop.setEnabled) if config.has_section("Psychr"): if config.getboolean("Psychr", 'chart'): self.checkASHRAE.setChecked(True) else: self.checkMollier.setChecked(True) self.virial.setChecked(config.getboolean("Psychr", 'virial')) self.coolProp.setChecked(config.getboolean("Psychr", 'coolprop')) self.refprop.setChecked(config.getboolean("Psychr", 'refprop')) self.satlineconfig.setConfig(config, "Psychr") self.cruxlineconfig.setConfig(config, "Psychr") def value(self, config): """Return value for main dialog""" if not config.has_section("Psychr"): config.add_section("Psychr") config.set("Psychr", "chart", str(self.checkASHRAE.isChecked())) config.set("Psychr", "virial", str(self.virial.isChecked())) config.set("Psychr", "coolprop", str(self.coolProp.isChecked())) config.set("Psychr", "refprop", str(self.refprop.isChecked())) config = self.satlineconfig.value(config, "Psychr") config = self.cruxlineconfig.value(config, "Psychr") for indice in range(self.Isolineas.count()): config = self.Isolineas.widget(indice).value(config) return config
def __init__(self, unit, ConfSection, config, section="MEOS", parent=None): """Constructor unit: subclass of unidad to define the isoline type ConfSection: title of isoline config: config of pychemqt project """ super(Isolinea, self).__init__(parent) self.ConfSection = ConfSection self.magnitud = unit.__name__ self.unidad = unit self.section = section layout = QtWidgets.QGridLayout(self) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Start")), 1, 1) self.inicio = Entrada_con_unidades(unit) layout.addWidget(self.inicio, 1, 2, 1, 3) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Fin")), 2, 1) self.fin = Entrada_con_unidades(unit) layout.addWidget(self.fin, 2, 2, 1, 3) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Intervalo")), 3, 1) if unit.__name__ == "Temperature": self.intervalo = Entrada_con_unidades(unidades.DeltaT) elif unit.__name__ == "Pressure": self.intervalo = Entrada_con_unidades(unidades.DeltaP) else: self.intervalo = Entrada_con_unidades(unit) layout.addWidget(self.intervalo, 3, 2, 1, 3) self.Personalizar = QtWidgets.QCheckBox( QtWidgets.QApplication.translate("pychemqt", "Customize")) layout.addWidget(self.Personalizar, 4, 1, 1, 4) self.Lista = QtWidgets.QLineEdit() layout.addWidget(self.Lista, 5, 1, 1, 4) self.Personalizar.toggled.connect(self.inicio.setDisabled) self.Personalizar.toggled.connect(self.fin.setDisabled) self.Personalizar.toggled.connect(self.intervalo.setDisabled) self.Personalizar.toggled.connect(self.Lista.setEnabled) layout.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 6, 1, 1, 4) if unit.__name__ != "float" and section != "Psychr": self.Critica = QtWidgets.QCheckBox( QtWidgets.QApplication.translate( "pychemqt", "Include critic point line")) layout.addWidget(self.Critica, 7, 1, 1, 4) layout.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 8, 1, 1, 4) self.lineconfig = LineConfig( ConfSection, QtWidgets.QApplication.translate("pychemqt", "Line Style")) layout.addWidget(self.lineconfig, 9, 1, 1, 4) layout.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 10, 1) self.label = QtWidgets.QCheckBox( QtWidgets.QApplication.translate("pychemqt", "Label")) layout.addWidget(self.label, 11, 1) self.variable = QtWidgets.QCheckBox( QtWidgets.QApplication.translate("pychemqt", "Variable in Label")) layout.addWidget(self.variable, 12, 1, 1, 4) self.unit = QtWidgets.QCheckBox( QtWidgets.QApplication.translate("pychemqt", "Units in Label")) layout.addWidget(self.unit, 13, 1, 1, 4) layout.addWidget(QtWidgets.QLabel( QtWidgets.QApplication.translate("pychemqt", "Position")), 14, 1) self.label5 = Entrada_con_unidades(int, value=0, width=25, frame=False, readOnly=True) self.label5.setFixedWidth(30) layout.addWidget(self.label5, 14, 2) self.Posicion = QtWidgets.QSlider(QtCore.Qt.Horizontal) self.Posicion.valueChanged.connect(self.label5.setValue) layout.addWidget(self.Posicion, 14, 3, 1, 2) layout.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 15, 4) if config.has_section(section): self.inicio.setValue(config.getfloat(section, ConfSection+'Start')) self.fin.setValue(config.getfloat(section, ConfSection+'End')) self.intervalo.setValue( config.getfloat(section, ConfSection+'Step')) self.Personalizar.setChecked( config.getboolean(section, ConfSection+'Custom')) if config.get(section, ConfSection+'List') != "": T = [] for i in config.get(section, ConfSection+'List').split(','): if unit.__name__ == "float": T.append(representacion(float(i))) else: T.append(representacion(unit(float(i)).config())) self.Lista.setText(",".join(T)) if unit.__name__ != "float" and section != "Psychr": self.Critica.setChecked( config.getboolean(section, ConfSection+'Critic')) self.inicio.setDisabled(self.Personalizar.isChecked()) self.fin.setDisabled(self.Personalizar.isChecked()) self.intervalo.setDisabled(self.Personalizar.isChecked()) self.Lista.setEnabled(self.Personalizar.isChecked()) self.label.setChecked( config.getboolean(section, ConfSection+'Label')) self.variable.setChecked( config.getboolean(section, ConfSection+'Variable')) self.unit.setChecked( config.getboolean(section, ConfSection+'Units')) self.Posicion.setValue( config.getint(section, ConfSection+'Position')) self.lineconfig.setConfig(config, section)
def __init__(self, config, parent=None): """constructor, config optional parameter to input project config""" super(Widget, self).__init__(parent) lyt = QtWidgets.QGridLayout(self) lyt.setContentsMargins(0, 0, 0, 0) scroll = QtWidgets.QScrollArea() scroll.setFrameStyle(QtWidgets.QFrame.NoFrame) lyt.addWidget(scroll) dlg = QtWidgets.QWidget() layout = QtWidgets.QGridLayout(dlg) self.coolProp = QtWidgets.QCheckBox(QtWidgets.QApplication.translate( "pychemqt", "Use external library coolProp (faster)")) self.coolProp.setEnabled(False) layout.addWidget(self.coolProp, 3, 1, 1, 2) self.refprop = QtWidgets.QCheckBox(QtWidgets.QApplication.translate( "pychemqt", "Use external library refprop (fastest)")) self.refprop.setEnabled(False) layout.addWidget(self.refprop, 4, 1, 1, 2) layout.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 4, 1) self.lineconfig = LineConfig( "saturation", QtWidgets.QApplication.translate( "pychemqt", "Saturation Line Style")) layout.addWidget(self.lineconfig, 5, 1, 1, 2) group = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("pychemqt", "Isolines")) layout.addWidget(group, 6, 1, 1, 2) layoutgroup = QtWidgets.QGridLayout(group) self.comboIsolineas = QtWidgets.QComboBox() layoutgroup.addWidget(self.comboIsolineas, 1, 1) self.Isolineas = QtWidgets.QStackedWidget() self.comboIsolineas.currentIndexChanged.connect( self.Isolineas.setCurrentIndex) layoutgroup.addWidget(self.Isolineas, 2, 1) for nombre, unidad, text in self.lineas: self.comboIsolineas.addItem(text) self.Isolineas.addWidget(Isolinea(unidad, nombre, config)) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Plot Definition")), 7, 1) quality = [QtWidgets.QApplication.translate("pychemqt", "Very Low"), QtWidgets.QApplication.translate("pychemqt", "Low"), QtWidgets.QApplication.translate("pychemqt", "Medium"), QtWidgets.QApplication.translate("pychemqt", "High"), QtWidgets.QApplication.translate("pychemqt", "Ultra High")] self.definition = QtWidgets.QComboBox() for q in quality: self.definition.addItem(q) layout.addWidget(self.definition, 7, 2) self.grid = QtWidgets.QCheckBox( QtWidgets.QApplication.translate("pychemqt", "Draw grid")) layout.addWidget(self.grid, 9, 1, 1, 2) layout.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 10, 2) scroll.setWidget(dlg) if os.environ["CoolProp"]: self.coolProp.setEnabled(True) if os.environ["refprop"]: self.refprop.setEnabled(True) if config.has_section("MEOS"): self.coolProp.setChecked(config.getboolean("MEOS", 'coolprop')) self.refprop.setChecked(config.getboolean("MEOS", 'refprop')) self.grid.setChecked(config.getboolean("MEOS", 'grid')) self.definition.setCurrentIndex( config.getint("MEOS", 'definition')) self.lineconfig.setConfig(config)
class Widget(QtWidgets.QDialog): """Config mEoS parameter dialog""" lineas = [ ("Isotherm", unidades.Temperature, QtWidgets.QApplication.translate("pychemqt", "Isotherm")), ("Isobar", unidades.Pressure, QtWidgets.QApplication.translate("pychemqt", "Isobar")), ("Isoenthalpic", unidades.Enthalpy, QtWidgets.QApplication.translate("pychemqt", "Isoenthalpic")), ("Isoentropic", unidades.SpecificHeat, QtWidgets.QApplication.translate("pychemqt", "Isoentropic")), ("Isochor", unidades.SpecificVolume, QtWidgets.QApplication.translate("pychemqt", "Isochor")), ("Isoquality", float, QtWidgets.QApplication.translate("pychemqt", "Isoquality"))] def __init__(self, config, parent=None): """constructor, config optional parameter to input project config""" super(Widget, self).__init__(parent) lyt = QtWidgets.QGridLayout(self) lyt.setContentsMargins(0, 0, 0, 0) scroll = QtWidgets.QScrollArea() scroll.setFrameStyle(QtWidgets.QFrame.NoFrame) lyt.addWidget(scroll) dlg = QtWidgets.QWidget() layout = QtWidgets.QGridLayout(dlg) self.coolProp = QtWidgets.QCheckBox(QtWidgets.QApplication.translate( "pychemqt", "Use external library coolProp (faster)")) self.coolProp.setEnabled(False) layout.addWidget(self.coolProp, 3, 1, 1, 2) self.refprop = QtWidgets.QCheckBox(QtWidgets.QApplication.translate( "pychemqt", "Use external library refprop (fastest)")) self.refprop.setEnabled(False) layout.addWidget(self.refprop, 4, 1, 1, 2) layout.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 4, 1) self.lineconfig = LineConfig( "saturation", QtWidgets.QApplication.translate( "pychemqt", "Saturation Line Style")) layout.addWidget(self.lineconfig, 5, 1, 1, 2) group = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("pychemqt", "Isolines")) layout.addWidget(group, 6, 1, 1, 2) layoutgroup = QtWidgets.QGridLayout(group) self.comboIsolineas = QtWidgets.QComboBox() layoutgroup.addWidget(self.comboIsolineas, 1, 1) self.Isolineas = QtWidgets.QStackedWidget() self.comboIsolineas.currentIndexChanged.connect( self.Isolineas.setCurrentIndex) layoutgroup.addWidget(self.Isolineas, 2, 1) for nombre, unidad, text in self.lineas: self.comboIsolineas.addItem(text) self.Isolineas.addWidget(Isolinea(unidad, nombre, config)) layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate( "pychemqt", "Plot Definition")), 7, 1) quality = [QtWidgets.QApplication.translate("pychemqt", "Very Low"), QtWidgets.QApplication.translate("pychemqt", "Low"), QtWidgets.QApplication.translate("pychemqt", "Medium"), QtWidgets.QApplication.translate("pychemqt", "High"), QtWidgets.QApplication.translate("pychemqt", "Ultra High")] self.definition = QtWidgets.QComboBox() for q in quality: self.definition.addItem(q) layout.addWidget(self.definition, 7, 2) self.grid = QtWidgets.QCheckBox( QtWidgets.QApplication.translate("pychemqt", "Draw grid")) layout.addWidget(self.grid, 9, 1, 1, 2) layout.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 10, 2) scroll.setWidget(dlg) if os.environ["CoolProp"]: self.coolProp.setEnabled(True) if os.environ["refprop"]: self.refprop.setEnabled(True) if config.has_section("MEOS"): self.coolProp.setChecked(config.getboolean("MEOS", 'coolprop')) self.refprop.setChecked(config.getboolean("MEOS", 'refprop')) self.grid.setChecked(config.getboolean("MEOS", 'grid')) self.definition.setCurrentIndex( config.getint("MEOS", 'definition')) self.lineconfig.setConfig(config) def value(self, config): """Return value for main dialog""" if not config.has_section("MEOS"): config.add_section("MEOS") config.set("MEOS", "coolprop", str(self.coolProp.isChecked())) config.set("MEOS", "refprop", str(self.refprop.isChecked())) config = self.lineconfig.value(config) config.set("MEOS", "grid", str(self.grid.isChecked())) config.set("MEOS", "definition", str(self.definition.currentIndex())) for indice in range(self.Isolineas.count()): config = self.Isolineas.widget(indice).value(config) return config
def __init__(self, config, parent=None): """constructor, config optional parameter to input project config""" super(Widget, self).__init__(parent) lyt = QtWidgets.QGridLayout(self) lyt.setContentsMargins(0, 0, 0, 0) scroll = QtWidgets.QScrollArea() scroll.setFrameStyle(QtWidgets.QFrame.NoFrame) lyt.addWidget(scroll) dlg = QtWidgets.QWidget() layout = QtWidgets.QGridLayout(dlg) groupType = QtWidgets.QGroupBox(QtWidgets.QApplication.translate( "pychemqt", "Chart type")) groupLayout = QtWidgets.QVBoxLayout(groupType) self.checkASHRAE = QtWidgets.QRadioButton( QtWidgets.QApplication.translate( "pychemqt", "ASHRAE Chart, W vs Tdb")) groupLayout.addWidget(self.checkASHRAE) self.checkMollier = QtWidgets.QRadioButton( QtWidgets.QApplication.translate("pychemqt", "Mollier Chart ix")) groupLayout.addWidget(self.checkMollier) layout.addWidget(groupType, 0, 1, 1, 2) self.virial = QtWidgets.QCheckBox(QtWidgets.QApplication.translate( "pychemqt", "Use virial equation of state")) layout.addWidget(self.virial, 1, 1, 1, 2) self.coolProp = QtWidgets.QCheckBox(QtWidgets.QApplication.translate( "pychemqt", "Use external library coolProp (faster)")) self.coolProp.setEnabled(False) layout.addWidget(self.coolProp, 2, 2) self.refprop = QtWidgets.QCheckBox(QtWidgets.QApplication.translate( "pychemqt", "Use external library refprop (fastest)")) self.refprop.setEnabled(False) layout.addWidget(self.refprop, 3, 2) layout.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 4, 1) self.satlineconfig = LineConfig( "saturation", QtWidgets.QApplication.translate( "pychemqt", "Saturation Line Style")) layout.addWidget(self.satlineconfig, 5, 1, 1, 2) self.cruxlineconfig = LineConfig( "crux", QtWidgets.QApplication.translate( "pychemqt", "Crux Line Style")) layout.addWidget(self.cruxlineconfig, 6, 1, 1, 2) group = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("pychemqt", "Isolines")) layout.addWidget(group, 7, 1, 1, 2) layoutgroup = QtWidgets.QGridLayout(group) self.comboIsolineas = QtWidgets.QComboBox() layoutgroup.addWidget(self.comboIsolineas, 1, 1) self.Isolineas = QtWidgets.QStackedWidget() self.comboIsolineas.currentIndexChanged.connect( self.Isolineas.setCurrentIndex) layoutgroup.addWidget(self.Isolineas, 2, 1) for name, unit, text in self.lineas: self.comboIsolineas.addItem(text) self.Isolineas.addWidget(Isolinea(unit, name, config, "Psychr")) layout.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 10, 2) scroll.setWidget(dlg) if os.environ["CoolProp"]: self.virial.toggled.connect(self.coolProp.setEnabled) if os.environ["refprop"]: self.virial.toggled.connect(self.refprop.setEnabled) if config.has_section("Psychr"): if config.getboolean("Psychr", 'chart'): self.checkASHRAE.setChecked(True) else: self.checkMollier.setChecked(True) self.virial.setChecked(config.getboolean("Psychr", 'virial')) self.coolProp.setChecked(config.getboolean("Psychr", 'coolprop')) self.refprop.setChecked(config.getboolean("Psychr", 'refprop')) self.satlineconfig.setConfig(config, "Psychr") self.cruxlineconfig.setConfig(config, "Psychr")
class Widget(QtWidgets.QWidget): """Phychrometric chart configuration""" lineas = [ ("IsoTdb", unidades.Temperature, QtWidgets.QApplication.translate( "pychemqt", "Iso dry bulb temperature")), ("IsoW", float, QtWidgets.QApplication.translate( "pychemqt", "Iso absolute humidity")), ("IsoHR", unidades.SpecificHeat, QtWidgets.QApplication.translate( "pychemqt", "Iso relative humidity")), ("IsoTwb", unidades.Temperature, QtWidgets.QApplication.translate( "pychemqt", "Iso wet bulb temperature")), ("Isochor", unidades.SpecificVolume, QtWidgets.QApplication.translate("pychemqt", "Isochor"))] def __init__(self, config, parent=None): """constructor, config optional parameter to input project config""" super(Widget, self).__init__(parent) lyt = QtWidgets.QGridLayout(self) lyt.setContentsMargins(0, 0, 0, 0) scroll = QtWidgets.QScrollArea() scroll.setFrameStyle(QtWidgets.QFrame.NoFrame) lyt.addWidget(scroll) dlg = QtWidgets.QWidget() layout = QtWidgets.QGridLayout(dlg) groupType = QtWidgets.QGroupBox(QtWidgets.QApplication.translate( "pychemqt", "Chart type")) groupLayout = QtWidgets.QVBoxLayout(groupType) self.checkASHRAE = QtWidgets.QRadioButton( QtWidgets.QApplication.translate( "pychemqt", "ASHRAE Chart, W vs Tdb")) groupLayout.addWidget(self.checkASHRAE) self.checkMollier = QtWidgets.QRadioButton( QtWidgets.QApplication.translate("pychemqt", "Mollier Chart ix")) groupLayout.addWidget(self.checkMollier) layout.addWidget(groupType, 0, 1, 1, 2) self.virial = QtWidgets.QCheckBox(QtWidgets.QApplication.translate( "pychemqt", "Use virial equation of state")) layout.addWidget(self.virial, 1, 1, 1, 2) self.coolProp = QtWidgets.QCheckBox(QtWidgets.QApplication.translate( "pychemqt", "Use external library coolProp (faster)")) self.coolProp.setEnabled(False) layout.addWidget(self.coolProp, 2, 2) self.refprop = QtWidgets.QCheckBox(QtWidgets.QApplication.translate( "pychemqt", "Use external library refprop (fastest)")) self.refprop.setEnabled(False) layout.addWidget(self.refprop, 3, 2) layout.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed), 4, 1) self.satlineconfig = LineConfig( "saturation", QtWidgets.QApplication.translate( "pychemqt", "Saturation Line Style")) layout.addWidget(self.satlineconfig, 5, 1, 1, 2) self.cruxlineconfig = LineConfig( "crux", QtWidgets.QApplication.translate( "pychemqt", "Crux Line Style")) layout.addWidget(self.cruxlineconfig, 6, 1, 1, 2) group = QtWidgets.QGroupBox( QtWidgets.QApplication.translate("pychemqt", "Isolines")) layout.addWidget(group, 7, 1, 1, 2) layoutgroup = QtWidgets.QGridLayout(group) self.comboIsolineas = QtWidgets.QComboBox() layoutgroup.addWidget(self.comboIsolineas, 1, 1) self.Isolineas = QtWidgets.QStackedWidget() self.comboIsolineas.currentIndexChanged.connect( self.Isolineas.setCurrentIndex) layoutgroup.addWidget(self.Isolineas, 2, 1) for name, unit, text in self.lineas: self.comboIsolineas.addItem(text) self.Isolineas.addWidget(Isolinea(unit, name, config, "Psychr")) layout.addItem(QtWidgets.QSpacerItem( 10, 10, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding), 10, 2) scroll.setWidget(dlg) if os.environ["CoolProp"]: self.virial.toggled.connect(self.coolProp.setEnabled) if os.environ["refprop"]: self.virial.toggled.connect(self.refprop.setEnabled) if config.has_section("Psychr"): if config.getboolean("Psychr", 'chart'): self.checkASHRAE.setChecked(True) else: self.checkMollier.setChecked(True) self.virial.setChecked(config.getboolean("Psychr", 'virial')) self.coolProp.setChecked(config.getboolean("Psychr", 'coolprop')) self.refprop.setChecked(config.getboolean("Psychr", 'refprop')) self.satlineconfig.setConfig(config, "Psychr") self.cruxlineconfig.setConfig(config, "Psychr") def value(self, config): """Return value for main dialog""" if not config.has_section("Psychr"): config.add_section("Psychr") config.set("Psychr", "chart", str(self.checkASHRAE.isChecked())) config.set("Psychr", "virial", str(self.virial.isChecked())) config.set("Psychr", "coolprop", str(self.coolProp.isChecked())) config.set("Psychr", "refprop", str(self.refprop.isChecked())) config = self.satlineconfig.value(config, "Psychr") config = self.cruxlineconfig.value(config, "Psychr") for indice in range(self.Isolineas.count()): config = self.Isolineas.widget(indice).value(config) return config