Example #1
0
 def actualizePeakModelComparative():
     model = QStandardItemModel()
     #root=MSDialogController.getColouredRootItem(sample)
     sampleList = QApplication.instance().model
     groups = sampleList.peaksGrouping()
     model.setVerticalHeaderLabels(["/".join(map(str, round([mass, rt], 4).tolist())) for mass, rt in sorted(groups.keys(), key=lambda x:x[0])])
     model.setHorizontalHeaderLabels([spl.shortName() for spl in sampleList.isamples()])
     for i, key in enumerate(sorted(groups.keys(), key=lambda x:x[0])):
         zeros = [0.] * len(sampleList)
         for peak in groups[key]:
             try:
                 idx = [spl.shortName() for spl in sampleList].index(peak.sample.shortName())
             except ValueError:
                 print "Error in %s"%MSDialogController.actualizePeakModelComparative.__name__
             zeros[idx] = peak
         for j in xrange(len(zeros)):
             item = QStandardItem()
             if not zeros[j]:
                 item.setBackground(QBrush(Qt.red))
                 item.setText("Not found")
             else:
                 MSDialogController.setRightIcon(zeros[j], item)#set the colour actually
                 item.setText(str(round(zeros[j].area, 2)))
             model.setItem(i, j, item)
     return model
Example #2
0
 def actualizePeakModelComparative():
     model = QStandardItemModel()
     #root=MSDialogController.getColouredRootItem(sample)
     sampleList = QApplication.instance().model
     groups = sampleList.peaksGrouping()
     model.setVerticalHeaderLabels([
         "/".join(map(str,
                      round([mass, rt], 4).tolist()))
         for mass, rt in sorted(groups.keys(), key=lambda x: x[0])
     ])
     model.setHorizontalHeaderLabels(
         [spl.shortName() for spl in sampleList.isamples()])
     for i, key in enumerate(sorted(groups.keys(), key=lambda x: x[0])):
         zeros = [0.] * len(sampleList)
         for peak in groups[key]:
             try:
                 idx = [spl.shortName() for spl in sampleList
                        ].index(peak.sample.shortName())
             except ValueError:
                 print "Error in %s" % MSDialogController.actualizePeakModelComparative.__name__
             zeros[idx] = peak
         for j in xrange(len(zeros)):
             item = QStandardItem()
             if not zeros[j]:
                 item.setBackground(QBrush(Qt.red))
                 item.setText("Not found")
             else:
                 MSDialogController.setRightIcon(
                     zeros[j], item)  #set the colour actually
                 item.setText(str(round(zeros[j].area, 2)))
             model.setItem(i, j, item)
     return model
Example #3
0
 def get_coloured_root_item(filepath, color, colorr):
     root = QStandardItem(filepath)
     gradient = QLinearGradient(-100, -100, 100, 100)
     gradient.setColorAt(0.7, colorr)
     gradient.setColorAt(1, color)
     root.setBackground(QBrush(gradient))
     root.setEditable(False)
     root.setCheckState(Qt.Checked)
     root.setCheckable(True)
     return root
Example #4
0
 def getColouredRootItem(sample):
     """stable, may be subdivised in sub routines """
     root = QStandardItem(sample.shortName())
     #root.setIcon(QIcon(QPixmap(os.path.normpath('gui/icons/formula.png'))))
     color =QColor.fromRgbF(sample.color[0],sample.color[1], sample.color[2],1.)
     colorr=QColor.fromRgbF(sample.color[0],sample.color[1], sample.color[2],.5)
     gradient=QLinearGradient(-100, -100, 100, 100)
     gradient.setColorAt(0.7, colorr);gradient.setColorAt(1, color)
     root.setBackground(QBrush(gradient))
     root.setEditable(False)
     root.setCheckState(Qt.Checked)
     root.setCheckable(True)
     return root
