def TableView(self):
        self.DL.clear()
        self.ui.TableWidget.clearContents()
        file_path = self.ui.FileTextEdit.toPlainText()
        column_name = self.ui.ColumnSpinBox.text()
        column_name = int(column_name)
        fileInput(file_path, column_name, self.DL)
        if len(self.DL) == 0:
            QMessageBox.warning(self, '读取失败', '读取失败,请检查调整命名列号,或检查文件!')
            print('\a')
            return
        ColumnCount = DlMax(self.DL)
        self.ui.TableWidget.setColumnCount(ColumnCount + 2)

        headerItem = QTableWidgetItem('文件名')
        font = headerItem.font()
        font.setPointSize(11)
        headerItem.setFont(font)
        headerItem.setForeground(QBrush(Qt.black))  # 前景色,即文字颜色
        self.ui.TableWidget.setHorizontalHeaderItem(0, headerItem)

        headerItem = QTableWidgetItem('文件数量')
        font = headerItem.font()
        font.setPointSize(11)
        headerItem.setFont(font)
        headerItem.setForeground(QBrush(Qt.black))  # 前景色,即文字颜色
        self.ui.TableWidget.setHorizontalHeaderItem(1, headerItem)

        for i in range(ColumnCount):
            headerItem = QTableWidgetItem('下载地址' + str(i + 1))
            font = headerItem.font()
            font.setPointSize(11)
            headerItem.setFont(font)
            headerItem.setForeground(QBrush(Qt.black))  # 前景色,即文字颜色
            self.ui.TableWidget.setHorizontalHeaderItem(i + 2, headerItem)

        self.ui.TableWidget.setRowCount(len(self.DL))
        self.ui.TableWidget.setAlternatingRowColors(True)  # 设置交替行背景颜色
        for i in range(len(self.DL)):
            item = QTableWidgetItem()
            item.setText(str(self.DL[i].name))
            self.ui.TableWidget.setItem(i, 0, item)
            item = QTableWidgetItem()
            item.setText(str(self.DL[i].num))
            self.ui.TableWidget.setItem(i, 1, item)
            for j in range(self.DL[i].num):
                item = QTableWidgetItem()
                item.setText(self.DL[i].url[j])
                self.ui.TableWidget.setItem(i, j + 2, item)
Beispiel #2
0
 def insertRound(self, r):
     closeType = r.getCloseType()
     winner = r.getWinner()
     background = self.bgcolors[closeType]
     i = r.getNumRound() - 1
     self.insertRow(i)
     for j, player in enumerate(self.engine.getListPlayers()):
         item = QTableWidgetItem()
         item.setFlags(item.flags() ^ QtCore.Qt.ItemIsEditable)
         item.setTextAlignment(QtCore.Qt.AlignVCenter |
                               QtCore.Qt.AlignCenter)
         item.setBackground(QtGui.QBrush(QtGui.QColor(background)))
         if player == winner:
             text = i18n(
                 "RemigioRoundTable", "Winner ({}x)").format(closeType)
             font = item.font()
             font.setBold(True)
             item.setFont(font)
         elif self.engine.wasPlayerOff(
                 player, r.getNumRound()) or r.getPlayerScore(player) < 0:
             if r.getPlayerScore(player) < 0:
                 text = ""
             else:
                 text = str(r.getPlayerScore(player))
             item.setBackground(QtGui.QBrush(QtCore.Qt.gray))
         else:
             text = str(r.getPlayerScore(player))
         item.setText(text)
         self.setItem(i, j, item)
     self.scrollToBottom()
Beispiel #3
0
 def insertRound(self, r):
     winner = r.getWinner()
     i = r.getNumRound() - 1
     self.insertRow(i)
     for j, player in enumerate(self.engine.getListPlayers()):
         item = QTableWidgetItem()
         item.setFlags(item.flags() ^ QtCore.Qt.ItemIsEditable)
         item.setTextAlignment(QtCore.Qt.AlignVCenter |
                               QtCore.Qt.AlignCenter)
         if player == winner:
             text = i18n(
                 "Phase10RoundTable", "Winner")
             font = item.font()
             font.setBold(True)
             item.setFont(font)
         else:
             text = str(r.getPlayerScore(player))
         a_phase = r.getPlayerAimedPhase(player)
         c_phase = r.getPlayerCompletedPhase(player)
         text += i18n(
             "Phase10PlayerWidget", " (Phase {})").format(a_phase)
         if c_phase != 0:
             background = 0xCCFF99  # green
         else:
             background = 0xFFCC99  # red
         item.setBackground(QtGui.QBrush(QtGui.QColor(background)))
         item.setText(text)
         self.setItem(i, j, item)
     self.scrollToBottom()
