コード例 #1
0
	def __init__(self, parent):
		super(UserManagerWidget, self).__init__(parent)
		self.parent = parent

		self.sort_order = 'by_name'

		view.notifier.observers.append(self)

		self.header_label = QLabel('Users')

		self.header_widget = QWidget(self)
		header_layout = QBoxLayout(QBoxLayout.LeftToRight)
		header_layout.addWidget(self.header_label)
		self.header_widget.setLayout(header_layout)

		self.sort_by_name_btn = QPushButton('Sort by Name', self)
		self.sort_by_name_btn.clicked.connect(self.sort_by_name)
		self.sort_by_rank_btn = QPushButton('Sort by Rank', self)
		self.sort_by_rank_btn.clicked.connect(self.sort_by_rank)

		self.sort_btns_widget = QWidget(self)
		sort_btns_layout = QBoxLayout(QBoxLayout.LeftToRight)
		sort_btns_layout.addWidget(self.sort_by_name_btn)
		sort_btns_layout.addSpacing(10)
		sort_btns_layout.addWidget(self.sort_by_rank_btn)
		self.sort_btns_widget.setLayout(sort_btns_layout)

		self.user_list = QTableWidget(style.style_loader.TABLE_INITIAL_LENGTH, 3, self)
		self.user_list.setFixedHeight(300)
		self.user_list.setFixedWidth(400)
		self.user_list.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
		self.user_list.verticalHeader().setSectionResizeMode(QHeaderView.Fixed)

		self.user_list_widget = QWidget(self)
		user_list_layout = QBoxLayout(QBoxLayout.LeftToRight)
		user_list_layout.addWidget(self.user_list)
		self.user_list_widget.setLayout(user_list_layout)

		self.add_player_btn = QPushButton('Add User', self)
		self.add_player_btn.clicked.connect(self.parent.show_add_user_widget)
		self.remove_player_btn = QPushButton('Remove User', self)
		self.remove_player_btn.clicked.connect(self.parent.show_remove_user_widget)

		self.player_btns_widget = QWidget(self)
		player_btn_layout = QBoxLayout(QBoxLayout.LeftToRight)
		player_btn_layout.addWidget(self.add_player_btn)
		player_btn_layout.addSpacing(10)
		player_btn_layout.addWidget(self.remove_player_btn)
		self.player_btns_widget.setLayout(player_btn_layout)

		self.error = None

		layout = QFormLayout()
		layout.addRow(self.header_widget)
		layout.addRow(self.sort_btns_widget)
		layout.addRow(self.user_list_widget)
		layout.addRow(self.player_btns_widget)
		self.setLayout(layout)

		self.update()
コード例 #2
0
ファイル: study_CheckBox.py プロジェクト: kingdelee/PyQtStudy
    def __init__(self):
        super(MyWindow, self).__init__()
        self.initGUI("PyQt5 学习 QCheckBox")

        layout = QGridLayout()
        self.setLayout(layout)

        self.checkbox1 = QCheckBox("Kestrel")
        self.checkbox1.setToolTip("什么意思")
        # FIXME: 为什么不能显示 WhatsThis?
        self.checkbox1.setWhatsThis("帮助文档也解决不了这个问题")
        self.checkbox1.setChecked(True)
        self.checkbox1.toggled.connect(self.checkbox_toggled)
        layout.addWidget(self.checkbox1, 0, 0)

        self.checkbox2 = QCheckBox("Sparrowhawk")
        self.checkbox2.setWhatsThis("帮助文档:看起来像是什么老鹰")
        self.checkbox2.toggled.connect(self.checkbox_toggled)
        layout.addWidget(self.checkbox2, 1, 0)

        self.checkbox3 = QCheckBox("Hobby")
        self.checkbox3.setToolTip("兴趣爱好")
        self.checkbox3.toggled.connect(self.checkbox_toggled)
        layout.addWidget(self.checkbox3, 2, 0)

        layout2 = QBoxLayout(QBoxLayout.TopToBottom)
        layout.addLayout(layout2, 0, 1)
        layout.setHorizontalSpacing(5)

        self.checkbox4 = QCheckBox("Sex")
        self.checkbox4.setToolTip("三态复选框")
        self.checkbox4.setTristate(True)
        self.checkbox4.setCheckState(True)
        self.checkbox4.toggled.connect(self.checkbox_toggled)
        self.checkbox4.clicked.connect(self.on_clicked)
        layout2.addWidget(self.checkbox4)

        self.checkbox5 = QCheckBox("Age")
        self.checkbox5.setToolTip("两态复选框")
        self.checkbox5.setTristate(False)
        self.checkbox5.setChecked(True)
        self.checkbox5.toggled.connect(self.checkbox_toggled)
        layout2.addWidget(self.checkbox5)

        self.btn = QPushButton("Click Me")
        self.btn.setWhatsThis("点击我呀笨蛋")
        layout2.addSpacing(10)
        layout2.addWidget(self.btn)