Example #5
0
    def __init__(self, engine, gui_parent, parent=None):
        """
        Constructor
        
        @param parent reference to the parent widget (QWidget)
        """
        super().__init__(parent)
        self.setupUi(self)

        self.setWindowTitle("Enregistrement d'une formation")

        self.engine = engine
        self.dateEdit.setDate(pendulum.now('Europe/Paris'))
        self.cmr_bdd = Bdd_Cmr(self.engine)

        gen_cmr = self.cmr_bdd.recup_cmr_en_activite()

        self.remplir_tableau_cmr(next(gen_cmr))

        #        self.threadpool = QThreadPool()

        self.gui_parent = gui_parent

        ####Threads
        self.thread_finish = False
        #        self.affectation_lancement_threads()

        init_domaine = Insertion_Domaine(self.engine)
        areas = init_domaine.recuperation_domaine()
        #        print(areas)

        self.model = QStandardItemModel((len(areas) + 1), 1)  # 5 rows, 1 col

        firstItem = QStandardItem("---- Select domaine(s) ----")
        firstItem.setBackground(QBrush(QColor(200, 200, 200)))
        firstItem.setSelectable(False)
        self.model.setItem(0, 0, firstItem)

        for i, area in enumerate(areas):
            item = QStandardItem(area)
            item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
            item.setData(Qt.Unchecked, Qt.CheckStateRole)
            self.model.setItem(i + 1, 0, item)

        self.comboBox_domaine.setModel(self.model)

        self.gui_parent.formation_a_modifier.connect(
            self.reaffectation_formation)
Example #6
0
 def getColouredRootItem(sample):
     """stable, may be subdivised in sub routines """
     root = QStandardItem(sample.shortName())
     #root.setIcon(QIcon(QPixmap(os.path.normpath('gui/icons/formula.png'))))
     color = QColor.fromRgbF(sample.color[0], sample.color[1],
                             sample.color[2], 1.)
     colorr = QColor.fromRgbF(sample.color[0], sample.color[1],
                              sample.color[2], .5)
     gradient = QLinearGradient(-100, -100, 100, 100)
     gradient.setColorAt(0.7, colorr)
     gradient.setColorAt(1, color)
     root.setBackground(QBrush(gradient))
     root.setEditable(False)
     root.setCheckState(Qt.Checked)
     root.setCheckable(True)
     return root
Example #7
0
    def actualizeClusterModel(sample):
        model = QApplication.instance().view.clusterModel
        if model.rowCount():
            model.clear()

        idItems = []
        for peak in sample.imappedPeaks():
            std_item = QStandardItem(str(peak))
            std_item.setEditable(False)
            if peak.isFoundInDatabase:
                std_item.setBackground(QBrush(Qt.green))
                #put the formula with the best score
                o = QStandardItem(peak.formulas.keys()[0])
                o.setBackground(QBrush(Qt.green))
                idItems.append(o)
            else:
                idItems.append(QStandardItem("not found"))
            MSDialogController.setRightIcon(peak, std_item)
            if peak.isoCluster:
                iso_item = QStandardItem("isotopic cluster:")
                iso_item.setEditable(False)
                for iso in peak.isoCluster:
                    item = QStandardItem(str(iso))
                    item.setEditable(False)
                    MSDialogController.setRightIcon(iso, item)
                    iso_item.appendRow(item)
                std_item.appendRow(iso_item)
            if peak.fragCluster:
                frag_item = QStandardItem("fragments/adducts:")
                frag_item.setEditable(False)
                for frag in peak.fragCluster:
                    item = QStandardItem("/".join([
                        str(frag.mass()),
                        str(frag.rt),
                        str(frag.annotation.values())[2:-2]
                    ]))
                    item.setEditable(False)
                    MSDialogController.setRightIcon(frag, item)
                    frag_item.appendRow(item)
                std_item.appendRow(frag_item)
            model.appendRow(std_item)
        model.appendColumn(idItems)
Example #8
0
    def run(self):
        """rempli le combobox domaine et cree la possibilité de checked des items"""

        init_domaine = Insertion_Domaine(self.engine)
        areas = init_domaine.recuperation_domaine()

        self.model = QStandardItemModel((len(areas) + 1), 1)  # 5 rows, 1 col

        firstItem = QStandardItem("---- Select domaine(s) ----")
        firstItem.setBackground(QBrush(QColor(200, 200, 200)))
        firstItem.setSelectable(False)
        self.model.setItem(0, 0, firstItem)

        for i, area in enumerate(areas):
            item = QStandardItem(area)
            item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
            item.setData(Qt.Unchecked, Qt.CheckStateRole)
            self.model.setItem(i + 1, 0, item)

        self.signals.signalmodel_dispo.emit(self.model)