Beispiel #4
0
	def on_btnSetHeader_clicked(self):
		'''
		设置表头
		表内的每个单元格都是一个QTableWidgetItem对象
		QTableWidgetItem对象实例化一共有4种方式
		    QTableWidgetItem(type: int = QTableWidgetItem.ItemType.Type):构建一个空项
		        type:默认是0
            QTableWidgetItem(str, type: int = QTableWidgetItem.ItemType.Type):构建一个带文本的项
                str:字符串
                type:是一个int,系统(Qt)保留0~1000,用户自定义需要从1001开始
            QTableWidgetItem(QIcon, str, type: int = QTableWidgetItem.ItemType.Type):构建一个带图标和文本的项
                QIcon:图标,str:字符串,
            QTableWidgetItem(QTableWidgetItem):从other复制项的内容构建一个新项

		type 参数主要为为了派生类使用,其类型为枚举类型QTableWidgetItem.ItemType,QTableWidgetItem创建的项使用缺省值QTreeWidgetItem.Type(值为0)。
		如果要从QTableWidgetItem派生子类以为应用提供自定义项时,可以为子类定义新类型,以便可以将它们与QTableWidgetItem项区分开来。
		需要此功能的子类的构造函数需要使用等于或大于QTableWidgetItem.UserType(对应整型1000)的新类型值。



		:return:
		'''
		headerText = ['姓名','性别','出生日期','民族','是否党员','分数']
		self.ui.tableInfo.setColumnCount(len(headerText))#设置列数
		for i in range(len(headerText)):
			headerItem = QTableWidgetItem(headerText[i])#实例化一个单元格,参数为单元格名称
			# print(headerItem.type())
			font = headerItem.font()#获取该单元格字体状态
			font.setPointSize(11)#为字体设置字号
			headerItem.setFont(font)#将字号大小绑定给该单元格
			headerItem.setForeground(QBrush(Qt.red))#设置单元格前景色,文字颜色
			#将该单元格设置为第i列的表头
			self.ui.tableInfo.setHorizontalHeaderItem(i,headerItem)
Beispiel #5
0
 def preview_item(self):
     item = QTableWidgetItem('Preview')
     item.setText('Preview')
     item.setForeground(QBrush(QColor(0, 0, 255)))
     link_font = QFont(item.font())
     link_font.setUnderline(True)
     item.setFont(link_font)
     item.setTextAlignment(Qt.AlignHCenter)
     return item
Beispiel #6
0
 def on_pushButton_setTableHead_clicked(self):
     headerText = ['姓 名', '性 别', '出生日期', '民 族', '分 数', '是否党员']
     self._ui.tableWidget.setColumnCount(len(headerText))
     for i, info in enumerate(headerText):
         headerItem = QTableWidgetItem(info)
         font = headerItem.font()
         font.setPointSize(11)
         headerItem.setFont(font)
         headerItem.setBackground(QBrush(Qt.red))
         self._ui.tableWidget.setHorizontalHeaderItem(i, headerItem)