コード例 #3
0
 def __init__(self, parent):
     super(EconomyTab, self).__init__()
     mainLayout = QBoxLayout(QBoxLayout.TopToBottom)
     rowLayout = [QBoxLayout(QBoxLayout.LeftToRight) for i in range(2)]
     grandTableLayout = QBoxLayout(QBoxLayout.LeftToRight)
     chartLayout = [QBoxLayout(QBoxLayout.TopToBottom) for i in range(5)]
     self.title = [QLabel("Title " + str(i)) for i in range(5)]
     for i in range(5):
         chartLayout[i].addWidget(self.title[i])
     chartLayout[0].addLayout(grandTableLayout)
     rowLayout[0].addLayout(chartLayout[0])
     rowLayout[0].addLayout(chartLayout[1])
     for i in range(2, 5, 1):
         rowLayout[1].addLayout(chartLayout[i])
     mainLayout.addLayout(rowLayout[0])
     mainLayout.addSpacing(50)
     mainLayout.addLayout(rowLayout[1])
     dataColLayout = [QBoxLayout(QBoxLayout.TopToBottom) for i in range(6)]
     for i in range(5):
         grandTableLayout.addLayout(dataColLayout[i])
     self.gnpCol = [QLabel("Text " + str(i)) for i in range(20)]
     for i in range(20):
         dataColLayout[i // 5].addWidget(self.gnpCol[i])
     tableLayout = [QBoxLayout(QBoxLayout.LeftToRight) for i in range(3)]
     for i in range(3):
         chartLayout[i + 2].addLayout(tableLayout[i])
     self.charts = [BarChart([[randint(10,100) for i in range(8)] for j in range(3)], 1)] + \
         [LineChart([[randint(10,100) for i in range(8)] for j in range(1)]) for k in range(3)]
     chartViews = [QChartView() for i in range(4)]
     chartViews[0].setFixedSize(250, 170)
     _setCharts(self.charts, chartViews)
     for i in range(4):
         chartLayout[i + 1].addWidget(chartViews[i])
     lowChartsColumnLayout = [
         QBoxLayout(QBoxLayout.TopToBottom) for i in range(6)
     ]
     for i in range(6):
         tableLayout[i // 2].addLayout(lowChartsColumnLayout[i])
     self.data = [QLabel("Data " + str(i)) for i in range(12)]
     for i in range(12):
         lowChartsColumnLayout[i // 2].addWidget(self.data[i])
     self.setLayout(mainLayout)
コード例 #4
0
 def __init__(self, parent):
     super(BasicInfoTab, self).__init__()
     mainLayout = QBoxLayout(QBoxLayout.TopToBottom)
     mainTableLayout = QBoxLayout(QBoxLayout.LeftToRight)
     headerLayout = QBoxLayout(QBoxLayout.LeftToRight)
     mainLowerLayout = QBoxLayout(QBoxLayout.LeftToRight)
     column = [QBoxLayout(QBoxLayout.TopToBottom) for i in range(4)]
     lowerColumn = [QBoxLayout(QBoxLayout.TopToBottom) for i in range(2)]
     self.hint = QLabel()
     headerLayout.addSpacing(172)
     headerLayout.addWidget(self.hint)
     self.topHeader = [QLabel(str(i)) for i in range(3)]
     column[0].addSpacing(20)
     for i in range(1, 4):
         column[i].addWidget(self.topHeader[i - 1])
     self.paramName = [QLabel("param " + str(i)) for i in range(20)]
     for i in range(20):
         if i <= 11: column[0].addWidget(self.paramName[i])
         else: lowerColumn[0].addWidget(self.paramName[i])
     self.sprpwrVal = [QLabel("data " + str(i)) for i in range(24)]
     for i in range(24):
         column[1 if i < 12 else 2].addWidget(self.sprpwrVal[i])
     self.otherVal = [QLabel() for i in range(12)]
     for i in self.otherVal:
         column[3].addWidget(i)
     self.infoVal = [QLabel("info " + str(i)) for i in range(8)]
     for i in self.infoVal:
         lowerColumn[1].addWidget(i)
     # Local news section
     self.localNewsGroup = QGroupBox("Local insights")
     self.localNewsLabel = QTextEdit()
     tmp = QBoxLayout(QBoxLayout.LeftToRight)
     tmp.addWidget(self.localNewsLabel)
     self.localNewsGroup.setLayout(tmp)
     # putting it all together
     for i in column:
         mainTableLayout.addLayout(i)
     for i in lowerColumn:
         mainLowerLayout.addLayout(i)
     mainLowerLayout.addSpacing(50)
     mainLowerLayout.addWidget(self.localNewsGroup)
     #preview = QGraphicsView(parent.mapView.scene())
     #preview.setFixedSize(200,200)
     #mainLowerLayout.addWidget(preview)
     mainLayout.addLayout(mainTableLayout)
     mainLayout.addLayout(headerLayout)
     mainLayout.addSpacing(5)
     mainLayout.addLayout(mainLowerLayout)
     self.setLayout(mainLayout)
コード例 #5
0
	def __init__(self, parent):
		super(TournamentOrganizerWidget, self).__init__(parent)
		self.parent = parent

		# Default Players (for quick testing)
		player_names = [
			'Frodo',
			'Sam',
			'Merry',
			'Pippin',
			'Gandalf',
			'Aragorn',
			'Legolas',
			'Gimli',
			'Boromir'
		]
		# for name in player_names:
		# 	to.add_player(name, None)

		self.sort_order = 'by_name'

		view.notifier.observers.append(self)

		self.header_label = QLabel('Players')

		self.header_widget = QWidget(self)
		header_layout = QBoxLayout(QBoxLayout.LeftToRight)
		header_layout.addWidget(self.header_label)
		self.header_widget.setLayout(header_layout)

		self.sort_by_name_btn = QPushButton('Sort by Name', self)
		self.sort_by_name_btn.clicked.connect(self.sort_by_name)
		self.sort_by_rank_btn = QPushButton('Sort by Rank', self)
		self.sort_by_rank_btn.clicked.connect(self.sort_by_rank)

		self.sort_btns_widget = QWidget(self)
		sort_btns_layout = QBoxLayout(QBoxLayout.LeftToRight)
		sort_btns_layout.addWidget(self.sort_by_name_btn)
		sort_btns_layout.addSpacing(10)
		sort_btns_layout.addWidget(self.sort_by_rank_btn)
		self.sort_btns_widget.setLayout(sort_btns_layout)

		self.player_list = QTableWidget(style.style_loader.TABLE_INITIAL_LENGTH, 2, self)
		self.player_list.setHorizontalHeaderLabels(['Name', 'Record'])
		self.player_list.setFixedHeight(300)
		self.player_list.setFixedWidth(400)
		self.player_list.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
		self.player_list.verticalHeader().setSectionResizeMode(QHeaderView.Fixed)
		self.player_list.horizontalHeader().setVisible(True)

		self.player_list_widget = QWidget(self)
		player_list_layout = QBoxLayout(QBoxLayout.LeftToRight)
		player_list_layout.addWidget(self.player_list)
		self.player_list_widget.setLayout(player_list_layout)

		self.add_player_btn = QPushButton('Add Player', self)
		self.add_player_btn.clicked.connect(self.parent.show_add_player_widget)
		self.remove_player_btn = QPushButton('Remove Player', self)
		self.remove_player_btn.clicked.connect(self.parent.show_remove_player_widget)

		self.player_btns_widget = QWidget(self)
		player_btn_layout = QBoxLayout(QBoxLayout.LeftToRight)
		player_btn_layout.addWidget(self.add_player_btn)
		player_btn_layout.addSpacing(10)
		player_btn_layout.addWidget(self.remove_player_btn)
		self.player_btns_widget.setLayout(player_btn_layout)

		self.error = None

		layout = QFormLayout()
		layout.addRow(self.header_widget)
		layout.addRow(self.sort_btns_widget)
		layout.addRow(self.player_list_widget)
		layout.addRow(self.player_btns_widget)
		self.setLayout(layout)

		self.update()
コード例 #6
0
class DetectPage(QWidget):

    # 界面绘制
    def __init__(self):
        super().__init__()
        self.setWindowIcon(QIcon('./config/HomePageIcon.png'))  # 设置窗口的图标
        self.set_center()
        self.image = './image/bird.jpg'

        # 第一行
        self.upload_button = QPushButton('上传图片')
        self.detect_button = QPushButton('开始检测')

        h_layout = QHBoxLayout()
        h_layout.setSpacing(15)
        h_layout.addWidget(self.upload_button)
        h_layout.addWidget(self.detect_button)

        self.upload_button.clicked.connect(self.pick_image)  # 绑定事件
        self.detect_button.clicked.connect(self.detect_image)  # 绑定事件

        # 第二行
        self.image_label = QLabel()
        self.image_label.setPixmap(QPixmap(self.image))

        # 第三行
        self.time_line = QLineEdit()
        self.time_line.setEnabled(False)
        self.probability_line = QLineEdit()
        self.probability_line.setEnabled(False)
        self.bird_num = QLineEdit()
        self.bird_num.setEnabled(False)

        form_layout = QFormLayout()
        form_layout.addRow('检测时间:', self.time_line)
        form_layout.addRow('score值:', self.probability_line)
        form_layout.addRow('鸟个数:', self.bird_num)

        # 整体布局
        self.main_layout = QBoxLayout(QBoxLayout.Down)
        self.main_layout.addLayout(h_layout)
        self.main_layout.addSpacing(10)
        self.main_layout.addWidget(self.image_label)
        self.main_layout.addSpacing(10)
        self.main_layout.addLayout(form_layout)
        self.setLayout(self.main_layout)

    # 从本地选择图片
    def pick_image(self):
        image_name, image_type = QFileDialog.getOpenFileName(
            self, "选择图片", "", "*.jpg;;*.png;;")
        self.image = image_name
        self.image_label.setPixmap(QPixmap(self.image))

    # 检测图片,供子类继承
    def detect_image(self):
        pass

    def process_scores(self, scores):
        result = '['
        if len(scores) != 0:
            for score in scores:
                result = result + str('%.3f' % score) + ','
            result = result + ']'
        else:
            result = '没有检测到任何鸟群'
        return result

    # 控制主页显示在屏幕中心
    def set_center(self):
        # 获得窗口
        qr = self.frameGeometry()
        # 获得屏幕中心点
        cp = QDesktopWidget().availableGeometry().center()
        # 显示到屏幕中心
        qr.moveCenter(cp)
        self.move(qr.topLeft())
コード例 #7
0
    def __init__(self, parent):
        super(NewsWindow, self).__init__(parent)
        self.parent = parent
        # top table - news list and filters
        self.table = QTableWidget(0, 5)
        horizLabels = ["", "", "", "", ""]
        self.table.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.table.setSelectionMode(QAbstractItemView.SingleSelection)
        self.table.itemSelectionChanged.connect(self.doDisplayNewsHeadline)
        self.table.setHorizontalHeaderLabels(horizLabels)
        self.table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
        self.table.setWordWrap(True)
        self.table.setEditTriggers(QAbstractItemView.NoEditTriggers)
        topLayout = QGridLayout()
        topLayout.addWidget(self.table, 0, 1)
        filterLayout = QBoxLayout(QBoxLayout.TopToBottom)
        self.filters = [
            QPushButton(parent.graphics.icon[23 + i], "") for i in range(5)
        ]
        filterGroup = QButtonGroup()
        for i, j in zip(self.filters, range(5)):
            i.setFixedSize(120, 32)
            i.setAutoExclusive(True)
            i.setCheckable(True)
            i.released.connect(partial(self.doRefreshNews, j))
            filterGroup.addButton(i)
            filterLayout.addWidget(i)
            filterLayout.addSpacing(-5)
        filterLayout.addSpacing(30)
        filterLayout.setAlignment(Qt.AlignVCenter)
        self.ctryList = QComboBox()
        self.ctryList.setMaxVisibleItems(10)
        self.ctryList.addItems([
            Local.strings[Local.DATA_COUNTRIES + i][Local.CTRY_NAME]
            for i in range(80)
        ])
        self.ctryList.currentIndexChanged.connect(
            partial(self.doRefreshNews, 5))
        self.localNews = QRadioButton()
        self.localNews.released.connect(partial(self.doRefreshNews, 5))
        filterGroup.addButton(self.localNews)
        filterLayout.addWidget(self.localNews)
        filterLayout.addWidget(self.ctryList)
        topLayout.addLayout(filterLayout, 0, 0)
        topLayout.setContentsMargins(-50, 0, 0, 0)
        self.table.setFixedHeight(220)

        # left half - news
        buttons = QBoxLayout(QBoxLayout.LeftToRight)
        leftLayout = QBoxLayout(QBoxLayout.TopToBottom)
        leftLayout.setContentsMargins(-80, 0, 0, 0)
        self.newsHline = QLabel()
        self.newsHline.setWordWrap(True)
        self.newsHline.setFixedHeight(40)
        leftLayout.addSpacing(25)
        leftLayout.addWidget(self.newsHline)
        leftLayout.addSpacing(30)
        self.question = QPushButton()
        self.backDown = QPushButton()
        self.question.released.connect(self.doTough)
        self.backDown.released.connect(self.doLoose)
        for i in (self.question, self.backDown):
            buttons.addWidget(i)
        leftLayout.addLayout(buttons)
        self.reactionLine = QLabel()
        self.reactionLine.setFixedHeight(30)
        self.reactionLine.setWordWrap(True)
        leftLayout.addSpacing(20)
        leftLayout.addWidget(self.reactionLine)
        leftLayout.addSpacing(20)
        leftInfoLayout = [QBoxLayout(QBoxLayout.LeftToRight) for i in range(3)]
        self.leftInfo = [QLabel() for i in range(3)]
        self.leftInfoVal = [QLabel() for i in range(3)]
        for i in range(3):
            leftInfoLayout[i].addWidget(self.leftInfo[i])
            leftInfoLayout[i].addWidget(self.leftInfoVal[i])
            leftLayout.addLayout(leftInfoLayout[i])
            if i < 2: leftLayout.addSpacing(-5)

        # right half - advisory
        rightLayout = QBoxLayout(QBoxLayout.TopToBottom)
        rightLayout.setContentsMargins(0, -50, 0, 0)
        #rightLayout.addWidget(self.advisory)
        headsLayout = QBoxLayout(QBoxLayout.LeftToRight)
        headsColumn = [QBoxLayout(QBoxLayout.TopToBottom) for i in range(2)]
        head = [QBoxLayout(QBoxLayout.LeftToRight) for i in range(4)]
        self.picture = [QLabel() for i in range(4)]
        self.advice = [QLabel() for i in range(4)]
        for i in range(4):
            self.picture[i].setPixmap(parent.graphics.advisor[i])
            self.advice[i].setWordWrap(True)
            self.advice[i].setFixedWidth(100)
            head[i].addWidget(self.picture[i])
            head[i].addWidget(self.advice[i])
            headsColumn[i // 2].addLayout(head[i])
        self.closeUpButton = QPushButton()

        for i in range(2):
            headsLayout.addLayout(headsColumn[i])
        rightLayout.addLayout(headsLayout)

        # save right and left layouts into groups
        self.detailGroup = [QGroupBox() for i in range(3)]
        self.detailGroup[0].setLayout(leftLayout)
        self.detailGroup[1].setLayout(rightLayout)
        self.detailGroup[2].setLayout(topLayout)

        mainLayout = QGridLayout()
        mainLayout.addWidget(self.detailGroup[2], 0, 0, 1, 2)
        for i in range(2):
            mainLayout.addWidget(self.detailGroup[i], 1, i)

        self.setStrings()
        self.setLayout(mainLayout)
        self.setFixedSize(830, 590)
        self.setModal(True)