def generateLeftListLogTypeModel(self): '''Returns all LogType list model ''' existingLogTypes = [] logType = LogType.GAMMA #get type for each log if self._logs is not None and len(self._logs)>0: for log in self._logs: existingLogTypes.append(log.log_type_name) generalSettings = GeneralSettings() if generalSettings.workflowType == WorkflowType.petrophysics: logTypeList = logType.getAllLogTypesPetrophysicsStringList() elif generalSettings.workflowType == WorkflowType.rockphysics: logTypeList = logType.getAllLogTypesRockPhysicsStringList() else: logTypeList = logType.getAllLogTypesStringList() model = QStandardItemModel(self._dataListToListWidget.leftDataTypeListView) for logType in logTypeList: item = QStandardItem(logType) # checkboxes are confusing item.setCheckable(False) if logType not in existingLogTypes: item.setForeground(Qt.gray) model.appendRow(item) return model
def _update_stats_model(self): # Update the results_model with up to date scores. # Note: The target class specific scores (if requested) are # computed as needed in this method. model = self.view.model() # clear the table model, but preserving the header labels for r in reversed(range(model.rowCount())): model.takeRow(r) target_index = None if self.data is not None: class_var = self.data.domain.class_var if self.data.domain.has_discrete_class and self.class_selection != self.TARGET_AVERAGE: target_index = class_var.values.index(self.class_selection) else: class_var = None errors = [] has_missing_scores = False for key, slot in self.learners.items(): name = learner_name(slot.learner) head = QStandardItem(name) head.setData(key, Qt.UserRole) if isinstance(slot.results, Try.Fail): head.setToolTip(str(slot.results.exception)) head.setText("{} (error)".format(name)) head.setForeground(QtGui.QBrush(Qt.red)) errors.append( "{name} failed with error:\n" "{exc.__class__.__name__}: {exc!s}".format(name=name, exc=slot.results.exception) ) row = [head] if class_var is not None and class_var.is_discrete and target_index is not None: if slot.results is not None and slot.results.success: ovr_results = results_one_vs_rest(slot.results.value, target_index) stats = [Try(lambda: score(ovr_results)) for score in classification_stats.scores] else: stats = None else: stats = slot.stats if stats is not None: for stat in stats: item = QStandardItem() if stat.success: item.setText("{:.3f}".format(stat.value[0])) else: item.setToolTip(str(stat.exception)) has_missing_scores = True row.append(item) model.appendRow(row) self.error("\n".join(errors), shown=bool(errors)) self.Warning.scores_not_computed(shown=has_missing_scores)
def _update_stats_model(self): # Update the results_model with up to date scores. # Note: The target class specific scores (if requested) are # computed as needed in this method. model = self.view.model() # clear the table model, but preserving the header labels for r in reversed(range(model.rowCount())): model.takeRow(r) if self.data is None: return target_index = None class_var = self.data.domain.class_var if class_var.is_discrete and \ self.class_selection != self.TARGET_AVERAGE: target_index = class_var.values.index(self.class_selection) for slot in self.learners.values(): name = learner_name(slot.learner) head = QStandardItem(name) if isinstance(slot.results, Try.Fail): head.setToolTip(str(slot.results.exception)) head.setText("{} (error)".format(name)) head.setForeground(QtGui.QBrush(Qt.red)) row = [head] if class_var.is_discrete and target_index is not None: if slot.results.success: ovr_results = results_one_vs_rest( slot.results.value, target_index) stats = [Try(lambda: score(ovr_results)) for score in classification_stats.scores] else: stats = None else: stats = slot.stats if stats is not None: for stat in stats: item = QStandardItem() if stat.success: item.setText("{:.3f}".format(stat.value[0])) else: item.setToolTip(str(stat.exception)) row.append(item) model.appendRow(row)
def scanXmlNodes ( self, filename ) : # dom = QtXml.QDomDocument ( '' ) nodeFilename = self.dirName + '/' + self.liblevel + filename file = QFile ( self.libdir.filePath ( filename ) ) if file.open ( QtCore.QIODevice.ReadOnly ) : if dom.setContent ( file ) : node = dom.documentElement () if node.nodeName () == 'nodenet' or node.nodeName () == 'node' : nodeName = node.attributes ().namedItem ( 'name' ).nodeValue () nodeType = node.attributes ().namedItem ( 'type' ).nodeValue () nodeAuthor = node.attributes ().namedItem ( 'author' ).nodeValue () nodeIcon = node.attributes ().namedItem ( 'icon' ).nodeValue () nodeHelp = '' help_tag = node.namedItem ('help') if not help_tag.isNull() : nodeHelp = help_tag.toElement ().text () item = QStandardItem ( nodeName ) item.setEditable ( False ) item.setData ( QVariant ( nodeAuthor ), QtCore.Qt.UserRole + 1 ) item.setData ( QVariant ( nodeType ), QtCore.Qt.UserRole + 2 ) item.setData ( QVariant ( nodeHelp ), QtCore.Qt.UserRole + 3 ) item.setData ( QVariant ( nodeFilename ), QtCore.Qt.UserRole + 4 ) item.setData ( QVariant ( nodeIcon ), QtCore.Qt.UserRole + 5 ) if node.nodeName () == 'nodenet' : # set Blue color for nodenet items brush = QtGui.QBrush () brush.setColor ( QtCore.Qt.blue ) item.setForeground ( brush ) item.setWhatsThis ( 'nodenet' ) else: item.setWhatsThis ( 'node' ) self.parentItem.appendRow ( item ) file.close ()
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)
def _update_stats_model(self): # Update the results_model with up to date scores. # Note: The target class specific scores (if requested) are # computed as needed in this method. model = self.view.model() # clear the table model, but preserving the header labels for r in reversed(range(model.rowCount())): model.takeRow(r) target_index = None if self.data is not None: class_var = self.data.domain.class_var if self.data.domain.has_discrete_class and \ self.class_selection != self.TARGET_AVERAGE: target_index = class_var.values.index(self.class_selection) else: class_var = None errors = [] has_missing_scores = False for key, slot in self.learners.items(): name = learner_name(slot.learner) head = QStandardItem(name) head.setData(key, Qt.UserRole) if isinstance(slot.results, Try.Fail): head.setToolTip(str(slot.results.exception)) head.setText("{} (error)".format(name)) head.setForeground(QtGui.QBrush(Qt.red)) errors.append("{name} failed with error:\n" "{exc.__class__.__name__}: {exc!s}".format( name=name, exc=slot.results.exception)) row = [head] if class_var is not None and class_var.is_discrete and \ target_index is not None: if slot.results is not None and slot.results.success: ovr_results = results_one_vs_rest(slot.results.value, target_index) stats = [ Try(lambda: score(ovr_results)) for score in classification_stats.scores ] else: stats = None else: stats = slot.stats if stats is not None: for stat in stats: item = QStandardItem() if stat.success: item.setText("{:.3f}".format(stat.value[0])) else: item.setToolTip(str(stat.exception)) has_missing_scores = True row.append(item) model.appendRow(row) if errors: self.error(3, "\n".join(errors)) else: self.error(3) if has_missing_scores: self.warning(3, "Some scores could not be computed") else: self.warning(3)
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);")
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)
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)