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


Python QButtonGroup.checkedButton方法代码示例

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


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

示例1: LabelButtonGroup

# 需要导入模块: from PyQt5.QtWidgets import QButtonGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QButtonGroup import checkedButton [as 别名]
class LabelButtonGroup(QWidget):
    def __init__(self, label = '', buttons = {'UJ object reference value': 'Name to show'}):
        super(LabelButtonGroup, self).__init__()
        self.label = QLabel()
        self.label.setText(label)
        self.button_group = QButtonGroup()
        self.buttons = {}
        self.layout = QHBoxLayout()
        self.layout.setContentsMargins(0,0,0,0)
        self.layout.addWidget(self.label)
        for button_key in buttons.keys():
            self.buttons[button_key] = QRadioButton(buttons[button_key])
            self.button_group.addButton(self.buttons[button_key])
            self.layout.addWidget(self.buttons[button_key])

    def show(self):
        for button in self.buttons.values():
            button.show()
        self.label.show()

    def hide(self):
        for button in self.buttons.values():
            button.hide()
        self.label.hide()

    def set_text(self, key):
        if key != '':
            self.buttons[key].setChecked(1)

    def text(self):
        return self.button_group.checkedButton().text()

    def checked(self):
        return self.button_group.checkedButton()
开发者ID:bobev18,项目名称:stujeditor,代码行数:36,代码来源:gui_classes.py

示例2: DyStockSelectAddColumnsDlg