Example #9
0
    def actualizeClusterModel(sample):
        model=QApplication.instance().view.clusterModel
        if model.rowCount():
            model.clear()

        idItems = []
        for peak in sample.imappedPeaks():
            std_item = QStandardItem(str(peak))
            std_item.setEditable(False)
            if peak.isFoundInDatabase:
                std_item.setBackground(QBrush(Qt.green))
                #put the formula with the best score
                o = QStandardItem(peak.formulas.keys()[0])
                o.setBackground(QBrush(Qt.green))
                idItems.append(o)
            else:
                idItems.append(QStandardItem("not found"))
            MSDialogController.setRightIcon(peak, std_item)
            if peak.isoCluster:
                iso_item = QStandardItem("isotopic cluster:")
                iso_item.setEditable(False)
                for iso in peak.isoCluster:
                    item = QStandardItem(str(iso))
                    item.setEditable(False)
                    MSDialogController.setRightIcon(iso, item)
                    iso_item.appendRow(item)
                std_item.appendRow(iso_item)
            if peak.fragCluster:
                frag_item = QStandardItem("fragments/adducts:")
                frag_item.setEditable(False)
                for frag in peak.fragCluster:
                    item =QStandardItem("/".join([str(frag.mass()), str(frag.rt), str(frag.annotation.values())[2:-2]]))
                    item.setEditable(False)
                    MSDialogController.setRightIcon(frag, item)
                    frag_item.appendRow(item)
                std_item.appendRow(frag_item)
            model.appendRow(std_item)
        model.appendColumn(idItems)
Example #10
0
        def addRowToMangaTable(self, manga):
                i = self.mangaTableModel.rowCount()

                mangaItem = QStandardItem(QString(manga["name"]))
                latestChapterItem = QStandardItem(QString(manga["latestChapter"]))
                statusItem = QStandardItem(QString(manga["status"]))

                brush = QBrush(QColor(255, 255, 255)) if i%2==0 else QBrush(QColor(200, 200, 200))

                mangaItem.setBackground(brush)
                latestChapterItem.setBackground(brush)
                statusItem.setBackground(brush)

                self.mangaTableModel.setItem(i, 0, mangaItem)
                self.mangaTableModel.setItem(i, 1, latestChapterItem)
                self.mangaTableModel.setItem(i, 2, statusItem)
Example #11
0
    def genOneTab(self, tabtitle="", tabbtn="", tabnums="", strwhere = "where studentsn like '03%' "):
        # tabtitle.setFixedHeight(40)
        # tabtitle.setFixedWidth(160)
        tabtitle.setFont(QFont('Courier New', 20))
        tabtitle.setStyleSheet("border: 3px solid blue;\
            border-radius: 6px; \
            padding: 1px 18px 1px 20px;\
            min-width: 8em;")
        model = tabtitle.model()
        for row in ["随堂演板", "随堂提问"]:
            item = QStandardItem(str(row))
            item.setForeground(QColor('blue'))
            item.setBackground(QColor(0,200,50, 130))
            font = item.font()
            font.setPointSize(20)
            item.setFont(font)
            model.appendRow(item)
        tabtitle.setCurrentIndex(0)
        titleLayout = QHBoxLayout()
        tabtitle.setMinimumHeight(50);
        titleLayout.addWidget(tabtitle)
        titleLayout.setAlignment(tabtitle, Qt.AlignCenter)
       
        btnlayout = QGridLayout()
        
        cur = conn.cursor()
        strsql = "select studentsn, studentname from student " + strwhere
        cur.execute(strsql)
     
        tmpnum = 0
        for item in cur.fetchall():
            irow = tmpnum // 7
            icol = tmpnum % 7
            tmpnum += 1
            btnlayout.setRowMinimumHeight(irow, 80)
            tmpbtn = QPushButton(item[1])
            tmpbtn.setFont(QFont('宋体', 16))
            tmpbtn.setSizePolicy(QSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding))

            popMenu = QMenu(self)
            entry1 = popMenu.addAction("正确")
            self.connect(entry1,SIGNAL('triggered()'), lambda item=item[0]: self.answerRight(item))
            entry2 = popMenu.addAction("错误")
            self.connect(entry2,SIGNAL('triggered()'), lambda item=item[0]: self.answerWrong(item))
            entry3 = popMenu.addAction("替换")
            self.connect(entry3,SIGNAL('triggered()'), lambda item=item[0]: self.resetStudent(item))
            tmpbtn.setMenu(popMenu)
            tmpbtn.setAutoDefault(False)
            self.btngroup.addButton(tmpbtn, int(item[0]))
            btnlayout.addWidget(tmpbtn, irow, icol)

        tabbtn.setIcon(QIcon("image/start.png"))
        tabbtn.setStyleSheet("border: 5px solid yellow;")
        tabbtn.setFixedHeight(45)
        tabbtn.setFixedWidth(100)
        tabbtn.setFont(QFont('宋体', 20))
        # tabnums.setFixedHeight(40)
        # tabnums.setFixedWidth(60)
        tabnums.setFont(QFont('Courier New', 20))
        tabnums.setStyleSheet("border: 5px solid blue; color:red;font-weight:bold;font-size:26px;\
            border-radius: 6px; \
            padding: 1px 1px 1px 1px;\
            min-width: 2em; ")
        # tabnums.VerticalContentAlignment="Center"
        # tabnums.addItems(["1", "2", "3", "4", "5", "6"])
        model = tabnums.model()
        for row in list(range(1, 7)):
            item = QStandardItem(str(row))
            # item.setStyleSheet("background-color:rgb(0,0,255)")
            item.setForeground(QColor('red'))
            item.setBackground(QColor(0,200,50, 130))
            # font = item.font()
            # font.setPointSize(16)
            # item.setFont(font)
            model.appendRow(item)
        tabnums.setCurrentIndex(2)

        bottomlayout = QHBoxLayout()
        bottomlayout.setSizeConstraint(QLayout.SetFixedSize)
        bottomlayout.addStretch(10)
        bottomlayout.addWidget(tabbtn)
        bottomlayout.setSpacing(5)
        bottomlayout.addWidget(tabnums)
     
        cur.close()
        return(titleLayout, btnlayout, bottomlayout)