Beispiel #7
0
    def __createItemsARow(self, rowNo, name, sex, birth, nation, isParty,
                          score):  ##创建一行的items
        StudID = 201805000 + rowNo  #学号

        #姓名
        item = QTableWidgetItem(name, CellType.ctName.value)
        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        font = item.font()
        font.setBold(True)
        item.setFont(font)
        item.setData(Qt.UserRole, StudID)  #关联数据
        self.ui.tableInfo.setItem(rowNo, FieldColNum.colName.value, item)

        #性别
        if (sex == "男"):
            icon = QIcon(":/icons/images/boy.ico")
        else:
            icon = QIcon(":/icons/images/girl.ico")
        item = QTableWidgetItem(sex, CellType.ctSex.value)
        item.setIcon(icon)
        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        self.ui.tableInfo.setItem(rowNo, FieldColNum.colSex.value, item)

        #出生日期
        strBitrh = birth.toString("yyyy-MM-dd")  #日期转换为字符串
        item = QTableWidgetItem(strBitrh, CellType.ctBirth.value)
        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        self.ui.tableInfo.setItem(rowNo, FieldColNum.colBirth.value, item)

        #民族
        item = QTableWidgetItem(nation, CellType.ctNation.value)
        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        if (nation != "汉族"):
            item.setForeground(QBrush(Qt.blue))
        self.ui.tableInfo.setItem(rowNo, FieldColNum.colNation.value, item)

        #分数
        strScore = str(score)
        item = QTableWidgetItem(strScore, CellType.ctScore.value)
        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        self.ui.tableInfo.setItem(rowNo, FieldColNum.colScore.value, item)

        #党员
        item = QTableWidgetItem("党员", CellType.ctPartyM.value)
        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        if (isParty == True):
            item.setCheckState(Qt.Checked)
        else:
            item.setCheckState(Qt.Unchecked)
        item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled
                      | Qt.ItemIsUserCheckable)  #不允许编辑文字
        item.setBackground(QBrush(Qt.yellow))  #Qt::green  lightGray  yellow
        self.ui.tableInfo.setItem(rowNo, FieldColNum.colPartyM.value,
                                  item)  #为单元格设置Item
Beispiel #8
0
 def setMyData(self):
     for row, item in enumerate(self.data):
         title_item = QTableWidgetItem(item[0])
         font = title_item.font()
         font.setBold(True)
         title_item.setFont(font)
         if self.use_icons:
             icon = QIcon(icon_dir + QtCore.QUrl(item[1]).host() + '.png')
             if icon.pixmap(16, 16).isNull(): icon = QIcon(':/quartz.png')
             title_item.setIcon(icon)
         self.setItem(row, 0, title_item)
Beispiel #9
0
 def setMyData(self):
     for row, item in enumerate(self.data):
         title_item = QTableWidgetItem(item[0])
         font = title_item.font()
         font.setBold(True)
         title_item.setFont(font)
         if self.use_icons:
             icon = QIcon(icon_dir + item[1].split('/')[2] + '.png')
             if icon.pixmap(16, 16).isNull():
                 icon = QIcon.fromTheme('applications-internet')
             title_item.setIcon(icon)
         self.setItem(row, 0, title_item)
Beispiel #10
0
    def on_btnSetHeader_clicked(self):
        headerText = ["姓 名", "性 别", "出生日期", "民 族", "分数", "是否党员"]
        self.ui.tableInfo.setColumnCount(len(headerText))  #列数
        ##        self.ui.tableInfo.setHorizontalHeaderLabels(headerText)   #简单的表头文字,无格式

        for i in range(len(headerText)):
            headerItem = QTableWidgetItem(headerText[i])
            font = headerItem.font()
            ##  font.setBold(True)
            font.setPointSize(11)
            headerItem.setFont(font)
            headerItem.setForeground(QBrush(Qt.red))  #前景色,即文字颜色
            self.ui.tableInfo.setHorizontalHeaderItem(i, headerItem)
Beispiel #11
0
    def on_btnSetHeader_clicked(self):
        # headerText = ["功率1", "功率2", "桨叶1", "桨叶2", "风速1", "风速2", "转速1", "转速2", "风速",
        #               "理论功率", "过滤系数 * 理论功率", "风速下限", "风速上限"]
        headerText = ["功率1", "功率2", "桨叶1", "桨叶2", "风速1", "风速2", "转速1", "转速2"]
        self.ui.tableInfo.setColumnCount(len(headerText))  # 列数
        #       self.ui.tableInfo.setHorizontalHeaderLabels(headerText)   #简单的表头文字,无格式

        for i in range(len(headerText)):
            headerItem = QTableWidgetItem(headerText[i])
            font = headerItem.font()
            #  font.setBold(True)
            font.setPointSize(11)
            headerItem.setFont(font)
            headerItem.setForeground(QBrush(Qt.red))  # 前景色,即文字颜色
            self.ui.tableInfo.setHorizontalHeaderItem(i, headerItem)
