当前位置: 首页>>代码示例>>Python>>正文


Python Tabla.setMatrix方法代码示例

本文整理汇总了Python中UI.widgets.Tabla.setMatrix方法的典型用法代码示例。如果您正苦于以下问题:Python Tabla.setMatrix方法的具体用法?Python Tabla.setMatrix怎么用?Python Tabla.setMatrix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UI.widgets.Tabla的用法示例。


在下文中一共展示了Tabla.setMatrix方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Binary_distillation

# 需要导入模块: from UI.widgets import Tabla [as 别名]
# 或者: from UI.widgets.Tabla import setMatrix [as 别名]
class Binary_distillation(QtGui.QDialog):
    title=QtGui.QApplication.translate("pychemqt", "x-y Distillation")
    def __init__(self, indices=None, nombres=None, x=None, y=None, parent=None):
        super(Binary_distillation, self).__init__(parent)
        self.setWindowTitle(self.title)
        layout=QtGui.QGridLayout(self)
        layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate("equipment", "Component 1:")),1,1)
        self.Comp1=QtGui.QComboBox()
        layout.addWidget(self.Comp1,1,2)
        layout.addWidget(QtGui.QLabel(QtGui.QApplication.translate("equipment", "Component 2:")),1,4)
        self.Comp2=QtGui.QComboBox()
        layout.addWidget(self.Comp2,1,5)
        
        self.indices=indices
        self.nombres=nombres
        for i, nombre in enumerate(nombres):
            self.Comp1.addItem("%i - %s" %(i+1, nombre))
            self.Comp2.addItem("%i - %s" %(i+1, nombre))
        self.Comp2.setCurrentIndex(1)
        tab=QtGui.QTabWidget()
        layout.addWidget(tab,2,1,1,5)
        self.plot=mpl()
        tab.addTab(self.plot, QtGui.QApplication.translate("equipment", "Plot"))
        self.tabla=Tabla(2, horizontalHeader=["x", "y"], stretch=False, readOnly=True)
        tab.addTab(self.tabla, QtGui.QApplication.translate("equipment", "Table"))
        
        self.Comp1.currentIndexChanged.connect(self.calculo)
        self.Comp2.currentIndexChanged.connect(self.calculo)
        
        if x and y:
            self.rellenar(x, y)
        else:
            self.calculo()
        
    def rellenar(self, x, y):
        self.x=x
        self.y=y
        self.plot.axes2D.clear()
        self.plot.data([0, 1], [0, 1], x, y, 'ro')

        self.tabla.setMatrix(transpose([x, y]))

    def calculo(self):
        ind1=self.Comp1.currentIndex()
        ind2=self.Comp2.currentIndex()
        if ind1!=ind2:
            zi=arange(0.025, 1., 0.025)
            id1=self.indices[ind1]
            id2=self.indices[ind2]
            x=[0]
            y=[0]
            for z in zi:
                try:
                    fraccion=[0.]*len(self.indices)
                    fraccion[ind1]=z
                    fraccion[ind2]=1-z
                    mez=Mezcla(tipo=3, fraccionMolar=fraccion, caudalMasico=1.)
                    tb=mez.componente[0].Tb
                    corr=Corriente(T=tb, P=101325., mezcla=mez)
                    T=corr.eos._Dew_T()
                    corr=Corriente(T=T, P=101325., mezcla=mez)
                    while corr.Liquido.fraccion[0]==corr.Gas.fraccion[0] and corr.T<corr.mezcla.componente[1].Tb:
                        corr=Corriente(T=corr.T-0.1, P=101325., mezcla=mez)
                    x.append(corr.Liquido.fraccion[0])
                    y.append(corr.Gas.fraccion[0])
                except:
                    pass
            x.append(1)
            y.append(1)
            self.rellenar(x, y)

    def writeToStream(self, stream):
        stream.writeInt32(self.widget().Comp1.currentIndex())
        stream.writeInt32(self.widget().Comp2.currentIndex())
        stream.writeInt32(len(self.widget().x))
        for i in self.widget().x:
            stream.writeFloat(i)
        for i in self.widget().y:
            stream.writeFloat(i)
    
    @classmethod
    def readToStream(cls, stream):
        id1=stream.readInt32()
        id2=stream.readInt32()
        len=stream.readInt32()
        x=[]
        for i in range(len):
            x.append(stream.readFloat())
        y=[]
        for i in range(len):
            y.append(stream.readFloat())
        self.plot(0, x, y)
开发者ID:edusegzy,项目名称:pychemqt,代码行数:94,代码来源:plots.py


注:本文中的UI.widgets.Tabla.setMatrix方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。