Example #12
0
    def __init__(self, Minerals=None, string=None, flag=None):
        super(Regression_PLOT_PyQt, self).__init__()
        if string is not None:
            self.stringK, self.stringG, self.stringRho, self.user_input = string
        else:
            self.stringK = None
            self.stringG = None
            self.stringRho = None
            self.user_input = False
        self.resize(1400, 600)
        self.Minerals = Minerals

        self.dirty = False
        #self.user_input = user_input

        self.Minerals.original_flag()
        self.Minerals.read_data()
        self.table = QTableView()
        self.model = QStandardItemModel(25, 7, self)
        self.model.setHorizontalHeaderLabels([
            'flag', 'Water Content', 'Iron Content', 'K (Gpa)', 'G (Gpa)',
            'Rho (g/cm³)', 'Reference'
        ])
        for i in range(len(self.Minerals.Flag)):
            a = self.Minerals.Return_original_data(i)
            for j in range(0, 7):
                item = QStandardItem(str(a[j]))
                self.model.setItem(i, j, item)
                if j != 0:
                    item.setFlags(Qt.ItemIsEnabled)
                    item.setBackground(QColor(211, 211, 211))

        if flag is not None:
            self.Minerals.change_flag(flag)
            for i in range(len(self.Minerals.Flag)):
                item = QStandardItem(str(self.Minerals.Flag[i]))
                self.model.setItem(i, 0, item)

        self.table.setModel(self.model)

        self.button = QPushButton('Update and use in thermoelastic model')
        self.button.clicked.connect(self.Update)
        self.button.setAutoDefault(False)
        self.button1 = QPushButton('Add data file ')
        self.button1.clicked.connect(self.Export)
        self.button1.setAutoDefault(False)
        self.layout = QGridLayout()

        self.label = QLabel()
        self.label.setText('''
        Please input equation, Water: water content (wt%) and Fe: iron content (mol%)
        for example -2.41*Water-30*Fe+81,K'=4.1,  
        ''')

        self.Kinput_formula = QLineEdit()
        self.Ginput_formula = QLineEdit()
        self.Rhoinput_formula = QLineEdit()
        if self.stringK is not None:
            self.Kinput_formula.setText(self.stringK)
            self.Ginput_formula.setText(self.stringG)
            self.Rhoinput_formula.setText(self.stringRho)
            self.Userinput()
        else:
            self.Kinput_formula.setText(
                self.Minerals.Show_fit_function(self.Minerals.function_K()[0],
                                                self.Minerals.function_K()[1],
                                                "K'",
                                                error=False))
            self.Ginput_formula.setText(
                self.Minerals.Show_fit_function(self.Minerals.function_G()[0],
                                                self.Minerals.function_G()[1],
                                                "G'",
                                                error=False))
            self.Rhoinput_formula.setText(
                self.Minerals.Show_fit_function(
                    self.Minerals.function_Rho()[0],
                    self.Minerals.function_Rho()[1],
                    '',
                    error=False))
        self.Kinput_formula.returnPressed.connect(self.Kformula)
        self.Ginput_formula.returnPressed.connect(self.Gformula)
        self.Rhoinput_formula.returnPressed.connect(self.Rhoformula)
        #self.connect(self.Kinput_formula,SIGNAL("returnPressed()"),self.Kformula)
        #self.connect(self.Ginput_formula,SIGNAL("returnPressed()"),self.Gformula)
        #self.connect(self.Rhoinput_formula,SIGNAL("returnPressed()"),self.Rhoformula)

        self.user_change_confrim = QPushButton('Change to user input')
        self.user_change_confrim.clicked.connect(self.Userinput)
        self.user_change_confrim.setAutoDefault(False)

        self.extension = QWidget()
        self.extensionLayout = QGridLayout()
        self.extensionLayout.setContentsMargins(0, 0, 0, 0)

        labelK = QLabel()
        labelK.setText('K<sub>0</sub>=')
        labelG = QLabel()
        labelG.setText('G<sub>0</sub>=')
        labelRho = QLabel()
        labelRho.setText('Rho<sub>0</sub>=')

        self.extensionLayout.addWidget(labelK, 0, 0, 1, 3)
        self.extensionLayout.addWidget(labelG, 1, 0, 1, 3)
        self.extensionLayout.addWidget(labelRho, 2, 0, 1, 3)
        self.extensionLayout.addWidget(self.Kinput_formula, 0, 1, 1, 3)
        self.extensionLayout.addWidget(self.Ginput_formula, 1, 1, 1, 3)
        self.extensionLayout.addWidget(self.Rhoinput_formula, 2, 1, 1, 3)
        self.extensionLayout.addWidget(self.user_change_confrim, 3, 0, 9, 4)

        self.extension.setLayout(self.extensionLayout)

        self.check_change = QCheckBox("user input")
        self.check_change.setChecked(False)
        self.check_change.toggled.connect(self.extension.setVisible)

        #self.PLOT(switch=True)
        self.PLOT()
        self.layout.addWidget(self.table, 0, 1, 1, 17)
        self.layout.addWidget(self.button, 2, 0, 1, 9)
        self.layout.addWidget(self.button1, 2, 9, 1, 9)
        self.layout.addWidget(self.check_change, 3, 0, 1, 1)
        self.layout.addWidget(self.label, 3, 3, 1, 5)
        self.layout.addWidget(self.extension, 4, 0, 1, 9)
        self.setLayout(self.layout)

        self.extension.hide()