Beispiel #12
0
	def __createItemARow(self,rowNo,name,sex,birth,nation,isParty,score):
		StudID = 201805000+rowNo
		#姓名
		item = QTableWidgetItem(name,CellType.ctName.value)#实例一个有姓名的单元格,
		item.setTextAlignment(Qt.AlignHCenter|Qt.AlignVCenter)#水平+垂直居中
		font = item.font()
		font.setBold(True)
		item.setFont(font)
		item.setData(Qt.UserRole,StudID)#设置自定义数据,将学生ID存入,该数据不会显示在界面
		self.ui.tableInfo.setItem(rowNo,FieldColNum.colName.value,item)#第1(0)行1(0)列,设置item单元格
		#性别
		if sex == '男':
			icon = QIcon(":/icons/images/boy.ico")
		else:
			icon = QIcon(":/icons/images/girl.ico")

		item = QTableWidgetItem(sex,CellType.ctSex.value)
		item.setIcon(icon)#设置图标
		item.setTextAlignment(Qt.AlignHCenter|Qt.AlignVCenter)
		self.ui.tableInfo.setItem(rowNo,FieldColNum.colSex.value,item)
		#出生日期
		strBirth = birth.toString('yyyy-MM-dd')
		item = QTableWidgetItem(strBirth,CellType.ctBirth.value)
		item.setTextAlignment(Qt.AlignHCenter|Qt.AlignVCenter)
		self.ui.tableInfo.setItem(rowNo,FieldColNum.colBirth.value,item)
		#民族
		item = QTableWidgetItem(nation,CellType.cnNation.value)
		item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
		if nation != '汉族':
			item.setForeground(QBrush(Qt.blue))#设置文字颜色为蓝色
		self.ui.tableInfo.setItem(rowNo,FieldColNum.colNation.value,item)
		#党员
		item = QTableWidgetItem("党员",CellType.ctPartyM.value)
		item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
		if  isParty == True:
			item.setCheckState(Qt.Checked)#选中
		else:
			item.setCheckState(Qt.Unchecked)#不选择
		item.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled|Qt.ItemIsUserCheckable)#可选,能被选(锁定),可被复选(为True带有复选框)
		item.setBackground(QBrush(Qt.yellow))
		self.ui.tableInfo.setItem(rowNo,FieldColNum.colParthM.value,item)
		#分数
		strScore = str(score)
		item = QTableWidgetItem(strScore,CellType.cnScore.value)
		item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
		self.ui.tableInfo.setItem(rowNo,FieldColNum.colScore.value,item)
    def __init__(self, parameters: list, modulation_type: str, parent=None):
        super().__init__(parent)
        self.ui = Ui_DialogModulationParameters()
        self.ui.setupUi(self)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setWindowFlags(Qt.Window)

        self.parameters = parameters
        self.num_bits = int(math.log2(len(parameters)))

        if "FSK" in modulation_type:
            self.ui.tblSymbolParameters.setItemDelegateForColumn(
                1, KillerSpinBoxDelegate(-1e12, 1e12, self))
            self.ui.tblSymbolParameters.horizontalHeaderItem(1).setText(
                "Frequency in Hz")
        elif "ASK" in modulation_type:
            self.ui.tblSymbolParameters.horizontalHeaderItem(1).setText(
                "Amplitude")
            self.ui.tblSymbolParameters.setItemDelegateForColumn(
                1, SpinBoxDelegate(0, 100, self, "%"))
        elif "PSK" in modulation_type:
            self.ui.tblSymbolParameters.setItemDelegateForColumn(
                1, SpinBoxDelegate(-360, 360, self, "°"))
            self.ui.tblSymbolParameters.horizontalHeaderItem(1).setText(
                "Phase")

        fmt = "{0:0" + str(self.num_bits) + "b}"
        self.ui.tblSymbolParameters.setRowCount(len(parameters))
        for i, parameter in enumerate(parameters):
            item = QTableWidgetItem(fmt.format(i))
            font = item.font()
            font.setBold(True)
            item.setFont(font)
            item.setFlags(Qt.ItemIsEnabled)
            self.ui.tblSymbolParameters.setItem(i, 0, item)

            item = QTableWidgetItem()
            item.setData(Qt.DisplayRole, self.parameters[i])
            self.ui.tblSymbolParameters.setItem(i, 1, item)
            self.ui.tblSymbolParameters.openPersistentEditor(
                self.ui.tblSymbolParameters.item(i, 1))

        self.create_connects()