# 需要导入模块: from PyQt5.QtWidgets import QButtonGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QButtonGroup import checkedButton [as 别名]
class DyStockSelectAddColumnsDlg(QDialog):

    def __init__(self, data, title, parent=None):
        super().__init__(parent)

        self._data = data

        self._initUi(title)

    def _initUi(self, title):
        self.setWindowTitle('添加{0}列'.format(title))
 
        # 控件
        increaseColumnsLable = QLabel('基准日期几日{0}'.format(title))
        self._increaseColumnsLineEdit = QLineEdit(','.join(self._data['days']) if self._data else '2,3,4,5,10' )

        # 前 & 后
        forwardRadioButton = QRadioButton('向前')
        backwardRadioButton = QRadioButton('向后'); backwardRadioButton.setChecked(True)

        # 添加到QButtonGroup
        self._wardButtonGroup = QButtonGroup()
        self._wardButtonGroup.addButton(forwardRadioButton, 1); 
        self._wardButtonGroup.addButton(backwardRadioButton, 2)

        cancelPushButton = QPushButton('Cancel')
        okPushButton = QPushButton('OK')
        cancelPushButton.clicked.connect(self._cancel)
        okPushButton.clicked.connect(self._ok)

        # 布局
        grid = QGridLayout()
        grid.setSpacing(10)
 
        grid.addWidget(increaseColumnsLable, 0, 0, 1, 2)
        grid.addWidget(self._increaseColumnsLineEdit, 1, 0, 1, 2)

        grid.addWidget(forwardRadioButton, 2, 0)
        grid.addWidget(backwardRadioButton, 2, 1)

        grid.addWidget(okPushButton, 3, 1)
        grid.addWidget(cancelPushButton, 3, 0)
 
 
        self.setLayout(grid)
        self.setMinimumWidth(QApplication.desktop().size().width()//5)

    def _ok(self):
        checkedButton = self._wardButtonGroup.checkedButton()
        text = checkedButton.text()
        self._data['backward'] = True if text == '向后' else False

        self._data['days'] = [int(x) for x in self._increaseColumnsLineEdit.text().split(',')]

        self.accept()

    def _cancel(self):
        self.reject()
开发者ID:hack1943,项目名称:DevilYuan,代码行数:60,代码来源:DyStockSelectAddColumnsDlg.py

示例3: DyStockTableSelectDlg

# 需要导入模块: from PyQt5.QtWidgets import QButtonGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QButtonGroup import checkedButton [as 别名]
class DyStockTableSelectDlg(QDialog):

    def __init__(self, data, dlgName):
        super().__init__()

        self._data = data

        self._initUi(dlgName)

    def _initUi(self, dlgName):
        self.setWindowTitle(dlgName)
 
        allRadioButton = QRadioButton('所有'); allRadioButton.setChecked(True)
        highlightRadioButton = QRadioButton('高亮')

        # 添加到QButtonGroup
        self._buttonGroup = QButtonGroup()
        self._buttonGroup.addButton(allRadioButton, 1); 
        self._buttonGroup.addButton(highlightRadioButton, 2)

        cancelPushButton = QPushButton('Cancel')
        okPushButton = QPushButton('OK')
        cancelPushButton.clicked.connect(self._cancel)
        okPushButton.clicked.connect(self._ok)

        # 布局
        grid = QGridLayout()
        grid.setSpacing(10)
 
        grid.addWidget(allRadioButton, 1, 0)
        grid.addWidget(highlightRadioButton, 1, 1)

        grid.addWidget(okPushButton, 2, 1)
        grid.addWidget(cancelPushButton, 2, 0)
 
        self.setLayout(grid)
        self.setMinimumWidth(QApplication.desktop().size().width()//5)

    def _ok(self):
        checkedButton = self._buttonGroup.checkedButton()
        text = checkedButton.text()
        self._data['all'] = True if text == '所有' else False

        self.accept()

    def _cancel(self):
        self.reject()
开发者ID:hack1943,项目名称:DevilYuan,代码行数:49,代码来源:DyStockTableSelectDlg.py

示例4: DataCheck

# 需要导入模块: from PyQt5.QtWidgets import QButtonGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QButtonGroup import checkedButton [as 别名]

#.........这里部分代码省略.........
            self.obj_group.addButton(self.lst_obj[-1])
            self.obj_group.setId(self.lst_obj[-1], c)

        htable.setNonScroll()

        self.vbox.addWidget(htable)

        if self.params.lang == 'jp':
            self.txt_cnf = ('<font color="red">目的変数を1つ選択し,'
                    'targetの列にチェックをいれてください。')
            if self.params.task.lower() == 'classification':
                self.txt_cnf += '<br>目的変数はカテゴリ変数である必要があります。</font>'
            else:
                self.txt_cnf += '<br>目的変数は量的変数である必要があります。</font>'
        else:
            self.txt_cnf = ('<font color="red">Select one variable as target variable,'
                            'then set the column of "target" of the variable checked.')
            if self.params.task.lower() == 'classification':
                self.txt_cnf += '<br>Target variable must be a categorical variable.</font>'
            else:
                self.txt_cnf += '<br>Target variable must be a numerical variable.</font>'
        self.lbl_cnf = QLabel(self.txt_cnf, self.inner)

        self.vbox.addWidget(self.lbl_cnf)

        self.vbox.addStretch(1)

        self.btn = QPushButton('Next', self.inner)
        self.btn.setStyleSheet('QPushButton{font: bold; font-size: 15pt; background-color: white;};')
        if self.params.lang == 'en':
            self.btn.clicked.connect(lambda: self.button_func('Overfitting'))
        else:
            self.btn.clicked.connect(lambda: self.button_func('過学習'))
        if self.obj_group.checkedButton() is None:
            self.btn.setEnabled(False)
        else:
            self.btn.setEnabled(True)

        self.vbox.addWidget(self.btn)

    def __make_cell(self, c, name, col_type, col_type_def):
        cell = QWidget(self.inner)
        rbtn = QRadioButton('', cell)
        rbtn.toggled.connect(lambda: self.rbtn_clicked(name + '_' + str(c)))
        hbl = QHBoxLayout(cell)
        hbl.addWidget(rbtn)
        hbl.setContentsMargins(0, 0, 0, 0)
        hbl.setAlignment(Qt.AlignCenter)
        cell.setLayout(hbl)
        if name == 'cat':
            if col_type == 'object':
                rbtn.setChecked(True)
            self.lst_cat.append(rbtn)
        elif name == 'num':
            if col_type != 'object':
                rbtn.setChecked(True)
            if col_type_def == 'object':
                rbtn.setEnabled(False)
            self.lst_num.append(rbtn)
        elif name == 'obj':
            if col_type == 'object' and self.params.task == 'Regression':
                rbtn.setEnabled(False)
            elif col_type != 'object' and self.params.task == 'Classification':
                rbtn.setEnabled(False)
            if self.params.columns[c] == self.params.objective:
                rbtn.setChecked(True)
开发者ID:canard0328,项目名称:malss,代码行数:70,代码来源:data_check.py

示例5: DyStockSelectIndexMaKChartStatsDlg

# 需要导入模块: from PyQt5.QtWidgets import QButtonGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QButtonGroup import checkedButton [as 别名]
class DyStockSelectIndexMaKChartStatsDlg(QDialog):

    def __init__(self, data, parent=None):
        super().__init__(parent)

        self._data = data

        self._initUi()

    def _initUi(self):
        self.setWindowTitle('指数均线K线图统计')
 
        # 控件
        startDateLable = QLabel('开始日期')
        self._startDateLineEdit = QLineEdit(datetime.now().strftime("%Y-%m-%d"))

        endDateLable = QLabel('结束日期')
        self._endDateLineEdit = QLineEdit(datetime.now().strftime("%Y-%m-%d"))

        # 指数和股票代码
        shIndexRadioButton = QRadioButton('上证指数'); shIndexRadioButton.setChecked(True)
        szIndexRadioButton = QRadioButton('深证成指')
        cybIndexRadioButton = QRadioButton('创业板指')
        zxbIndexRadioButton = QRadioButton('中小板指')

        hs300IndexRadioButton = QRadioButton('沪深300')
        zz500IndexRadioButton = QRadioButton('中证500')

        # 添加到QButtonGroup
        self._stocksButtonGroup = QButtonGroup()
        self._stocksButtonGroup.addButton(shIndexRadioButton, 1); 
        self._stocksButtonGroup.addButton(szIndexRadioButton, 2)
        self._stocksButtonGroup.addButton(cybIndexRadioButton, 3)
        self._stocksButtonGroup.addButton(zxbIndexRadioButton, 4)

        self._stocksButtonGroup.addButton(hs300IndexRadioButton, 4)
        self._stocksButtonGroup.addButton(zz500IndexRadioButton, 4)

        cancelPushButton = QPushButton('Cancel')
        okPushButton = QPushButton('OK')
        cancelPushButton.clicked.connect(self._cancel)
        okPushButton.clicked.connect(self._ok)

        # 布局
        grid = QGridLayout()
        grid.setSpacing(10)
 
        grid.addWidget(startDateLable, 0, 0)
        grid.addWidget(self._startDateLineEdit, 1, 0)

        grid.addWidget(endDateLable, 0, 1)
        grid.addWidget(self._endDateLineEdit, 1, 1)

        grid.addWidget(shIndexRadioButton, 2, 0)
        grid.addWidget(szIndexRadioButton, 2, 1)
        grid.addWidget(cybIndexRadioButton, 3, 0)
        grid.addWidget(zxbIndexRadioButton, 3, 1)

        grid.addWidget(hs300IndexRadioButton, 4, 0)
        grid.addWidget(zz500IndexRadioButton, 4, 1)

        grid.addWidget(okPushButton, 5, 1)
        grid.addWidget(cancelPushButton, 5, 0)
 
        self.setLayout(grid)

    def _getStockCode(self):
        checkedButton = self._stocksButtonGroup.checkedButton()
        text = checkedButton.text()

        return DyStockCommon.getIndexSectorByName(text)

    def _ok(self):
        self._data['startDate'] = self._startDateLineEdit.text()
        self._data['endDate'] = self._endDateLineEdit.text()
        self._data['index'] = self._getStockCode()

        self.accept()

    def _cancel(self):
        self.reject()
开发者ID:hack1943,项目名称:DevilYuan,代码行数:83,代码来源:DyStockSelectIndexMaKChartStatsDlg.py

示例6: TARWindow

# 需要导入模块: from PyQt5.QtWidgets import QButtonGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QButtonGroup import checkedButton [as 别名]

#.........这里部分代码省略.........
        self.comprGroup.addButton(self.tarxzRadio)
        # We'll define a compression by default
        self.targzRadio.setChecked(True)
        # If we don't define blankTile right now it will return an error
        self.blankTile = str()
        # Signals
        self.blankButton.clicked.connect(self.setBlank)
        self.saveBox.accepted.connect(self.saveTilemap)
        self.saveBox.rejected.connect(self.cancel)

    def getTiles(self, resource, h, w, tileSize):
        # This cuts the resource and put it on the temporary folder.
        r = 0
        for i in range(0, h, tileSize):
            c = 0
            for j in range(0, w, tileSize):
                box = self.resource[i:i+tileSize, j:j+tileSize]
                nm = str(c) + '-' + str(r) + '.png'
                place = os.path.join(self.tmp_dir, nm)
                cv2.imwrite(place, box)
                c += 1
            r += 1
        return(c,r)

    def hashsum(self, path, hex=True, hash_type=hashlib.md5):
        # All this function was for deleting the repeated tiles. I won't use
        # it.
        hashinst = hash_type()
        blocksize = hashinst.block_size * 128
        with open(path, 'rb') as f:
            for chunk in iter(lambda: f.read(blocksize), b''):
                hashinst.update(chunk)
        return(hashinst.hexdigest() if hex else hashinst.digest())

    def refreshdir(self, c, r, size):
        # This loads the tilemap
        self.resourceView.setColumnCount(c)
        self.resourceView.setRowCount(r)
        for column in range(0, c):
            self.resourceView.setColumnWidth(column, size)
            for row in range(0, r):
                self.resourceView.setRowHeight(row, size)
                filename = str(column) + '-'+ str(row) + '.png'
                filedir = os.path.join(self.tmp_dir, filename)
                icon = QIcon(filedir)
                item = QTableWidgetItem(icon, None)
                self.resourceView.setItem(row, column, item)

    @pyqtSlot()
    def setBlank(self):
        # Set the blank tile. When you load a new map, the tilemap will give a
        # default tile for the blank map.
        r = str(self.resourceView.currentRow())
        c = str(self.resourceView.currentColumn())
        file = c + '-' + r
        pixmap = QPixmap(os.path.join(self.tmp_dir, file + '.png'))
        pixmapitem = QGraphicsPixmapItem(pixmap)
        scene = QGraphicsScene()
        scene.addItem(pixmapitem)
        self.tileView.setScene(scene)
        self.blankTile = file

    def saveTilemap(self):
        # We have to define c and r from self
        # Because PyQt Signals are shitty
        # So I'm using a singals style that can't pass arguments
        c = self.columns
        r = self.rows
        # We'll write the metadata
        fileplace = os.path.join(self.tmp_dir, 'metafile.ini')
        # You may be thinking:
        # "Why did you write this string on such a shitty way?"
        # And the answer is: "NONE OF YOUR FUCKING BUSINESS
        METADATA = (
                    "[META]\n"
                    "COLUMNS = {0}\n"
                    "ROWS = {1}\n"
                    "BLANKTILE = {2}\n"
                    "TILESIZE = {3}\n"
                    ).format(c, r, self.blankTile, self.tileSize)
        with open(fileplace, 'w') as metafile:
            metafile.write(METADATA)
        filters = 'TAR (*.tar, *.tar.gz, *.tar.xz, *.tar.bz2)'
        rawSuffix = self.comprGroup.checkedButton().text()
        suffix = rawSuffix.split(' ')[1][1:-1]
        sufParts = suffix.split('.')
        savefile = QFileDialog().getSaveFileName(filter = filters)
        if len(sufParts) > 2:
            openAs = 'w:{0}'.format(sufParts[-1])
        else:
            openAs = 'w'
        with tarfile.open(savefile[0] + suffix, openAs) as tar:
            for i in os.listdir(self.tmp_dir):
                tar.add(os.path.join(self.tmp_dir, i), arcname = i)
                os.remove(os.path.join(self.tmp_dir, i))
        os.removedirs(self.tmp_dir)
        self.close()

    def cancel(self):
        self.close()
开发者ID:mratmartinez,项目名称:Mapuche,代码行数:104,代码来源:newTm.py

示例7: SettingsDialog

# 需要导入模块: from PyQt5.QtWidgets import QButtonGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QButtonGroup import checkedButton [as 别名]

#.........这里部分代码省略.........
        fileDialog.setOption(QFileDialog.ShowDirsOnly, True)
        fileDialog.setViewMode(QFileDialog.List)
        fileDialog.setDirectory(os.environ["HOME"])
        if fileDialog.exec():
            selected = fileDialog.selectedFiles()[0]
            if selected in self.newMounts:
                return
            row = self.table_mounts.rowCount()
            self.table_mounts.insertRow(row)
            self.table_mounts.setItem(
                row, 0,
                QTableWidgetItem(app.adapterManager[0].mountsFaker.driveIndexToLetter(row) +
                                 "\\TDDOWNLOAD"))
            self.table_mounts.setItem(row, 1, QTableWidgetItem(selected))
            self.table_mounts.setItem(row, 2, QTableWidgetItem("新近添加"))

    @pyqtSlot()
    def slotRemoveMount(self):
        row = self.table_mounts.currentRow()
        self.table_mounts.removeRow(row)

    @pyqtSlot()
    def accept(self):
        app.settings.set("adapter-legacy", "username", self.lineEdit_loginUsername.text())
        app.settings.set("adapter-legacy", "password", self.lineEdit_loginPassword.text())
        app.settings.setbool("legacy", "autologin", self.checkBox_autoLogin.isChecked())

        app.autoStart = self.checkBox_autoStartFrontend.isChecked()

        app.adapterManager[0].daemonManagedBySystemd = self.radio_managedBySystemd.isChecked()
        app.adapterManager[0].daemonManagedByUpstart = self.radio_managedByUpstart.isChecked()
        app.adapterManager[0].daemonManagedByAutostart = self.radio_managedByAutostart.isChecked()

        app.settings.setbool("legacy", "enabledeveloperstools",
                             self.checkBox_enableDevelopersTools.isChecked())
        app.settings.setbool("legacy", "allowflash",
                             self.checkBox_allowFlash.isChecked())
        app.settings.setbool("frontend", "minimizetosystray",
                             self.checkBox_minimizeToSystray.isChecked())

        # A possible Qt bug
        # https://bugreports.qt-project.org/browse/QTBUG-37695
        app.settings.setbool("frontend", "closetominimize",
                             self.checkBox_closeToMinimize.isChecked())
        app.settings.setbool("frontend", "popnotifications",
                             self.checkBox_popNotifications.isChecked())
        app.settings.setbool("frontend", "notifybysound",
                             self.checkBox_notifyBySound.isChecked())

        app.settings.setbool("frontend", "showmonitorwindow",
                             self.checkBox_showMonitorWindow.isChecked())
        app.settings.setint("frontend", "monitorfullspeed",
                            self.spinBox_monitorFullSpeed.value())
        app.settings.setbool("frontend", "watchclipboard",
                             self.checkBox_watchClipboard.isChecked())
        app.settings.set("frontend", "watchpattern",
                         self.plaintext_watchPattern.toPlainText())

        if self.group_etmStartWhen.isEnabled():
            startEtmWhen = self.btngrp_etmStartWhen.id(self.btngrp_etmStartWhen.checkedButton())
            app.adapterManager[0].startEtmWhen = startEtmWhen

        app.settings.save()

        if self.tab_mount.isEnabled():
            app.adapterManager[0].mountsFaker.mounts = self.newMounts
        app.applySettings.emit()
        super().accept()

    @property
    def newMounts(self):
        return list(map(lambda row: self.table_mounts.item(row, 1).text(),
                        range(self.table_mounts.rowCount())))

    @pyqtSlot()
    def setupETM(self):
        # fill values
        adapter = app.adapterManager[0]
        settings = adapter.backendSettings
        etmRunning = adapter.etmPid != 0
        if etmRunning and settings.initialized:
            self.spinBox_dSpeedLimit.setValue(settings.downloadSpeedLimit)
            self.spinBox_uSpeedLimit.setValue(settings.uploadSpeedLimit)
            self.spinBox_maxRunningTasksNum.setValue(settings.maxRunTaskNumber)

            # connect signals
            self.accepted.connect(self.saveETM)
        else:
            self.spinBox_dSpeedLimit.setEnabled(False)
            self.spinBox_uSpeedLimit.setEnabled(False)
            self.spinBox_maxRunningTasksNum.setEnabled(False)

    @pyqtSlot()
    def saveETM(self):
        adapter = app.adapterManager[0]
        adapter.do_applySettings({
            "downloadSpeedLimit": self.spinBox_dSpeedLimit.value(),
            "uploadSpeedLimit": self.spinBox_uSpeedLimit.value(),
            "maxRunTaskNumber": self.spinBox_maxRunningTasksNum.value(),
        })
开发者ID:CludeX,项目名称:XwareDesktop,代码行数:104,代码来源:settings.py

示例8: TypeOfTask

# 需要导入模块: from PyQt5.QtWidgets import QButtonGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QButtonGroup import checkedButton [as 别名]
class TypeOfTask(Content):

    def __init__(self, parent=None, button_func=None, params=None):
        super().__init__(parent, 'Task', params)

        self.button_func = button_func

        path = os.path.abspath(os.path.dirname(__file__)) + '/static/'

        # Text for machine learning tasks
        path1 = path + 'task'
        text = self.get_text(path1)
        if self.params.lang == 'en':
            self.set_paragraph('Type of task', text=text, img=path1)
        else:
            self.set_paragraph('分析タスク', text=text, img=path1)

        # Text for supervised learning
        path2 = path + 'supervised_learning'
        text = self.get_text(path2)
        if self.params.lang == 'en':
            self.set_paragraph('Supervised learning', text=text, img=path2)
        else:
            self.set_paragraph('教師あり学習', text=text, img=path2)

        if params.lang == 'jp':
            self.set_paragraph(
                'タスクの選択',
                text='あなたの機械学習のタスクを選択してください。')
        else:
            self.set_paragraph(
                'Task selection',
                text='Choose your machine learning task.')

        vbox1 = QVBoxLayout()
        vbox1.setContentsMargins(10, 10, 10, 10)
        vbox1.setSpacing(10)

        rbtn_cls = QRadioButton('Classification', self.inner)
        rbtn_cls.setStyleSheet('QRadioButton{font: 15pt;};')
        rbtn_cls.clicked.connect(self.rbtn_clicked)
        rbtn_reg = QRadioButton('Regression', self.inner)
        rbtn_reg.setStyleSheet('QRadioButton{font: 15pt;};')
        rbtn_reg.clicked.connect(self.rbtn_clicked)
        if params.task == 'Classification':
            rbtn_cls.setChecked(True)
        elif params.task == 'Regression':
            rbtn_reg.setChecked(True)

        self.btn_group = QButtonGroup()
        self.btn_group.addButton(rbtn_cls, 1)
        self.btn_group.addButton(rbtn_reg, 1)

        vbox1.addWidget(rbtn_cls)
        vbox1.addWidget(rbtn_reg)
        vbox1.addStretch(1)

        self.vbox.addLayout(vbox1)

        self.vbox.addStretch(1)

        self.btn = QPushButton('Next', self.inner)
        self.btn.setStyleSheet('QPushButton{font: bold; font-size: 15pt; background-color: white;};')
        if self.params.lang == 'en':
            self.btn.clicked.connect(lambda: self.button_func('Input data'))
        else:
            self.btn.clicked.connect(lambda: self.button_func('入力データ'))
        if params.task is None:
            self.btn.setEnabled(False)

        self.vbox.addWidget(self.btn)

    def rbtn_clicked(self):
        self.params.task = self.btn_group.checkedButton().text()
        self.btn.setEnabled(True)
开发者ID:canard0328,项目名称:malss,代码行数:77,代码来源:type_of_task.py

示例9: App

# 需要导入模块: from PyQt5.QtWidgets import QButtonGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QButtonGroup import checkedButton [as 别名]

#.........这里部分代码省略.........
        self.get_update_button.setText(_translate('App', 'Go to download page'))
        self.checkbox_get_updates.setText(_translate('App', 'Check for plugin updates'))
        self.docx_label.setText(_translate('App', 'DOCX File to import'))
        self.checkbox_smap.setText(_translate('App', 'Use Custom Style Map'))
        self.checkbox_css.setText(_translate('App', 'Use Custom CSS'))
        self.checkbox_debug.setText(_translate('App', 'Debug Mode (change takes effect next plugin run)'))

    def fileChooser(self, ftype, qlineedit, qcheck=None, qbutton=None):
        _translate = QCoreApplication.translate
        options =  QFileDialog.Options()
        options |= QFileDialog.DontUseNativeDialog
        title = self.FTYPE_MAP[ftype]['title']
        startfolder = self.prefs['lastDir'][ftype]
        ffilter = self.FTYPE_MAP[ftype]['filetypes']
        inpath, _ = QFileDialog.getOpenFileName(self, _translate('APP', title), startfolder, ffilter, options=options)
        if len(inpath):
            qlineedit.setEnabled(True)
            qlineedit.setText(os.path.normpath(inpath))
            self.prefs['lastDir'][ftype] = os.path.dirname(inpath)
            qlineedit.setEnabled(False)
        else:
            if qcheck is not None:
                qcheck.setChecked(False)
            if qbutton is not None:
                qbutton.setEnabled(False)

    def chkBoxActions(self, chk, btn):
        btn.setEnabled(chk.isChecked())

    def cmdDo(self):
        global _DETAILS
        self.prefs['qt_geometry'] = binascii.b2a_base64(self.saveGeometry()).decode('ascii')
        self.prefs['check_for_updates'] = self.checkbox_get_updates.isChecked()
        self.prefs['epub_version'] = self.epubType.checkedButton().text()[-1] + '.0'
        self.prefs['debug'] = self.checkbox_debug.isChecked()
        _DETAILS['vers'] = self.epubType.checkedButton().text()[-1] + '.0'
        self.prefs['useSmap'] = self.checkbox_smap.isChecked()
        if self.checkbox_smap.isChecked():
            if len(self.cust_smap_path.text()):
                self.prefs['useSmapPath'] = self.cust_smap_path.text()
                _DETAILS['smap'] = (self.checkbox_smap.isChecked(), self.cust_smap_path.text())
            else:
                # Message box that no file is selected
                return
        self.prefs['useCss'] = self.checkbox_css.isChecked()
        if self.checkbox_css.isChecked():
            if len(self.cust_css_path.text()):
                self.prefs['useCssPath'] = self.cust_css_path.text()
                _DETAILS['css'] = (self.checkbox_css.isChecked(), self.cust_css_path.text())
            else:
                # Message box that no file is selected
                return
        if len(self.docx_path.text()):
            self.prefs['lastDocxPath'] = self.docx_path.text()
            _DETAILS['docx'] = self.docx_path.text()
        else:
            # Message box that no file is selected
            return

    def check_for_update(self):
        '''Use updatecheck.py to check for newer versions of the plugin'''
        chk = UpdateChecker(self.prefs['last_time_checked'], self.bk._w)
        update_available, online_version, time = chk.update_info()
        # update preferences with latest date/time/version
        self.prefs['last_time_checked'] = time
        if online_version is not None:
开发者ID:dougmassay,项目名称:docximport-sigil-plugin,代码行数:70,代码来源:qtdialogs.py

示例10: MainWindow

# 需要导入模块: from PyQt5.QtWidgets import QButtonGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QButtonGroup import checkedButton [as 别名]

#.........这里部分代码省略.........
            self.buttongroup_results[radiobutton] = arguments.radiolist[i]
            if arguments.radiolist[i+2].lower() == "true":
                radiobutton.setChecked(True)
            self.scrollLayout.addWidget(radiobutton)
            self.buttonGroup.addButton(radiobutton)
            i += 3


    def set_button_labels(self):
        """Set the button labels"""
        global arguments
        if arguments.yeslabel and self.active_buttons["yes_button"]:
            self.buttons["yes_button"].setText(arguments.yeslabel)
        if arguments.nolabel and self.active_buttons["no_button"]:
            self.buttons["no_button"].setText(arguments.nolabel)
        if arguments.cancellabel and self.active_buttons["cancel_button"]:
            self.buttons["cancel_button"].setText(arguments.cancellabel)
        if arguments.continuelabel and self.active_buttons["continue_button"]:
            self.buttons["continue_button"].setText(arguments.continuelabel)


    def create_buttons(self):
        global arguments
        self.buttons = {}
        
        i = 0
        for button_id in self.button_ids:
            if self.active_buttons[button_id]:
                self.buttons[button_id] = QPushButton(self.button_names[button_id])
                self.horizontalLayout.addWidget(self.buttons[button_id])
                if button_id == "details_button":
                    self.buttons["details_button"].clicked.connect(self.details_button_clicked)
                elif button_id == "cancel_button":
                    self.buttons[button_id].clicked.connect(self.reject)
                else:
                    self.button_values[button_id] = i
                    exec("self.buttons[button_id].clicked.connect(self."+button_id+"_clicked)")
                    i += 1
    
    
    def print_checkboxes(self):
        for e in self.checkboxes:
            if e["box"].isChecked():
                print("%r " % e["result"], end="")
                
    def get_checked_radiobutton(self):
        radiobutton_name = self.buttonGroup.checkedButton()
        print("%r" % self.buttongroup_results[radiobutton_name])
    

    def ok_button_clicked(self):
        if arguments.slider:
            print(self.horizontalSlider.value())
        elif arguments.inputbox or arguments.password:
            print(self.lineEdit.text())
        elif arguments.checklist:
            self.print_checkboxes()
        elif arguments.radiolist:
            self.get_checked_radiobutton()
        print(return_keyword+str(self.button_values["ok_button"])+">")
        self.done(0)
    
    def yes_button_clicked(self):
        print(return_keyword+str(self.button_values["yes_button"])+">")
        self.done(0)
    
    def no_button_clicked(self):
        print(return_keyword+str(self.button_values["no_button"])+">")
        self.done(0)
    
    def continue_button_clicked(self):
        print(return_keyword+str(self.button_values["continue_button"])+">")
        self.done(0)

    def save_button_clicked(self):
        print(return_keyword+str(self.button_values["save_button"])+">")
        self.done(0)
    
    def reject(self):
        print(return_keyword+str(self.reject_value)+">")
        self.done(0)

    def enable_buttons (self, button_list):
        for button in button_list:
            self.active_buttons[button] = True
            
    def details_button_clicked (self):
        self.label.setText(self.label.text() + '\n\n' + self.details)
        self.buttons["details_button"].setDisabled(True)

    def progressbar_cancel_clicked(self):
        self.progressbar_cancelled = True

    def showCancelButton(self):
        if not "cancel_button" in self.buttons:
            self.buttons["cancel_button"] = QPushButton(self.button_names["cancel_button"])
            self.buttons["cancel_button"].clicked.connect(self.progressbar_cancel_clicked)
            self.horizontalLayout.addWidget(self.buttons["cancel_button"])
            self.progressbar_cancelled = False
        self.buttons["cancel_button"].show()
开发者ID:thevladsoft,项目名称:playground,代码行数:104,代码来源:pydialog.py

示例11: SettingsDialog

# 需要导入模块: from PyQt5.QtWidgets import QButtonGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QButtonGroup import checkedButton [as 别名]

#.........这里部分代码省略.........
                return
            row = self.table_mounts.rowCount()
            self.table_mounts.insertRow(row)
            self.table_mounts.setItem(row, 0, QTableWidgetItem(selected))
            self.table_mounts.setItem(row, 1, QTableWidgetItem("新近添加"))
            self.table_mounts.setItem(row, 2, QTableWidgetItem("新近添加"))

    @pyqtSlot()
    def slotRemoveMount(self):
        row = self.table_mounts.currentRow()
        self.table_mounts.removeRow(row)

    @pyqtSlot()
    def accept(self):
        app.settings.set("account", "username", self.lineEdit_loginUsername.text())
        app.settings.set("account", "password", self.lineEdit_loginPassword.text())
        app.settings.setbool("account", "autologin", self.checkBox_autoLogin.isChecked())
        doesAutoStartFileExists = self.doesAutoStartFileExists()
        if self.checkBox_autoStartFrontend.isChecked() and not doesAutoStartFileExists:
            # mkdir if autostart dir doesn't exist
            try:
                os.mkdir(os.path.dirname(constants.FRONTEND_AUTOSTART_FILE))
            except OSError:
                pass  # already exists
            os.symlink(constants.DESKTOP_FILE_LOCATION,
                       constants.FRONTEND_AUTOSTART_FILE)
        elif (not self.checkBox_autoStartFrontend.isChecked()) and doesAutoStartFileExists:
            os.remove(constants.FRONTEND_AUTOSTART_FILE)

        app.settings.setbool("frontend", "enabledeveloperstools",
                             self.checkBox_enableDevelopersTools.isChecked())
        app.settings.setbool("frontend", "allowflash",
                             self.checkBox_allowFlash.isChecked())
        app.settings.setbool("frontend", "minimizetosystray",
                             self.checkBox_minimizeToSystray.isChecked())

        # A possible Qt bug
        # https://bugreports.qt-project.org/browse/QTBUG-37695
        app.settings.setbool("frontend", "closetominimize",
                             self.checkBox_closeToMinimize.isChecked())
        app.settings.setbool("frontend", "popnotifications",
                             self.checkBox_popNotifications.isChecked())
        app.settings.setbool("frontend", "notifybysound",
                             self.checkBox_notifyBySound.isChecked())

        app.settings.setbool("frontend", "showmonitorwindow",
                             self.checkBox_showMonitorWindow.isChecked())
        app.settings.setint("frontend", "monitorfullspeed",
                            self.spinBox_monitorFullSpeed.value())
        app.settings.setbool("frontend", "watchclipboard",
                             self.checkBox_watchClipboard.isChecked())
        # app.settings.set("frontend", "watchpattern",
        #                         self.plaintext_watchPattern.toPlainText())

        if self.group_etmStartWhen.isEnabled():
            startEtmWhen = self.btngrp_etmStartWhen.id(self.btngrp_etmStartWhen.checkedButton())
            try:
                callXwaredInterface("setStartEtmWhen", startEtmWhen)
            except SocketDoesntExist:
                QMessageBox.warning(None, "Xware Desktop",
                                    "选项未能成功设置:{}。".format(self.group_etmStartWhen.title()),
                                    QMessageBox.Ok, QMessageBox.Ok)

        app.settings.save()

        app.mountsFaker.mounts = self.newMounts
        app.settings.applySettings.emit()
        super().accept()

    @property
    def newMounts(self):
        return list(map(lambda row: self.table_mounts.item(row, 0).text(),
                        range(self.table_mounts.rowCount())))

    @pyqtSlot()
    def setupETM(self):
        # fill values
        lcPort = app.xwaredpy.lcPort
        self.lineEdit_lcport.setText(str(lcPort) if lcPort else "不可用")

        etmSettings = app.etmpy.getSettings()
        if etmSettings:
            self.spinBox_dSpeedLimit.setValue(etmSettings.dLimit)
            self.spinBox_uSpeedLimit.setValue(etmSettings.uLimit)
            self.spinBox_maxRunningTasksNum.setValue(etmSettings.maxRunningTasksNum)

            # connect signals
            self.accepted.connect(self.saveETM)
        else:
            self.spinBox_dSpeedLimit.setEnabled(False)
            self.spinBox_uSpeedLimit.setEnabled(False)
            self.spinBox_maxRunningTasksNum.setEnabled(False)

    @pyqtSlot()
    def saveETM(self):
        newsettings = EtmSetting(dLimit = self.spinBox_dSpeedLimit.value(),
                                 uLimit = self.spinBox_uSpeedLimit.value(),
                                 maxRunningTasksNum = self.spinBox_maxRunningTasksNum.value())

        app.etmpy.saveSettings(newsettings)
开发者ID:bugmoto,项目名称:XwareDesktop,代码行数:104,代码来源:dialog.py

示例12: SettingsDialog

# 需要导入模块: from PyQt5.QtWidgets import QButtonGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QButtonGroup import checkedButton [as 别名]

#.........这里部分代码省略.........
        import os
        from PyQt5.QtWidgets import QFileDialog
        from PyQt5.Qt import Qt

        fileDialog = QFileDialog(self, Qt.Dialog)
        fileDialog.setFileMode(QFileDialog.Directory)
        fileDialog.setOption(QFileDialog.ShowDirsOnly, True)
        fileDialog.setViewMode(QFileDialog.List)
        fileDialog.setDirectory(os.environ["HOME"])
        if (fileDialog.exec()):
            selected = fileDialog.selectedFiles()[0]
            if selected in self.newMounts:
                return
            row = self.table_mounts.rowCount()
            self.table_mounts.insertRow(row)
            self.table_mounts.setItem(row, 0, QTableWidgetItem(selected))
            self.table_mounts.setItem(row, 1, QTableWidgetItem("新近添加"))
            self.table_mounts.setItem(row, 2, QTableWidgetItem("新近添加"))

    @pyqtSlot()
    def slotRemoveMount(self):
        row = self.table_mounts.currentRow()
        self.table_mounts.removeRow(row)

    @pyqtSlot()
    def writeSettings(self):
        self.settings.set("account", "username", self.lineEdit_loginUsername.text())
        self.settings.set("account", "password", self.lineEdit_loginPassword.text())
        self.settings.setbool("account", "autologin", self.checkBox_autoLogin.isChecked())

        self.settings.setbool("frontend", "enabledeveloperstools",
                                self.checkBox_enableDevelopersTools.isChecked())
        self.settings.setbool("frontend", "allowflash",
                                self.checkBox_allowFlash.isChecked())
        self.settings.setbool("frontend", "minimizetosystray",
                                self.checkBox_minimizeToSystray.isChecked())

        # A possible Qt bug
        # https://bugreports.qt-project.org/browse/QTBUG-37695
        self.settings.setbool("frontend", "closetominimize",
                                self.checkBox_closeToMinimize.isChecked())
        self.settings.setbool("frontend", "popnotifications",
                                self.checkBox_popNotifications.isChecked())
        self.settings.setbool("frontend", "notifybysound",
                                self.checkBox_notifyBySound.isChecked())

        self.settings.setbool("frontend", "showmonitorwindow",
                                self.checkBox_showMonitorWindow.isChecked())
        self.settings.setint("frontend", "monitorfullspeed",
                                self.spinBox_monitorFullSpeed.value())
        self.settings.setbool("frontend", "watchclipboard",
                                self.checkBox_watchClipboard.isChecked())
        # self.settings.set("frontend", "watchpattern",
        #                         self.plaintext_watchPattern.toPlainText())
        self.settings.setint("xwared", "startetmwhen",
                          self.btngrp_etmStartWhen.id(self.btngrp_etmStartWhen.checkedButton()))

        startETMWhen = self.settings.getint("xwared", "startetmwhen")
        if startETMWhen == 1:
            self.settings.setbool("xwared", "startetm", True)

        self.settings.save()

        self.mainWin.mountsFaker.setMounts(self.newMounts)
        self.settings.applySettings.emit()

    @property
    def newMounts(self):
        return list(map(lambda row: self.table_mounts.item(row, 0).text(),
                        range(self.table_mounts.rowCount())))

    @pyqtSlot()
    def setupETM(self):
        etmpy = self.mainWin.etmpy

        # fill values
        self.lineEdit_lcport.setText(etmpy.cfg.get("local_control.listen_port", "不可用"))

        etmSettings = etmpy.getSettings()
        if etmSettings:
            self.spinBox_dSpeedLimit.setValue(etmSettings.dLimit)
            self.spinBox_uSpeedLimit.setValue(etmSettings.uLimit)
            self.spinBox_maxRunningTasksNum.setValue(etmSettings.maxRunningTasksNum)

            # connect signals
            self.accepted.connect(self.saveETM)
        else:
            self.spinBox_dSpeedLimit.setEnabled(False)
            self.spinBox_uSpeedLimit.setEnabled(False)
            self.spinBox_maxRunningTasksNum.setEnabled(False)

    @pyqtSlot()
    def saveETM(self):
        import etmpy

        newsettings = etmpy.EtmSetting(dLimit = self.spinBox_dSpeedLimit.value(),
                                       uLimit = self.spinBox_uSpeedLimit.value(),
                                       maxRunningTasksNum = self.spinBox_maxRunningTasksNum.value())

        self.mainWin.etmpy.saveSettings(newsettings)
开发者ID:mimers,项目名称:XwareDesktop,代码行数:104,代码来源:settings.py

示例13: FileDialogWizardDialog

# 需要导入模块: from PyQt5.QtWidgets import QButtonGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QButtonGroup import checkedButton [as 别名]

#.........这里部分代码省略.........
        self.lInitialFilter.setEnabled(enable)
        self.eInitialFilter.setEnabled(enable)
        self.cInitialFilter.setEnabled(enable)
        
        self.lFilterVariable.setEnabled(enable)
        self.eFilterVariable.setEnabled(enable)
    
    def getCode(self, indLevel, indString):
        """
        Public method to get the source code for Qt4 and Qt5.
        
        @param indLevel indentation level (int)
        @param indString string used for indentation (space or tab) (string)
        @return generated code (string)
        """
        # calculate our indentation level and the indentation string
        il = indLevel + 1
        istring = il * indString
        estring = os.linesep + indLevel * indString
        
        # now generate the code
        if self.parentSelf.isChecked():
            parent = "self"
        elif self.parentNone.isChecked():
            parent = "None"
        elif self.parentOther.isChecked():
            parent = self.parentEdit.text()
            if parent == "":
                parent = "None"
        
        # prepare the result variables
        nameVariable = self.eNameVariable.text()
        if not nameVariable:
            if self.__typeButtonsGroup.checkedButton() in [
                    self.rOpenFile, self.rfOpenFile,
                    self.rSaveFile, self.rfSaveFile]:
                nameVariable = "fileName"
            elif self.__typeButtonsGroup.checkedButton() in [
                    self.rOpenFiles, self.rfOpenFiles]:
                nameVariable = "fileNames"
            elif self.__typeButtonsGroup.checkedButton() == self.rDirectory:
                nameVariable = "dirName"
            else:
                nameVariable = "res"
        filterVariable = self.eFilterVariable.text()
        if not filterVariable:
            if (self.__pyqtVariant == 4 and
                self.__typeButtonsGroup.checkedButton() in [
                    self.rfOpenFile, self.rfOpenFiles, self.rfSaveFile]) or \
                    (self.__pyqtVariant == 5 and
                        self.__typeButtonsGroup.checkedButton() in [
                            self.rOpenFile, self.rOpenFiles, self.rSaveFile]):
                filterVariable = ", selectedFilter"
            else:
                filterVariable = ""
        
        code = '{0}{1} = QFileDialog.'.format(nameVariable, filterVariable)
        if self.rOpenFile.isChecked() or self.rfOpenFile.isChecked():
            if self.rOpenFile.isChecked():
                code += 'getOpenFileName({0}{1}'.format(os.linesep, istring)
            else:
                code += 'getOpenFileNameAndFilter({0}{1}'.format(
                    os.linesep, istring)
            code += '{0},{1}{2}'.format(parent, os.linesep, istring)
            if not self.eCaption.text():
                code += '"",{0}{1}'.format(os.linesep, istring)
开发者ID:Darriall,项目名称:eric,代码行数:70,代码来源:FileDialogWizardDialog.py

示例14: DyStockSelectBBandsStatsDlg

# 需要导入模块: from PyQt5.QtWidgets import QButtonGroup [as 别名]
# 或者: from PyQt5.QtWidgets.QButtonGroup import checkedButton [as 别名]
class DyStockSelectBBandsStatsDlg(QDialog):

    def __init__(self, data, parent=None):
        super(DyStockSelectBBandsStatsDlg, self).__init__(parent)

        self._data = data

        self._initUi()

        self._stocksButtonGroup.buttonClicked.connect(self._radioButtonClicked)

    def _initUi(self):
        self.setWindowTitle('股票代码')
 
        # 控件
        startDateLable = QLabel('开始日期')
        self._startDateLineEdit = QLineEdit(datetime.now().strftime("%Y-%m-%d"))

        endDateLable = QLabel('结束日期')
        self._endDateLineEdit = QLineEdit(datetime.now().strftime("%Y-%m-%d"))

        # 指数和股票代码
        shIndexRadioButton = QRadioButton('上证指数'); shIndexRadioButton.setChecked(True)
        szIndexRadioButton = QRadioButton('深证成指')
        cybIndexRadioButton = QRadioButton('创业板指')
        zxbIndexRadioButton = QRadioButton('中小板指')

        stockRadioButton = QRadioButton('股票代码')
        self._stockLineEdit = QLineEdit(); self._stockLineEdit.setEnabled(False)

        # 添加到QButtonGroup
        self._stocksButtonGroup = QButtonGroup()
        self._stocksButtonGroup.addButton(shIndexRadioButton, 1); 
        self._stocksButtonGroup.addButton(szIndexRadioButton, 2)
        self._stocksButtonGroup.addButton(cybIndexRadioButton, 3)
        self._stocksButtonGroup.addButton(zxbIndexRadioButton, 4)
        self._stocksButtonGroup.addButton(stockRadioButton, 5)

        # 布林周期
        bBands1PeriodLabel = QLabel('布林1周期')
        self._bBands1PeriodLineEdit = QLineEdit('10')
        bBands2PeriodLabel = QLabel('布林2周期')
        self._bBands2PeriodLineEdit = QLineEdit('20')

        cancelPushButton = QPushButton('Cancel')
        okPushButton = QPushButton('OK')
        cancelPushButton.clicked.connect(self._cancel)
        okPushButton.clicked.connect(self._ok)

        # 布局
        grid = QGridLayout()
        grid.setSpacing(10)
 
        grid.addWidget(startDateLable, 0, 0)
        grid.addWidget(self._startDateLineEdit, 1, 0)

        grid.addWidget(endDateLable, 0, 1)
        grid.addWidget(self._endDateLineEdit, 1, 1)

        grid.addWidget(shIndexRadioButton, 2, 0)
        grid.addWidget(szIndexRadioButton, 2, 1)
        grid.addWidget(cybIndexRadioButton, 3, 0)
        grid.addWidget(zxbIndexRadioButton, 3, 1)
        grid.addWidget(stockRadioButton, 4, 0)
        grid.addWidget(self._stockLineEdit, 4, 1)

        grid.addWidget(bBands1PeriodLabel, 5, 0)
        grid.addWidget(self._bBands1PeriodLineEdit, 5, 1)
        grid.addWidget(bBands2PeriodLabel, 6, 0)
        grid.addWidget(self._bBands2PeriodLineEdit, 6, 1)

        grid.addWidget(okPushButton, 7, 1)
        grid.addWidget(cancelPushButton, 7, 0)
 
 
        self.setLayout(grid)

    def _radioButtonClicked(self, button):
        if button.text() == '股票代码':
            self._stockLineEdit.setEnabled(True)
        else:
            self._stockLineEdit.setEnabled(False)

    def _getStockCode(self):
        checkedButton = self._stocksButtonGroup.checkedButton()
        text = checkedButton.text()

        if text == '股票代码':
            return DyStockCommon.getDyStockCode(self._stockLineEdit.text())

        return DyStockCommon.getIndexByName(text)

    def _ok(self):
        self._data['startDate'] = self._startDateLineEdit.text()
        self._data['endDate'] = self._endDateLineEdit.text()
        self._data['code'] = self._getStockCode()
        self._data['bBands1Period'] = int(self._bBands1PeriodLineEdit.text())
        self._data['bBands2Period'] = int(self._bBands2PeriodLineEdit.text())

        self.accept()
#.........这里部分代码省略.........
开发者ID:hack1943,项目名称:DevilYuan,代码行数:103,代码来源:DyStockSelectBBandsStatsDlg.py


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