Example #13
0
    def genOneTab(self):

        tabtitle = QLabel()
        # tabtitle.setFixedHeight(40)
        # tabtitle.setFixedWidth(160)        
        self.btn_start = MyButton("开始")
        self.choicenum_text = QComboBox()
        self.choicenum_text.setObjectName('w1combonums')
        # self.w1title.setStyleSheet("background-image:url('image/panelbg.jpg');")
        
        # Set the title style                
        tabtitle.setFont(QFont('Courier New', 20))
        tabtitle.setText("随堂提问演板")
        tabtitle.setStyleSheet("border: 1px solid blue; color:rgba(0,0,255, 220);\
            background-color:rgba(201,201,201,60);\
            border-radius: 6px; \
            padding: 1px 18px 1px 20px;\
            min-width: 8em;")
        tabtitle.setMinimumHeight(50);
        titleLayout = QHBoxLayout()
        titleLayout.addWidget(tabtitle)
        titleLayout.setAlignment(tabtitle, Qt.AlignCenter)
       
        btnlayout = QGridLayout()
        tmpnum = 0
        for inum in range(0,56):
            irow = tmpnum // g_cols
            icol = tmpnum % g_cols
            tmpnum += 1
            btnlayout.setRowMinimumHeight(irow, 80)
            tmpbtn = MyButton("")
            tmpbtn.setMyarg(None)
            # tmpbtn.setFixedHeight(20)
            tmpbtn.setSizePolicy(QSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding))
            tmpbtn.setStyleSheet("border: 1px solid rgb(55,55,255,100);background-color: rgba(255,255,255,20);font-size:16px;")
            self.connect(tmpbtn,  SIGNAL("myslot(PyQt_PyObject)"), self.myslot)
            tmpbtn.setAutoDefault(False)
            self.btngroup.addButton(tmpbtn, inum+1) # stusn is from 1 start

            btnlayout.addWidget(tmpbtn, irow, icol)


        self.btn_start.setIcon(QIcon("image/start.png"))
        self.btn_start.setStyleSheet("border: 1px solid yellow;")
        self.btn_start.setFixedHeight(40)
        self.btn_start.setFixedWidth(100)
        self.btn_start.setFont(QFont('宋体', 18))
        # self.choicenum_text.setFixedHeight(45)
        # self.choicenum_text.setFixedWidth(60)

        ## Set the combox number style
        self.choicenum_text.setFont(QFont('Courier New', 20))
        self.choicenum_text.setFixedHeight(45)
        self.choicenum_text.setStyleSheet("border: 2px solid blue; color:red;font-weight:light;font-size:26px;\
            border-radius: 6px; \
            min-width: 2em; ")
        self.choicenum_text.setEditable(True)
        self.choicenum_text.lineEdit().setReadOnly(True);
        self.choicenum_text.lineEdit().setAlignment(Qt.AlignCenter);

        model = self.choicenum_text.model()
        for row in list(range(1, 7)):
            item = QStandardItem(str(row))
            item.setTextAlignment(Qt.AlignCenter)
            item.setForeground(QColor('red'))
            item.setBackground(QColor(0,200,50, 130))
            model.appendRow(item)
        self.choicenum_text.setCurrentIndex(2)
        # self.choicenum_text.setStyleSheet ("QComboBox::drop-down {border-width: 100px;}")
        # self.choicenum_text.setStyleSheet ("QComboBox::down-arrow {image: url(image/downarrow.png);top: 10px;left: 1px;}")

        bottomlayout = QHBoxLayout()
        bottomlayout.setSizeConstraint(QLayout.SetFixedSize)
        bottomlayout.addStretch(10)
        bottomlayout.addWidget(self.btn_start)
        bottomlayout.setSpacing(5)
        bottomlayout.addWidget(self.choicenum_text)

        tab1layout = QVBoxLayout()
        tab1layout.addLayout(titleLayout)       
        tab1layout.addLayout(btnlayout)
        tab1layout.addLayout(bottomlayout)
                
        self.w1.setLayout(tab1layout)
        self.w1.setStyleSheet("background-color: QLinearGradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffffff, stop: 1 #228888);")