Beispiel #14
0
    def insertRound(self, entry):
        kind = entry.getKind()
        kinds = self.engine.getEntryKinds()
        background = self.bgcolors[kinds.index(kind)]
        kind = i18n("CarcassonneInputWidget", kind)
        i = entry.getNumRound() - 1
        self.insertRow(i)
        for j, player in enumerate(self.engine.getListPlayers()):
            item = QTableWidgetItem()
            item.setFlags(item.flags() ^ QtCore.Qt.ItemIsEditable)
            item.setTextAlignment(QtCore.Qt.AlignVCenter |
                                  QtCore.Qt.AlignCenter)
            item.setBackground(QtGui.QBrush(QtGui.QColor(background)))

            if player == entry.getPlayer():
                text = "{} ({})".format(entry.getPlayerScore(), kind)
                font = item.font()
                font.setBold(True)
                item.setFont(font)
            else:
                text = ""
            item.setText(text)
            self.setItem(i, j, item)
        self.scrollToBottom()
Beispiel #15
0
    def init_iu(self):
        # insist on white background color (for linux, mac)
        self.setAutoFillBackground(True)
        p = self.palette()
        p.setColor(self.backgroundRole(), Qt.white)
        self.setPalette(p)

        """ about_tab """
        about_tab = QScrollArea()
        about_tab.setAutoFillBackground(True)  # insist on white background color (for linux, mac)
        about_tab.setPalette(p)
        about_tab.setWidgetResizable(True)
        about_tab.setFrameShape(QFrame.NoFrame)
        about_frame = QFrame()
        about_frame.setFrameShape(QFrame.NoFrame)
        about_frame.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        about_tab.setWidget(about_frame)
        about_layout = QFormLayout()
        home_page_label = QLabel("<a href='https://habby.wiki.inrae.fr'>https://habby.wiki.inrae.fr</a>")
        home_page_label.setOpenExternalLinks(True)
        github_page_label = QLabel("<a href='https://github.com/YannIrstea/habby'>https://github.com/YannIrstea/habby</a>")
        github_page_label.setOpenExternalLinks(True)
        about_layout.addRow(QLabel(self.tr("HABBY version")), QLabel(HABBY_VERSION_STR))
        about_layout.addRow(QLabel(self.tr("Qt version")), QLabel(PYQT_VERSION_STR))
        about_layout.addRow(QLabel(self.tr("GDAL/OGR version")), QLabel(GDAL_VERSION_STR))
        about_layout.addRow(QLabel(self.tr("triangle version")), QLabel(TRIANGLE_VERSION_STR))
        about_layout.addRow(QLabel(self.tr("h5py version")), QLabel(H5PY_VERSION_STR))
        about_layout.addRow(QLabel(self.tr("hdf5 version")), QLabel(HDF5_VERSION_STR))
        about_layout.addRow(QLabel(self.tr("qdarkstyle version")), QLabel(QDARKSTYLE_VERSION_STR))
        about_layout.addRow(QLabel(self.tr("OS version")), QLabel(OS_VERSION_STR()))
        about_layout.addRow(QLabel(self.tr("HABBY official web site")), home_page_label)
        about_layout.addRow(QLabel(self.tr("HABBY github web site")), github_page_label)
        about_layout.setAlignment(Qt.AlignTop)
        about_frame.setLayout(about_layout)

        """ developer_tab """
        developer_tab = QScrollArea()
        developer_tab.setAutoFillBackground(True)  # insist on white background color (for linux, mac)
        developer_tab.setPalette(p)
        developer_tab.setWidgetResizable(True)
        developer_tab.setFrameShape(QFrame.NoFrame)
        developer_frame = QFrame() 
        developer_frame.setFrameShape(QFrame.NoFrame)
        developer_frame.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        developer_tab.setWidget(developer_frame)
        developer_layout = QVBoxLayout()
        self.developer_tablewidget = QTableWidget()
        self.developer_tablewidget.setFrameShape(QFrame.NoFrame)
        self.developer_tablewidget.setShowGrid(False)
        self.developer_tablewidget.setEditTriggers(QAbstractItemView.NoEditTriggers) 
        self.developer_tablewidget.verticalHeader().setVisible(False)
        self.developer_tablewidget.horizontalHeader().setVisible(False)
        #self.developer_tablewidget.horizontalHeader().setStretchLastSection(True)
        my_developer_list = []
        with open(os.path.join("doc", "table_developpers.txt"), 'r', encoding='utf-8') as f:
            for line_num, line in enumerate(f):
                my_developer_list.append(line.strip().split("\t"))
        self.developer_tablewidget.setRowCount(len(my_developer_list))
        self.developer_tablewidget.setColumnCount(len(my_developer_list[0]))
        for line_num in range(len(my_developer_list)):
            for header_num in range(len(my_developer_list[line_num])):
                twi = QTableWidgetItem(my_developer_list[line_num][header_num])
                current_font = twi.font()
                current_font.setPointSize(7)
                twi.setFont(current_font)
                self.developer_tablewidget.setItem(line_num, header_num, twi)
        self.developer_tablewidget.verticalHeader().setDefaultSectionSize(self.developer_tablewidget.verticalHeader().minimumSectionSize())
        self.developer_tablewidget.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
        developer_layout.addWidget(self.developer_tablewidget)
        developer_layout.setAlignment(Qt.AlignTop)
        developer_frame.setLayout(developer_layout)

        """ contributor_tab """
        contributor_tab = QScrollArea()
        contributor_tab.setAutoFillBackground(True)  # insist on white background color (for linux, mac)
        contributor_tab.setPalette(p)
        contributor_tab.setWidgetResizable(True)
        contributor_tab.setFrameShape(QFrame.NoFrame)
        contributor_frame = QFrame() 
        contributor_frame.setFrameShape(QFrame.NoFrame)
        contributor_frame.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        contributor_tab.setWidget(contributor_frame)
        contributor_layout = QVBoxLayout()
        self.contributor_tablewidget = QTableWidget()
        self.contributor_tablewidget.setFrameShape(QFrame.NoFrame)
        self.contributor_tablewidget.setShowGrid(False)
        self.contributor_tablewidget.setEditTriggers(QAbstractItemView.NoEditTriggers) 
        self.contributor_tablewidget.verticalHeader().setVisible(False)
        self.contributor_tablewidget.horizontalHeader().setVisible(False)
        #self.contributor_tablewidget.horizontalHeader().setStretchLastSection(True)
        my_contributor_list = []
        with open(os.path.join("doc", "table_contributors.txt"), 'r', encoding='utf-8') as f:
            for line_num, line in enumerate(f):
                my_contributor_list.append(line.strip().split("\t"))
        self.contributor_tablewidget.setRowCount(len(my_contributor_list))
        self.contributor_tablewidget.setColumnCount(len(my_contributor_list[0]))
        for line_num in range(len(my_contributor_list)):
            for header_num in range(len(my_contributor_list[line_num])):
                twi = QTableWidgetItem(my_contributor_list[line_num][header_num])
                current_font = twi.font()
                current_font.setPointSize(7)
                twi.setFont(current_font)
                self.contributor_tablewidget.setItem(line_num, header_num, twi)
        self.contributor_tablewidget.verticalHeader().setDefaultSectionSize(self.contributor_tablewidget.verticalHeader().minimumSectionSize())
        self.contributor_tablewidget.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
        contributor_layout.addWidget(self.contributor_tablewidget)
        contributor_layout.setAlignment(Qt.AlignTop)
        contributor_frame.setLayout(contributor_layout)

        """ thanks_tab """
        thanks_tab = QScrollArea()
        thanks_tab.setAutoFillBackground(True)  # insist on white background color (for linux, mac)
        thanks_tab.setPalette(p)
        thanks_tab.setWidgetResizable(True)
        thanks_tab.setFrameShape(QFrame.NoFrame)
        thanks_frame = QFrame()
        thanks_frame.setFrameShape(QFrame.NoFrame)
        thanks_frame.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        thanks_tab.setWidget(thanks_frame)
        thanks_layout = QVBoxLayout()
        self.thanks_tablewidget = QTableWidget()
        self.thanks_tablewidget.setFrameShape(QFrame.NoFrame)
        self.thanks_tablewidget.setShowGrid(False)
        self.thanks_tablewidget.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.thanks_tablewidget.verticalHeader().setVisible(False)
        self.thanks_tablewidget.horizontalHeader().setVisible(False)
        #self.thanks_tablewidget.horizontalHeader().setStretchLastSection(True)
        my_thanks_list = []
        with open(os.path.join("doc", "table_acknowledgements.txt"), 'r', encoding='utf-8') as f:
            for line_num, line in enumerate(f):
                my_thanks_list.append(line.strip().split("\t"))
        self.thanks_tablewidget.setRowCount(len(my_thanks_list))
        self.thanks_tablewidget.setColumnCount(len(my_thanks_list[0]))
        for line_num in range(len(my_thanks_list)):
            for header_num in range(len(my_thanks_list[line_num])):
                twi = QTableWidgetItem(my_thanks_list[line_num][header_num])
                current_font = twi.font()
                current_font.setPointSize(7)
                twi.setFont(current_font)
                self.thanks_tablewidget.setItem(line_num, header_num, twi)
        self.thanks_tablewidget.verticalHeader().setDefaultSectionSize(self.thanks_tablewidget.verticalHeader().minimumSectionSize())
        self.thanks_tablewidget.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
        thanks_layout.addWidget(self.thanks_tablewidget)
        thanks_layout.setAlignment(Qt.AlignTop)
        thanks_frame.setLayout(thanks_layout)

        """ translator_tab """
        translator_tab = QScrollArea()
        translator_tab.setAutoFillBackground(True)  # insist on white background color (for linux, mac)
        translator_tab.setPalette(p)
        translator_tab.setWidgetResizable(True)
        translator_tab.setFrameShape(QFrame.NoFrame)
        translator_frame = QFrame()
        translator_frame.setFrameShape(QFrame.NoFrame)
        translator_frame.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        translator_tab.setWidget(translator_frame)
        translator_layout = QVBoxLayout()
        self.translator_tablewidget = QTableWidget()
        self.translator_tablewidget.setFrameShape(QFrame.NoFrame)
        self.translator_tablewidget.setShowGrid(False)
        self.translator_tablewidget.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.translator_tablewidget.verticalHeader().setVisible(False)
        self.translator_tablewidget.horizontalHeader().setVisible(False)
        #self.translator_tablewidget.horizontalHeader().setStretchLastSection(True)
        my_translator_list = []
        with open(os.path.join("doc", "table_translators.txt"), 'r', encoding='utf-8') as f:
            for line_num, line in enumerate(f):
                my_translator_list.append(line.strip().split("\t"))
        self.translator_tablewidget.setRowCount(len(my_translator_list))
        self.translator_tablewidget.setColumnCount(len(my_translator_list[0]))
        for line_num in range(len(my_translator_list)):
            for header_num in range(len(my_translator_list[line_num])):
                twi = QTableWidgetItem(my_translator_list[line_num][header_num])
                current_font = twi.font()
                current_font.setPointSize(7)
                twi.setFont(current_font)
                self.translator_tablewidget.setItem(line_num, header_num, twi)
        self.translator_tablewidget.verticalHeader().setDefaultSectionSize(self.translator_tablewidget.verticalHeader().minimumSectionSize())
        self.translator_tablewidget.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeToContents)
        translator_layout.addWidget(self.translator_tablewidget)
        translator_layout.setAlignment(Qt.AlignTop)
        translator_frame.setLayout(translator_layout)

        """ licence_tab """
        licence_tab = QScrollArea()
        licence_tab.setAutoFillBackground(True)  # insist on white background color (for linux, mac)
        licence_tab.setPalette(p)
        licence_tab.setWidgetResizable(True)
        licence_tab.setFrameShape(QFrame.NoFrame)
        licence_frame = QFrame()
        licence_frame.setFrameShape(QFrame.NoFrame)
        licence_frame.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        licence_tab.setWidget(licence_frame)
        licence_layout = QVBoxLayout()
        self.licence_label = QLabel()
        licence_layout.addWidget(self.licence_label)
        licence_layout.setAlignment(Qt.AlignTop)
        licence_frame.setLayout(licence_layout)

        """ last line """
        inrae_label = QLabel()
        inrae_label.setPixmap(QPixmap("file_dep/INRAE.png").scaled(inrae_label.size() * 0.2, Qt.KeepAspectRatio))
        ofb_label = QLabel()
        ofb_label.setPixmap(QPixmap("file_dep/OFB.png").scaled(ofb_label.size() * 0.2, Qt.KeepAspectRatio))
        edf_label = QLabel()
        edf_label.setPixmap(QPixmap("file_dep/EDF.png").scaled(edf_label.size() * 0.2, Qt.KeepAspectRatio))
        self.close_button = QPushButton(self.tr("Close"))
        self.close_button.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
        self.close_button.clicked.connect(self.close_dialog)

        """ general """
        self.tab_widget = QTabWidget()
        self.tab_widget.setTabBar(src_GUI.dev_tools_GUI.LeftHorizontalTabBar(self))  # horizontal tab title text
        self.tab_widget.setTabPosition(QTabWidget.West)  # tab position to le left
        self.tab_widget.addTab(about_tab, self.tr("About"))
        self.tab_widget.addTab(developer_tab, self.tr("Developers"))
        self.tab_widget.addTab(contributor_tab, self.tr("Contributors"))
        self.tab_widget.addTab(thanks_tab, self.tr("Acknowledgements"))
        self.tab_widget.addTab(translator_tab, self.tr("Translators"))
        self.tab_widget.addTab(licence_tab, self.tr("Licence"))

        """ LAYOUT """
        # last_line_layout
        last_line_layout = QHBoxLayout()
        last_line_layout.addWidget(inrae_label)
        last_line_layout.addWidget(ofb_label)
        last_line_layout.addWidget(edf_label)
        last_line_layout.addStretch()
        last_line_layout.addWidget(self.close_button)
        last_line_layout.setAlignment(inrae_label, Qt.AlignLeft)
        last_line_layout.setAlignment(ofb_label, Qt.AlignLeft)
        last_line_layout.setAlignment(edf_label, Qt.AlignLeft)
        last_line_layout.setAlignment(self.close_button, Qt.AlignRight)

        # general
        layout = QVBoxLayout(self)
        layout.addWidget(self.tab_widget)
        layout.addLayout(last_line_layout)
        self.setWindowTitle(self.tr("About HABBY"))
        self.setWindowIcon(QIcon(self.name_icon))
        self.resize(650, 500)
        self.setModal(True)