Example #14
0
    def genOneTab(self, tabtitle="", tabbtn="", tabnums="", strwhere = "where studentsn like '03%' "):
        # tabtitle.setFixedHeight(40)
        # tabtitle.setFixedWidth(160)
        tabtitle.setFont(QFont('Courier New', 20))
        tabtitle.setText("随堂提问演板")
        tabtitle.setStyleSheet("border: 1px solid blue; color:rgba(0,0,255, 220);\
            background-color:rgba(201,201,201,60);\
            border-radius: 6px; \
            padding: 1px 18px 1px 20px;\
            min-width: 8em;")
        tabtitle.setMinimumHeight(50);
        titleLayout = QHBoxLayout()
        titleLayout.addWidget(tabtitle)
        titleLayout.setAlignment(tabtitle, Qt.AlignCenter)
       
        btnlayout = QGridLayout()
        
        cur = conn.cursor()
        strsql = "select studentsn, studentname from student " + strwhere
        cur.execute(strsql)
     
        tmpnum = 0
        for item in cur.fetchall():
            irow = tmpnum // 7
            icol = tmpnum % 7
            tmpnum += 1
            btnlayout.setRowMinimumHeight(irow, 80)

            tmpbtn = MyButton(item[1])
            tmpbtn.setMyarg(item[0])
            # tmpbtn.setFixedHeight(20)
            tmpbtn.setSizePolicy(QSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding))
            # tmpbtn.setStyleSheet("border: 1px solid rgb(255,255,255,0);background-color: rgba(255,255,255,20);font-size:16px;")
            # tmpbtn.setFlat(True)
            self.connect(tmpbtn,  SIGNAL("myslot(PyQt_PyObject)"), self.myslot)
            # self.connect(tmpbtn, SIGNAL('customContextMenuRequested(const QPoint&)'), self.on_context_menu)

            tmpbtn.setAutoDefault(False)
            self.btngroup.addButton(tmpbtn, int(item[0]))

            btnlayout.addWidget(tmpbtn, irow, icol)

        tabbtn.setIcon(QIcon("image/start.png"))
        tabbtn.setStyleSheet("border: 1px solid yellow;")
        tabbtn.setFixedHeight(40)
        tabbtn.setFixedWidth(100)
        tabbtn.setFont(QFont('宋体', 20))
        # tabnums.setFixedHeight(45)
        # tabnums.setFixedWidth(60)
        tabnums.setFont(QFont('Courier New', 20))
        tabnums.setFixedHeight(45)
        tabnums.setStyleSheet("border: 2px solid blue; color:red;font-weight:light;font-size:26px;\
            border-radius: 6px; \
            min-width: 2em; ")
        tabnums.setEditable(True)
        tabnums.lineEdit().setReadOnly(True);
        tabnums.lineEdit().setAlignment(Qt.AlignCenter);

        model = tabnums.model()
        for row in list(range(1, 7)):
            item = QStandardItem(str(row))
            item.setTextAlignment(Qt.AlignCenter)
            item.setForeground(QColor('red'))
            item.setBackground(QColor(0,200,50, 130))
            model.appendRow(item)
        tabnums.setCurrentIndex(2)
        # tabnums.setStyleSheet ("QComboBox::drop-down {border-width: 100px;}")
        # tabnums.setStyleSheet ("QComboBox::down-arrow {image: url(image/downarrow.png);top: 10px;left: 1px;}")

        bottomlayout = QHBoxLayout()
        bottomlayout.setSizeConstraint(QLayout.SetFixedSize)
        bottomlayout.addStretch(10)
        bottomlayout.addWidget(tabbtn)
        bottomlayout.setSpacing(5)
        bottomlayout.addWidget(tabnums)
     
        cur.close()
        return(titleLayout, btnlayout, bottomlayout)
Example #15
0
    def genOneTab(self, tabtitle="", tabbtn="", tabnums="", strwhere = "where studentsn like '03%' "):
        # tabtitle.setFixedHeight(40)
        # tabtitle.setFixedWidth(160)
        tabtitle.setFont(QFont('Courier New', 20))
        tabtitle.setText("随堂提问演板")
        tabtitle.setStyleSheet("border: 3px solid blue;\
            border-radius: 6px; \
            padding: 1px 18px 1px 20px;\
            min-width: 8em;")
        tabtitle.setMinimumHeight(50);
        titleLayout = QHBoxLayout()
        titleLayout.addWidget(tabtitle)
        titleLayout.setAlignment(tabtitle, Qt.AlignCenter)
       
        btnlayout = QGridLayout()
        
        cur = conn.cursor()
        strsql = "select studentsn, studentname from student " + strwhere
        cur.execute(strsql)
     
        tmpnum = 0
        for item in cur.fetchall():
            irow = tmpnum // 7
            icol = tmpnum % 7
            tmpnum += 1
            btnlayout.setRowMinimumHeight(irow, 80)

            tmpbtn = QPushButton(item[1])
            # tmpbtn.setFixedHeight(20)
            tmpbtn.setSizePolicy(QSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding))
            # tmpbtn.setStyleSheet("border: 1px solid rgb(255,255,255,0);background-color: rgba(255,255,255,20);font-size:16px;")
            tmpbtn.setFlat(True)

            popMenu = QMenu(self)
            entry1 = popMenu.addAction("正确")
            self.connect(entry1,SIGNAL('triggered()'), lambda item=item[0]: self.answerRight(item))
            entry2 = popMenu.addAction("错误")
            self.connect(entry2,SIGNAL('triggered()'), lambda item=item[0]: self.answerWrong(item))
            entry3 = popMenu.addAction("替换")
            self.connect(entry3,SIGNAL('triggered()'), lambda item=item[0]: self.resetStudent(item))
            tmpbtn.setMenu(popMenu)
            tmpbtn.setAutoDefault(False)
            self.btngroup.addButton(tmpbtn, int(item[0]))

            tmpmovie = QMovie('image/ex_stu.gif', QByteArray(), self)
            tmplabel = QLabel()
            tmplabel.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
            tmplabel.setAlignment(Qt.AlignCenter)
            tmplabel.setMovie(tmpmovie)
            tmplabel.setScaledContents(True)
            tmplabel.setLayout(QHBoxLayout())
            tmplabel.layout().setContentsMargins(0,0,0,0)
            # tmplabel.setStyleSheet("border: 1px solid rgb(255,255,255,0);background-color: rgba(255,255,255,20);font-size:16px;")
            tmplabel.layout().addWidget(tmpbtn)
            tmpmovie.start()
            tmpmovie.stop()

            btnlayout.addWidget(tmplabel, irow, icol)

        tabbtn.setIcon(QIcon("image/start.png"))
        tabbtn.setStyleSheet("border: 5px solid yellow;")
        tabbtn.setFixedHeight(40)
        tabbtn.setFixedWidth(100)
        tabbtn.setFont(QFont('宋体', 20))
        # tabnums.setFixedHeight(45)
        # tabnums.setFixedWidth(60)
        tabnums.setFont(QFont('Courier New', 20))
        tabnums.setStyleSheet("border: 5px solid blue; color:red;font-weight:bold;font-size:26px;\
            border-radius: 6px; \
            padding: 1px 1px 1px 1px;\
            min-width: 2em; ")
        tabnums.setEditable(True)
        tabnums.lineEdit().setReadOnly(True);
        tabnums.lineEdit().setAlignment(Qt.AlignCenter);

        model = tabnums.model()
        for row in list(range(1, 7)):
            item = QStandardItem(str(row))
            item.setTextAlignment(Qt.AlignCenter)
            item.setForeground(QColor('red'))
            item.setBackground(QColor(0,200,50, 130))
            model.appendRow(item)
        tabnums.setCurrentIndex(2)
        # tabnums.setStyleSheet ("QComboBox::drop-down {border-width: 100px;}")
        # tabnums.setStyleSheet ("QComboBox::down-arrow {image: url(image/downarrow.png);top: 10px;left: 1px;}")

        bottomlayout = QHBoxLayout()
        bottomlayout.setSizeConstraint(QLayout.SetFixedSize)
        bottomlayout.addStretch(10)
        bottomlayout.addWidget(tabbtn)
        bottomlayout.setSpacing(5)
        bottomlayout.addWidget(tabnums)
     
        cur.close()
        return(titleLayout, btnlayout, bottomlayout)