Beispiel #16
0
    def __createItemsARow(self, rowNo, name, sex, birth, nation, isParty,
                          score):
        """创建行

        :param rowNo: 行号
        :param name: 学生名字
        :param sex: 学生性别
        :param birth: 出生日期
        :param nation: 民族
        :param isParty: 是否为党员
        :param score: 得分
        :return: None
        """
        ID = 2018101000 + rowNo  # 学号

        # 姓名
        item = QTableWidgetItem(name, CellType.ctName.value)
        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)  # 设置对齐方式
        font = item.font()  # 设置字体
        font.setBold(True)
        item.setFont(font)
        item.setData(Qt.UserRole, ID)  # 关联数据
        self._ui.tableWidget.setItem(rowNo, FieldColNum.colName.value,
                                     item)  # 创建姓名单元格

        # 性别
        if sex == '男':
            icon = QIcon(':icon/images/boy.ico')  # 设置图标
        else:
            icon = QIcon(':icon/images/girl.ico')
        item = QTableWidgetItem(sex, CellType.ctSex.value)
        item.setIcon(icon)
        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        self._ui.tableWidget.setItem(rowNo, FieldColNum.colSex.value,
                                     item)  # 创建性别单元格

        # 生日
        strBirth = birth.toString('yyyy-MM-dd')  # 将时间转换成字符串
        item = QTableWidgetItem(strBirth, CellType.ctBirth.value)
        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        self._ui.tableWidget.setItem(rowNo, FieldColNum.colBirth.value,
                                     item)  # 创建生日单元格

        # 民族
        item = QTableWidgetItem(nation, CellType.ctNation.value)
        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        if nation != '汉':
            item.setForeground(QBrush(Qt.blue))
        self._ui.tableWidget.setItem(rowNo, FieldColNum.colNation.value,
                                     item)  # 创建民族单元格

        # 得分
        item = QTableWidgetItem(str(score), CellType.ctScore.value)
        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        self._ui.tableWidget.setItem(rowNo, FieldColNum.colScore.value,
                                     item)  # 创建得分单元格

        # 是否是党员
        item = QTableWidgetItem('党员', CellType.ctPartyM.value)
        item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        if isParty:
            item.setCheckState(Qt.Checked)
        else:
            item.setCheckState(Qt.Unchecked)
        item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled
                      | Qt.ItemIsUserCheckable)
        item.setBackground(QBrush(Qt.yellow))
        self._ui.tableWidget.setItem(rowNo, FieldColNum.colPartM.value,
                                     item)  # 创建是否是党员单元格