Example #16
0
    def PLOT(self,switch=True):
        if self.dirty==False:
            #self.Minerals.Clean_content()
            params=[]
            for i in range(20):            
                index=self.model.index(i,0)
                try:
                    aa=(float(self.model.itemData(index)[0]))
                    #print (aa)
                    params.append(aa)
                except:
                    break
            #print (params)
            self.Minerals.Change_data_from_table(params)
            #print ('wf')
        else:       
            self.Minerals.read_data()
            self.model.clear()
            self.model.setHorizontalHeaderLabels(['flag','Water Content','Iron Content','K (Gpa)','G (Gpa)', 'Rho (g/cm3)','Reference'])
            for i in range(len(self.Minerals.Flag)):
                a=self.Minerals.Return_original_data(i)
                item = QStandardItem(str(self.Minerals.Flag[i]))
                self.model.setItem(i, 0,item)  
                for j in range(1,7):
                    item = QStandardItem(str(a[j]))
                    self.model.setItem(i, j,item)  
                    if j != 0:
                        item.setFlags(Qt.ItemIsEnabled)
                        item.setBackground(QColor(211,211,211))
                        
        #print (self.Minerals.Change)     
            
            
        if self.user_input == False:
            self.a,self.b,self.c = self.Minerals.PLOT(return_fig=False,methods=self.regression_methods)       
            #print (self.Minerals.number_of_data)
            self.Kinput_formula.setText(self.Minerals.Show_fit_function(self.Minerals.function_K(methods = self.regression_methods)[0],self.Minerals.function_K(methods = self.regression_methods)[1],"K'",error=False))
            self.Ginput_formula.setText(self.Minerals.Show_fit_function(self.Minerals.function_G(methods = self.regression_methods)[0],self.Minerals.function_G(methods = self.regression_methods)[1],"G'",error=False))
            self.Rhoinput_formula.setText(self.Minerals.Show_fit_function(self.Minerals.function_Rho(methods = self.regression_methods)[0],self.Minerals.function_Rho(methods = self.regression_methods)[1],'',error=False))

        else:
            self.a,self.b,self.c = self.Minerals.PLOT_input_formula(return_fig=False)   
       
        
        
        error1,error2,error3 = self.Minerals.Return_error()
            
        self.canvas1 = FigureCanvas3D(self.a,error1)
        self.canvas2 = FigureCanvas3D(self.b,error2)
        self.canvas3 = FigureCanvas3D(self.c,error3)
        self.canvas1.mpl_connect('pick_event', self.onpick)
        self.canvas2.mpl_connect('pick_event', self.onpick)
        self.canvas3.mpl_connect('pick_event', self.onpick)
        
        self.toolbar1 = NavigationToolbar(self.canvas1, self)
        self.toolbar2 = NavigationToolbar(self.canvas2, self)
        self.toolbar3 = NavigationToolbar(self.canvas3, self) 
 
        self.layout1_widget = QWidget()
        self.layout1 = QGridLayout(self.layout1_widget)
        self.layout1_widget.setFixedSize(600, 600)
        self.layout1.addWidget(self.canvas1,0,1,5,5)
        self.layout1.addWidget(self.toolbar1,5,1,1,5)       
        self.layout1.addWidget(self.canvas2,6,1,5,5)
        self.layout1.addWidget(self.toolbar2,11,1,1,5)  
        self.layout1.addWidget(self.canvas3,12,1,5,5)
        self.layout1.addWidget(self.toolbar3,17,1,1,5)       
        self.layout.addWidget(self.layout1_widget,0,0,1,1)