Python PyQt5.QtWidgets 模块,QCheckBox() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用PyQt5.QtWidgets.QCheckBox()

项目:scm-workbench    作者:barry-scott    | 项目源码 | 文件源码
def __init__( self, app, parent ):
        self.app = app

        super().__init__( parent )

        self.setWindowTitle( T_('Lock files') )

        self.details = QtWidgets.QPlainTextEdit( '' )
        self.message = QtWidgets.QPlainTextEdit( '' )

        self.force = QtWidgets.QCheckBox( T_('force files to be locked') )
        self.force.setCheckState( QtCore.Qt.Unchecked )

        em = self.fontMetrics().width( 'M' )

        self.addNamedDivider( 'Files to Lock' )
        self.addRow( None, self.details, min_width=60*em )
        self.addNamedDivider( 'Lock Message' )
        self.addRow( None, self.message )
        self.addRow( T_('Force'), self.force )
        self.addButtons()
项目:pytc-gui    作者:harmslab    | 项目源码 | 文件源码
def _layout(self):
        """
        Create layout.
        """

        self._main_layout = QW.QHBoxLayout(self)

        if self._input_type is bool:
            self._select_widget = QW.QCheckBox()
            self._select_widget.stateChanged.connect(self._bool_handler)
            self._select_widget.setChecked(self._initial_value)
        elif self._input_type is str:
            self._select_widget = QW.QLineEdit()
            self._select_widget.editingFinished.connect(self._str_handler)
            self._select_widget.setText(self._initial_value)
        elif self._input_type is int:
            self._select_widget = QW.QLineEdit()
            self._select_widget.editingFinished.connect(self._int_handler)
            self._select_widget.setText(str(self._initial_value))
        else:
            self._select_widget = QW.QLineEdit()
            self._select_widget.editingFinished.connect(self._general_handler)
            self._select_widget.setText(str(self._initial_value))

        self._main_layout.addWidget(self._select_widget)
项目:scm-workbench    作者:barry-scott    | 项目源码 | 文件源码
def __init__( self, app, parent, folder_name ):
        self.app = app

        super().__init__( parent )

        self.setWindowTitle( T_('Add Folder') )

        self.depth = WbSvnDepthWidget( include_empty=True, default=pysvn.depth.empty )

        self.force = QtWidgets.QCheckBox( T_('force files to be added') )
        self.force.setCheckState( QtCore.Qt.Unchecked )

        self.addRow( T_('Folder'), folder_name )
        self.addRow( T_('Depth'), self.depth )
        self.addRow( T_('Force'), self.force )
        self.addButtons()
项目:scm-workbench    作者:barry-scott    | 项目源码 | 文件源码
def __init__( self, app, parent ):
        self.app = app

        super().__init__( parent )

        self.setWindowTitle( T_('UnLock files') )

        self.details = QtWidgets.QPlainTextEdit( '' )
        self.force = QtWidgets.QCheckBox( T_('force files to be unlocked') )
        self.force.setCheckState( QtCore.Qt.Unchecked )

        em = self.fontMetrics().width( 'M' )

        self.addNamedDivider( 'Files to Unlock' )
        self.addRow( None, self.details, min_width=60*em )
        self.addRow( T_('Force'), self.force )
        self.addButtons()
项目:scm-workbench    作者:barry-scott    | 项目源码 | 文件源码
def __init__( self, parent, trust_info ):
        super().__init__( parent )

        self.setWindowTitle( T_('SVN SSL Server Trust') )

        self.realm = QtWidgets.QLabel( trust_info['realm'] )
        self.save_trust = QtWidgets.QCheckBox()
        self.save_trust.setCheckState( QtCore.Qt.Unchecked )

        em = self.fontMetrics().width( 'M' )

        self.addRow( T_('Hostname'), trust_info['hostname'], min_width=50*em )
        self.addRow( T_('Finger Print'), trust_info['finger_print'] )
        self.addRow( T_('Valid From'), trust_info['valid_from'] )
        self.addRow( T_('Valid Until'), trust_info['valid_until'] )
        self.addRow( T_('Issuer Dname'), trust_info['issuer_dname'] )
        self.addRow( T_('Realm'), trust_info['realm'] )
        self.addRow( T_('Save Trust'), self.save_trust )
        self.addButtons()
项目:sequana    作者:sequana    | 项目源码 | 文件源码
def __init__(self, option, value):
        # Make sure the value is a boolean
        if isinstance(value, str):
            if value.lower() in ['yes', "true", "on"]:
                value = True
            elif value in ['no', "false", "off"]:
                value = False
        super().__init__(option)

        self.check_box = QW.QCheckBox()
        self.check_box.setChecked(value)

        self.answer = QW.QLabel()
        self.switch_answer()

        self.check_box.clicked.connect(self.switch_answer)

        self.layout.addWidget(self.check_box)
        self.layout.addWidget(self.answer)
项目:sequana    作者:sequana    | 项目源码 | 文件源码
def read_settings(self):
        settings = QtCore.QSettings(self._application, self._section)
        for key in settings.allKeys():
            value = settings.value(key)
            try:
                # This is required to skip the tab_position key/value
                this = getattr(self.ui, key)
            except:
                continue
            if isinstance(this, QW.QLineEdit):
                this.setText(value)
            elif isinstance(this, QW.QSpinBox):
                this.setValue(int(value))
            elif isinstance(this, QW.QCheckBox):
                if value in ['false', False, "False"]:
                    this.setChecked(False)
                else:
                    this.setChecked(True)
            elif isinstance(this, FileBrowser):
                this.set_filenames(value)
            else:
                print('could not handle : %s' % this)
        # The last tab position
        self._tab_pos = settings.value("tab_position", 0, type=int)
        self.ui.tabs.setCurrentIndex(self._tab_pos)
项目:sequana    作者:sequana    | 项目源码 | 文件源码
def get_settings(self):
        # get all items to save in settings
        items = {}
        names = self._get_widget_names()
        for name in names:
            widget = getattr(self.ui, name)
            if isinstance(widget, QW.QLineEdit):
                value = widget.text()
            elif isinstance(widget, QW.QSpinBox):
                value = widget.value()
            elif isinstance(widget, QW.QCheckBox):
                value = widget.isChecked()
            elif isinstance(widget, QW.QSpinBox):
                value = widget.value()
            elif isinstance(widget, FileBrowser):
                value = widget.get_filenames()
            else:
                raise NotImplementedError("for developers")
            items[name] = value
        items["tab_position"] = self.ui.tabs.currentIndex()
        return items
项目:sequana    作者:sequana    | 项目源码 | 文件源码
def get_option(self):
        """Return option and its value as a list

        An option may be without any value, but we still return a list

        e.G. ["--verbose"] or ["--cores", "2"]
        """
        if isinstance(self.widget, QW.QCheckBox):
            if self.widget.isChecked() is True:
                return ["--" + self.name]
        else:
            value = self._get_value()
            if value is None or value in ["", '', "''", '""']:
                return []
            else:
                return ["--" + self.name, value]
项目:plexdesktop    作者:coryo    | 项目源码 | 文件源码
def __init__(self, parent=None):
        super().__init__(parent)
        self.setWindowTitle('Manual Add Server')
        self.form = QtWidgets.QFormLayout(self)
        self.secure = QtWidgets.QCheckBox()
        self.address = QtWidgets.QLineEdit()
        self.port = QtWidgets.QLineEdit('32400')
        self.token = QtWidgets.QLineEdit()
        self.form.addRow(QtWidgets.QLabel('HTTPS?'), self.secure)
        self.form.addRow(QtWidgets.QLabel('Address'), self.address)
        self.form.addRow(QtWidgets.QLabel('Port'), self.port)
        self.form.addRow(QtWidgets.QLabel('Access Token (optional)'), self.token)
        self.buttons = QtWidgets.QDialogButtonBox(
            QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel, QtCore.Qt.Horizontal, self)
        self.form.addRow(self.buttons)
        self.buttons.rejected.connect(self.reject)
        self.buttons.accepted.connect(self.accept)
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def setLang(self, langName):
        uiList_lang_read = self.memoData['lang'][langName]
        for ui_name in uiList_lang_read:
            ui_element = self.uiList[ui_name]
            if type(ui_element) in [ QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox ]:
                # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox
                if uiList_lang_read[ui_name] != "":
                    ui_element.setText(uiList_lang_read[ui_name])
            elif type(ui_element) in [ QtWidgets.QGroupBox, QtWidgets.QMenu ]:
                # uiType: QMenu, QGroupBox
                if uiList_lang_read[ui_name] != "":
                    ui_element.setTitle(uiList_lang_read[ui_name])
            elif type(ui_element) in [ QtWidgets.QTabWidget]:
                # uiType: QTabWidget
                tabCnt = ui_element.count()
                if uiList_lang_read[ui_name] != "":
                    tabNameList = uiList_lang_read[ui_name].split(';')
                    if len(tabNameList) == tabCnt:
                        for i in range(tabCnt):
                            if tabNameList[i] != "":
                                ui_element.setTabText(i,tabNameList[i])
            elif type(ui_element) == str:
                # uiType: string for msg
                if uiList_lang_read[ui_name] != "":
                    self.uiList[ui_name] = uiList_lang_read[ui_name]
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def setLang(self, langName):
        uiList_lang_read = self.memoData['lang'][langName]
        for ui_name in uiList_lang_read:
            ui_element = self.uiList[ui_name]
            if type(ui_element) in [ QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox ]:
                # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox
                if uiList_lang_read[ui_name] != "":
                    ui_element.setText(uiList_lang_read[ui_name])
            elif type(ui_element) in [ QtWidgets.QGroupBox, QtWidgets.QMenu ]:
                # uiType: QMenu, QGroupBox
                if uiList_lang_read[ui_name] != "":
                    ui_element.setTitle(uiList_lang_read[ui_name])
            elif type(ui_element) in [ QtWidgets.QTabWidget]:
                # uiType: QTabWidget
                tabCnt = ui_element.count()
                if uiList_lang_read[ui_name] != "":
                    tabNameList = uiList_lang_read[ui_name].split(';')
                    if len(tabNameList) == tabCnt:
                        for i in range(tabCnt):
                            if tabNameList[i] != "":
                                ui_element.setTabText(i,tabNameList[i])
            elif type(ui_element) == str:
                # uiType: string for msg
                if uiList_lang_read[ui_name] != "":
                    self.uiList[ui_name] = uiList_lang_read[ui_name]
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def setLang(self, langName):
        uiList_lang_read = self.memoData['lang'][langName]
        for ui_name in uiList_lang_read:
            ui_element = self.uiList[ui_name]
            if type(ui_element) in [ QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox ]:
                # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox
                if uiList_lang_read[ui_name] != "":
                    ui_element.setText(uiList_lang_read[ui_name])
            elif type(ui_element) in [ QtWidgets.QGroupBox, QtWidgets.QMenu ]:
                # uiType: QMenu, QGroupBox
                if uiList_lang_read[ui_name] != "":
                    ui_element.setTitle(uiList_lang_read[ui_name])
            elif type(ui_element) in [ QtWidgets.QTabWidget]:
                # uiType: QTabWidget
                tabCnt = ui_element.count()
                if uiList_lang_read[ui_name] != "":
                    tabNameList = uiList_lang_read[ui_name].split(';')
                    if len(tabNameList) == tabCnt:
                        for i in range(tabCnt):
                            if tabNameList[i] != "":
                                ui_element.setTabText(i,tabNameList[i])
            elif type(ui_element) == str:
                # uiType: string for msg
                if uiList_lang_read[ui_name] != "":
                    self.uiList[ui_name] = uiList_lang_read[ui_name]
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def setLang(self, langName):
        uiList_lang_read = self.memoData['lang'][langName]
        for ui_name in uiList_lang_read:
            ui_element = self.uiList[ui_name]
            if type(ui_element) in [ QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox ]:
                # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox
                if uiList_lang_read[ui_name] != "":
                    ui_element.setText(uiList_lang_read[ui_name])
            elif type(ui_element) in [ QtWidgets.QGroupBox, QtWidgets.QMenu ]:
                # uiType: QMenu, QGroupBox
                if uiList_lang_read[ui_name] != "":
                    ui_element.setTitle(uiList_lang_read[ui_name])
            elif type(ui_element) in [ QtWidgets.QTabWidget]:
                # uiType: QTabWidget
                tabCnt = ui_element.count()
                if uiList_lang_read[ui_name] != "":
                    tabNameList = uiList_lang_read[ui_name].split(';')
                    if len(tabNameList) == tabCnt:
                        for i in range(tabCnt):
                            if tabNameList[i] != "":
                                ui_element.setTabText(i,tabNameList[i])
            elif type(ui_element) == str:
                # uiType: string for msg
                if uiList_lang_read[ui_name] != "":
                    self.uiList[ui_name] = uiList_lang_read[ui_name]
项目:OpenTutorials_PyQt    作者:RavenKyu    | 项目源码 | 文件源码
def __init__(self):
        QWidget.__init__(self, flags=Qt.Widget)
        self.setWindowTitle("CheckBox")

        # ??? ?? ?? ??
        cb_1 = QCheckBox("CheckBox 1")
        cb_2 = QCheckBox("CheckBox 2")
        cb_3 = QCheckBox("CheckBox 3")
        cb_4 = QCheckBox("CheckBox 4")
        cb_5 = QCheckBox("CheckBox 5")

        # ???? ?? ? Form Widget? ??
        base_layout = QBoxLayout(QBoxLayout.TopToBottom, self)
        base_layout.addWidget(cb_1)
        base_layout.addWidget(cb_2)
        base_layout.addWidget(cb_3)
        base_layout.addWidget(cb_4)
        base_layout.addWidget(cb_5)

        self.setLayout(base_layout)
项目:OpenTutorials_PyQt    作者:RavenKyu    | 项目源码 | 文件源码
def __init__(self):
        QWidget.__init__(self, flags=Qt.Widget)
        self.setWindowTitle("CheckBox")
        base_layout = QBoxLayout(QBoxLayout.TopToBottom, self)
        self.setLayout(base_layout)

        # ??? ?? ?? ??
        self.lb = QLabel()
        base_layout.addWidget(self.lb)

        # CheckBox ?? ?? ? ??? ??
        self.cb_list = list()
        for i in range(2):
            w = QCheckBox("CheckBox %s" % i)
            w.stateChanged.connect(self._confirm)
            base_layout.addWidget(w)
            self.cb_list.append(w)

        # ?? ?? ??? ??
        self._confirm()
项目:PySAT_Point_Spectra_GUI    作者:USGS-Astrogeology    | 项目源码 | 文件源码
def setupUi(self, Form):
        Form.setObjectName("Form")
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(Form.sizePolicy().hasHeightForWidth())
        Form.setSizePolicy(sizePolicy)
        self.verticalLayout = QtWidgets.QVBoxLayout(Form)
        self.verticalLayout.setObjectName("verticalLayout")
        self.groupBox = QtWidgets.QGroupBox(Form)
        self.groupBox.setObjectName("groupBox")
        self.formLayout = QtWidgets.QFormLayout(self.groupBox)
        self.formLayout.setFieldGrowthPolicy(QtWidgets.QFormLayout.AllNonFixedFieldsGrow)
        self.formLayout.setObjectName("formLayout")
        self.fitInterceptLabel = QtWidgets.QLabel(self.groupBox)
        self.fitInterceptLabel.setObjectName("fitInterceptLabel")
        self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.fitInterceptLabel)
        self.fitInterceptCheckBox = QtWidgets.QCheckBox(self.groupBox)
        self.fitInterceptCheckBox.setChecked(True)
        self.fitInterceptCheckBox.setObjectName("fitInterceptCheckBox")
        self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.fitInterceptCheckBox)
        self.verticalLayout.addWidget(self.groupBox)

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def my_close(self):
        settings = constants.SETTINGS
        not_show = settings.value('not_show_close_dialog', False, type=bool)

        if not not_show:
            cb = QCheckBox("Do not show this again.")
            msgbox = QMessageBox(QMessageBox.Question, "Confirm close", "Are you sure you want to close?")
            msgbox.addButton(QMessageBox.Yes)
            msgbox.addButton(QMessageBox.No)
            msgbox.setDefaultButton(QMessageBox.No)
            msgbox.setCheckBox(cb)

            reply = msgbox.exec()

            not_show_again = bool(cb.isChecked())
            settings.setValue("not_show_close_dialog", not_show_again)
            self.not_show_again_changed.emit()
            if reply != QMessageBox.Yes:
                return

        self.closed.emit(self)
项目:FIRST-plugin-ida    作者:vrtadmin    | 项目源码 | 文件源码
def init_middle_layout(self):
            if not self.should_show:
                return

            vbox = QtWidgets.QVBoxLayout()
            self.select_all = QtWidgets.QCheckBox('Select All ')
            self.filter_sub_funcs = QtWidgets.QCheckBox('Filter Out "sub_" functions ')
            vbox.addWidget(self.filter_sub_funcs)
            vbox.addWidget(self.select_all)

            format_str = '{} functions'.format(self.total_functions)
            self.function_number = QtWidgets.QLabel(format_str)
            self.function_number.setAlignment(Qt.AlignTop)
            self.middle_layout.addWidget(self.function_number)
            self.middle_layout.addStretch()
            self.middle_layout.addLayout(vbox)
项目:FIRST-plugin-ida    作者:vrtadmin    | 项目源码 | 文件源码
def init_middle_layout(self):
            found = len(self.groups)
            total = len(FIRST.Metadata.get_non_jmp_wrapped_functions())
            s = 's' if 1 != total else ''
            label = 'Matched {0} out of {1} function{2}'

            self.select_highest_ranked = QtWidgets.QCheckBox('Select Highest Ranked ')
            self.filter_sub_funcs_only = QtWidgets.QCheckBox('Show only "sub_" functions')

            vbox = QtWidgets.QVBoxLayout()
            vbox.addWidget(self.filter_sub_funcs_only)
            vbox.addWidget(self.select_highest_ranked)

            self.found_format = label.format('{}', total, s)
            self.found_label = QtWidgets.QLabel(self.found_format.format(found))
            self.found_label.setAlignment(Qt.AlignTop)

            self.middle_layout.addWidget(self.found_label)
            self.middle_layout.addStretch()
            self.middle_layout.addLayout(vbox)
项目:pytc-gui    作者:harmslab    | 项目源码 | 文件源码
def _bool_handler(self,value):
        """
        Handler for bool values.  Parses QCheckBox.
        """

        value = self._select_widget.checkState() 
        self._current_value = value
        self._valid = True
项目:pytc-gui    作者:harmslab    | 项目源码 | 文件源码
def layout(self):

        # --------------- Guess -----------------       
        self._guess = QW.QLineEdit()
        self._guess.editingFinished.connect(self._guess_handler)
        self._current_guess = None

        # --------------- Lower -----------------       
        self._lower = QW.QLineEdit()
        self._lower.editingFinished.connect(self._lower_handler)
        self._current_lower = None

        # --------------- Upper -----------------       
        self._upper = QW.QLineEdit()
        self._upper.editingFinished.connect(self._upper_handler)
        self._current_upper = None

        # --------------- Fixed -----------------
        self._fixed = QW.QCheckBox()
        self._fixed.stateChanged.connect(self._fixed_handler)
        self._current_fixed = None

        # --------------- Alias -----------------
        self._alias = QW.QComboBox()
        self._alias.addItem("Unlink")
        self._alias.addItem("Add global")
        self._alias.addItem("Add connector")
        self._alias.currentIndexChanged.connect(self._alias_handler)
        self._current_alias = None

        # Load in parameters from FitParameter object
        self.update()
项目:pytc-gui    作者:harmslab    | 项目源码 | 文件源码
def __init__(self,parent,fit,experiment,settable_name,start_value,value_type,
                 allowable_values,float_view_cutoff=100000):
        """
        parent: parent widget
        fit: FitContainer object
        experiment: pytc.ITCExperiment object containing settable
        settable_name: name of settable (string) in experiment object
        start_value: starting value of settable when widget opens
        value_type: value type. 
            bool -> QCheckBox
            str,float,int -> QLineEdit, parsed appropriately
            multi -> QDropDown, using allowable_values to populate
        allowable_value: list of available values for multi, None otherwise
        float_view_cutoff: how to show floats in QLineEdit boxes
        """

        super().__init__()

        self._parent = parent
        self._fit = fit
        self._experiment = experiment
        self._settable_name = settable_name
        self._start_value = start_value
        self._value_type = value_type
        self._allowable_values = allowable_values
        self._float_view_cutoff = float_view_cutoff

        self._current_value = self._start_value

        self.layout()
项目:pytc-gui    作者:harmslab    | 项目源码 | 文件源码
def update(self):
        """
        Update widget based on what's actually in the experiment.
        """

        value = getattr(self._experiment,self._settable_name)
        if self._current_value != value:

            # --------- multi value ----------
            if self._value_type == "multi":

                current_index = self._select_widget.findText(value)
                if current_index == -1:
                    err = "current value is not in the allowable values\n"
                    raise ValueError(err)
                self._select_widget.setCurrentIndex(current_index)

            # --------- bool value --------------
            elif self._value_type == bool:

                self._select_widget = QW.QCheckBox()
                self._select_widget.setChecked(value)

            # -------- other values --------------
            else:
                if self._value_type == float:
                    if value < 1/self._float_view_cutoff or value > self._float_view_cutoff:
                        val_str = "{:.8e}".format(value)
                    else:
                        val_str = "{:.8f}".format(value)
                else:
                    val_str = "{}".format(value)

                self._select_widget.setText(val_str)
项目:specton    作者:somesortoferror    | 项目源码 | 文件源码
def saveSettings(self):
        lineEdit_filemaskregex = self.findChild(QLineEdit, "lineEdit_filemaskregex")
        cfg.settings.setValue('Options/FilemaskRegEx', lineEdit_filemaskregex.text())
        lineEdit_mediainfo_path = self.findChild(QLineEdit, "lineEdit_mediainfo_path")
        cfg.settings.setValue('Paths/mediainfo_bin', lineEdit_mediainfo_path.text())
        lineEdit_mp3guessenc_path = self.findChild(QLineEdit, "lineEdit_mp3guessenc_path")
        cfg.settings.setValue('Paths/mp3guessenc_bin', lineEdit_mp3guessenc_path.text())
        lineEdit_aucdtect_path = self.findChild(QLineEdit, "lineEdit_aucdtect_path")
        cfg.settings.setValue('Paths/aucdtect_bin', lineEdit_aucdtect_path.text())
        lineEdit_sox_path = self.findChild(QLineEdit, "lineEdit_sox_path")
        cfg.settings.setValue('Paths/sox_bin', lineEdit_sox_path.text())
        lineEdit_ffprobe_path = self.findChild(QLineEdit, "lineEdit_ffprobe_path")
        cfg.settings.setValue('Paths/ffprobe_bin', lineEdit_ffprobe_path.text())
        checkBox_recursive = self.findChild(QCheckBox, "checkBox_recursive")
        cfg.settings.setValue('Options/RecurseDirectories', checkBox_recursive.isChecked())
        checkBox_followsymlinks = self.findChild(QCheckBox, "checkBox_followsymlinks")
        cfg.settings.setValue('Options/FollowSymlinks', checkBox_followsymlinks.isChecked())
        checkBox_cache = self.findChild(QCheckBox, "checkBox_cache")
        cfg.settings.setValue('Options/UseCache', checkBox_cache.isChecked())
        checkBox_cacheraw = self.findChild(QCheckBox, "checkBox_cacheraw")
        cfg.settings.setValue('Options/CacheRawOutput', checkBox_cacheraw.isChecked())
        spinBox_processes = self.findChild(QSpinBox, "spinBox_processes")
        cfg.settings.setValue('Options/Processes', spinBox_processes.value())
        spinBox_spectrogram_palette = self.findChild(QSpinBox, "spinBox_spectrogram_palette")
        cfg.settings.setValue('Options/SpectrogramPalette', spinBox_spectrogram_palette.value())
        checkBox_debug = self.findChild(QCheckBox, "checkBox_debug")
        cfg.settings.setValue('Options/Debug', checkBox_debug.isChecked())
        cfg.debug_enabled = checkBox_debug.isChecked()
        checkBox_savewindowstate = self.findChild(QCheckBox, "checkBox_savewindowstate")
        cfg.settings.setValue('Options/SaveWindowState', checkBox_savewindowstate.isChecked())
        checkBox_clearfilelist = self.findChild(QCheckBox, "checkBox_clearfilelist")
        cfg.settings.setValue('Options/ClearFilelist', checkBox_clearfilelist.isChecked())
        checkBox_spectrogram = self.findChild(QCheckBox, "checkBox_spectrogram")
        cfg.settings.setValue('Options/EnableSpectrogram', checkBox_spectrogram.isChecked())
        checkBox_bitrate_graph = self.findChild(QCheckBox, "checkBox_bitrate_graph")
        cfg.settings.setValue('Options/EnableBitGraph', checkBox_bitrate_graph.isChecked())
        checkBox_aucdtect_scan = self.findChild(QCheckBox, "checkBox_aucdtect_scan")
        cfg.settings.setValue('Options/auCDtect_scan', checkBox_aucdtect_scan.isChecked())
        horizontalSlider_aucdtect_mode = self.findChild(QSlider, "horizontalSlider_aucdtect_mode")
        cfg.settings.setValue('Options/auCDtect_mode', horizontalSlider_aucdtect_mode.value())
        self.close()
项目:scm-workbench    作者:barry-scott    | 项目源码 | 文件源码
def __init__( self, wizard ):
        super().__init__( wizard )

        self.setTitle( T_('Add Git Project') )
        self.setSubTitle( T_('Clone Git repository') )

        #------------------------------------------------------------
        v = wb_dialog_bases.WbValidateUrl( all_supported_schemes,
                    T_('Fill in the upstream URL') )
        self.url_upstream = wb_dialog_bases.WbLineEdit( '', validator=v )

        self.setup_upstream = wb_dialog_bases.WbCheckBox(
                T_('git remote upstream. Usually required when using a forked repository'),
                False )

        self.setup_upstream.stateChanged.connect( self.url_upstream.setEnabled )
        self.url_upstream.setEnabled( False )

        self.setup_upstream.stateChanged.connect( self._fieldsChanged )
        self.url_upstream.textChanged.connect( self._fieldsChanged )

        #------------------------------------------------------------
        self.pull_rebase = QtWidgets.QCheckBox( T_('git pull --rebase') )
        self.pull_rebase.setChecked( True )

        #------------------------------------------------------------
        self.grid_layout.addNamedDivider( T_('git remote origin') )
        self.grid_layout.addRow( T_('Repository URL'), self.url )

        self.grid_layout.addNamedDivider( T_('git remote upstream') )
        self.grid_layout.addRow( T_('remote upstream'), self.setup_upstream )
        self.grid_layout.addRow( T_('upstream URL'),  self.url_upstream )

        self.grid_layout.addNamedDivider( T_('git config --local') )
        self.grid_layout.addRow( T_('pull.rebase'), self.pull_rebase )

        self.grid_layout.addFeedbackWidget()
项目:scm-workbench    作者:barry-scott    | 项目源码 | 文件源码
def __init__( self, dialog, name, present ):
        self.dialog = dialog
        self.name = name
        self.was_present = present
        self.starting_value = ''
        self.value_ctrl = None

        self.checkbox = QtWidgets.QCheckBox( name )
        self.checkbox.setCheckState( QtCore.Qt.Checked if present else QtCore.Qt.Unchecked )
项目:scm-workbench    作者:barry-scott    | 项目源码 | 文件源码
def __init__( self, app ):
        super().__init__( app, T_('Commit Log History') )

        if self.app is None:
            self.prefs = None
        else:
            self.prefs = self.app.prefs.log_history

        self.default_limit = QtWidgets.QSpinBox()
        self.default_limit.setRange( 1, 100000 )
        self.default_limit.setSuffix( T_(' Commits') )

        self.use_default_limit = QtWidgets.QCheckBox( T_('Use limit') )

        self.default_until = QtWidgets.QSpinBox()
        self.default_until.setRange( 1, 365 )
        self.default_until.setSuffix( T_(' days') )

        self.use_default_until = QtWidgets.QCheckBox( T_('Use until') )

        self.default_since = QtWidgets.QSpinBox()
        self.default_since.setRange( 2, 365 )
        self.default_since.setSuffix( T_(' days') )

        self.use_default_since = QtWidgets.QCheckBox( T_('Use since') )

        if self.prefs is not None:
            self.default_limit.setValue( self.prefs.default_limit )
            self.use_default_limit.setChecked( self.prefs.use_default_limit )

            self.default_until.setValue( self.prefs.default_until_days_interval )
            self.use_default_until.setChecked( self.prefs.use_default_until_days_interval )

            self.default_since.setValue( self.prefs.default_since_days_interval )
            self.use_default_since.setChecked( self.prefs.use_default_since_days_interval )

        self.addRow( T_('Default Limit'), self.default_limit, self.use_default_limit )
        self.addRow( T_('Default until interval'), self.default_until, self.use_default_until )
        self.addRow( T_('Default since interval'), self.default_since, self.use_default_since )

        self.default_until.valueChanged.connect( self.__untilChanged )
项目:kaptan    作者:KaOSx    | 项目源码 | 文件源码
def __init__(self, parent=None):
        super().__init__(parent)
        self.setSubTitle(self.tr("<h2>Welcome to KaOS</h2>"))

        vlayout = QVBoxLayout(self)
        vlayout.addItem(QSpacerItem(20, 30, QSizePolicy.Preferred, QSizePolicy.Minimum))

        hlayout = QHBoxLayout(self)
        label = QLabel(self)
        label.setText(self.tr("""<h1>What is KaOS?</h1>
        <p>The idea behind KaOS is to create a tightly integrated rolling and<br />
        transparent distribution for the modern desktop, build from scratch with<br />
        a very specific focus. Focus on one DE (KDE), one toolkit (Qt) & one architecture (x86_64).<br />
        Plus a focus on evaluating and selecting the most suitable tools and applications.</p>
        <p>This wizard will help you personalize your KaOS workspace easily and quickly.</p>
        <p>Please click <code style=color:#3498DB>Next</code> in order to begin. Click <code style=color:#3498DB>Cancel</code> anytime and changes won't be saved.</p>"""))
        label.setWordWrap(True)
        label.setAlignment(Qt.AlignLeft)
        hlayout.addWidget(label)

        kaptan_logo = QLabel(self)
        kaptan_logo.setPixmap(QPixmap(":/data/images/welcome.png"))
        kaptan_logo.setAlignment(Qt.AlignRight)
        kaptan_logo.setMaximumSize(157, 181)
        hlayout.addWidget(kaptan_logo)
        vlayout.addLayout(hlayout)

        vlayout.addItem(QSpacerItem(20, 40, QSizePolicy.Preferred, QSizePolicy.Preferred))

        desktop_file = os.path.join(os.environ["HOME"], ".config", "autostart", "kaptan.desktop")
        if os.path.exists(desktop_file):
            self.checkBox = QCheckBox()
            self.checkBox.setText(self.tr("Run on system startup"))
            self.checkBox.setChecked(True)
            self.checkBox.clicked.connect(self.autoRemove)
            vlayout.addWidget(self.checkBox)
项目:FuME    作者:fupadev    | 项目源码 | 文件源码
def setupUi(self, filter):
        filter.setObjectName("filter")
        filter.resize(381, 435)
        self.gridLayout = QtWidgets.QGridLayout(filter)
        self.gridLayout.setObjectName("gridLayout")
        self.buttonBox = QtWidgets.QDialogButtonBox(filter)
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
        self.buttonBox.setObjectName("buttonBox")
        self.gridLayout.addWidget(self.buttonBox, 3, 0, 1, 1)
        self.label_2 = QtWidgets.QLabel(filter)
        self.label_2.setObjectName("label_2")
        self.gridLayout.addWidget(self.label_2, 0, 0, 1, 1)
        self.listWidget = QtWidgets.QListWidget(filter)
        self.listWidget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.listWidget.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection)
        self.listWidget.setObjectName("listWidget")
        self.gridLayout.addWidget(self.listWidget, 2, 0, 1, 1)
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.label = QtWidgets.QLabel(filter)
        self.label.setObjectName("label")
        self.horizontalLayout.addWidget(self.label)
        self.lineEdit = QtWidgets.QLineEdit(filter)
        self.lineEdit.setInputMask("")
        self.lineEdit.setPlaceholderText("")
        self.lineEdit.setObjectName("lineEdit")
        self.horizontalLayout.addWidget(self.lineEdit)
        self.checkBox = QtWidgets.QCheckBox(filter)
        self.checkBox.setObjectName("checkBox")
        self.horizontalLayout.addWidget(self.checkBox)
        self.gridLayout.addLayout(self.horizontalLayout, 1, 0, 1, 1)
        self.label_2.raise_()
        self.listWidget.raise_()
        self.buttonBox.raise_()
        self.label.raise_()

        self.retranslateUi(filter)
        self.buttonBox.accepted.connect(filter.accept)
        self.buttonBox.rejected.connect(filter.reject)
        QtCore.QMetaObject.connectSlotsByName(filter)
项目:sequana    作者:sequana    | 项目源码 | 文件源码
def read_settings(self):
        settings = QtCore.QSettings(self._application, self._section)
        for key in settings.allKeys():
            value = settings.value(key)
            try:
                # This is required to skip the tab_position key/value
                this = getattr(self.ui, key)
            except:
                continue
            if isinstance(this, QW.QLineEdit):
                this.setText(value)
            elif isinstance(this, QW.QSpinBox):
                this.setValue(int(value))
            elif isinstance(this, QW.QComboBox):
                index = this.findText(value)
                this.setCurrentIndex(index)
            elif isinstance(this, QW.QCheckBox):
                if value in ['false']:
                    this.setChecked(False)
                else:
                    this.setChecked(True)
            else:
                print('could not handle : %s' % this)
        # The last tab position
        self._tab_pos = settings.value("tab_position", 0, type=int)
        self.ui.tabs.setCurrentIndex(self._tab_pos)
项目:pyree-old    作者:DrLuke    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        super(Bool, self).__init__(*args, **kwargs)

        self.propertiesWidget = QWidget()

        self.vlayout = QVBoxLayout()
        self.toggle = QCheckBox("Output")
        self.toggle.toggled.connect(self.toggleTrueFalse)

        self.vlayout.addWidget(self.toggle)
        self.vlayout.addItem(QSpacerItem(40, 20, QSizePolicy.Minimum, QSizePolicy.Expanding))

        self.propertiesWidget.setLayout(self.vlayout)
项目:plexdesktop    作者:coryo    | 项目源码 | 文件源码
def __init__(self, media_object, parent=None):
        super().__init__(parent)
        self.setWindowTitle('Preferences')
        self.form = QtWidgets.QFormLayout(self)
        server = media_object.container.server
        settings = server.container(media_object.key)
        self.ids = []
        for item in settings['_children']:
            itype = item['type']
            if itype == 'bool':
                input_widget = QtWidgets.QCheckBox()
                input_widget.setCheckState(QtCore.Qt.Checked if item['value'] == 'true' else QtCore.Qt.Unchecked)
            elif itype == 'enum':
                input_widget = QtWidgets.QComboBox()
                input_widget.addItems(item['values'].split('|'))
                input_widget.setCurrentIndex(int(item['value']))
            elif itype == 'text':
                input_widget = QtWidgets.QLineEdit(item['value'])
                if item['secure'] == 'true':
                    input_widget.setEchoMode(QtWidgets.QLineEdit.PasswordEchoOnEdit)
            else:
                input_widget = QtWidgets.QLabel('...')
            self.form.addRow(QtWidgets.QLabel(item['label']), input_widget)
            self.ids.append((item['id'], input_widget))

        self.buttons = QtWidgets.QDialogButtonBox(
            QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel, QtCore.Qt.Horizontal, self)
        self.form.addRow(self.buttons)
        self.buttons.rejected.connect(self.reject)
        self.buttons.accepted.connect(self.accept)
        if self.exec_() == QtWidgets.QDialog.Accepted:
            media_object.container.server.request(media_object.key + '/set', params=self.extract_values())
项目:plexdesktop    作者:coryo    | 项目源码 | 文件源码
def extract_values(self):
        values = {}
        for pid, widget in self.ids:
            if isinstance(widget, QtWidgets.QLineEdit):
                values[pid] = widget.text()
            elif isinstance(widget, QtWidgets.QComboBox):
                values[pid] = widget.currentIndex()
            elif isinstance(widget, QtWidgets.QCheckBox):
                values[pid] = 'true' if widget.checkState() == QtCore.Qt.Checked else 'false'
        return values
项目:plexdesktop    作者:coryo    | 项目源码 | 文件源码
def __init__(self, parent=None):
        super().__init__(parent)
        s = plexdesktop.settings.Settings()
        self.setWindowTitle('Preferences')
        self.form = QtWidgets.QFormLayout(self)

        i = QtWidgets.QComboBox()
        i.addItems(plexdesktop.style.Style.Instance().themes)
        i.setCurrentIndex(i.findText(s.value('theme')))
        self.form.addRow(QtWidgets.QLabel('theme'), i)

        bf = QtWidgets.QSpinBox()
        bf.setValue(int(s.value('browser_font', 9)))
        self.form.addRow(QtWidgets.QLabel('browser font size'), bf)

        icon_size = QtWidgets.QLineEdit(str(s.value('thumb_size', 240)))
        icon_size.setValidator(QtGui.QIntValidator(0, 300))
        self.form.addRow(QtWidgets.QLabel('thumbnail size'), icon_size)

        widget_player = QtWidgets.QCheckBox()
        widget_player.setCheckState(QtCore.Qt.Checked if bool(int(s.value('widget_player', 0))) else QtCore.Qt.Unchecked)
        self.form.addRow(QtWidgets.QLabel('use widget player'), widget_player)

        self.buttons = QtWidgets.QDialogButtonBox(
            QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel,
            QtCore.Qt.Horizontal, self)
        self.form.addRow(self.buttons)
        self.buttons.rejected.connect(self.reject)
        self.buttons.accepted.connect(self.accept)

        if self.exec_() == QtWidgets.QDialog.Accepted:
            # s = Settings()
            theme = i.currentText()
            s.setValue('theme', theme)
            plexdesktop.style.Style.Instance().theme(theme)

            s.setValue('browser_font', bf.value())

            s.setValue('thumb_size', int(icon_size.text()))

            s.setValue('widget_player', 1 if widget_player.checkState() == QtCore.Qt.Checked else 0)
项目:vivisect-py3    作者:bat-serjo    | 项目源码 | 文件源码
def __init__(self, config, name, value, parent=None):
        QtWidgets.QCheckBox.__init__(self, parent=parent)
        EnviConfigOption.__init__(self, config, name, value)
        self.toggled.connect(self.setEnviValue)
        self.setChecked(value)
项目:PINCE    作者:korcankaraokcu    | 项目源码 | 文件源码
def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(1025, 530)
        Form.setToolTip("")
        self.gridLayout = QtWidgets.QGridLayout(Form)
        self.gridLayout.setObjectName("gridLayout")
        self.splitter = QtWidgets.QSplitter(Form)
        self.splitter.setOrientation(QtCore.Qt.Horizontal)
        self.splitter.setObjectName("splitter")
        self.layoutWidget = QtWidgets.QWidget(self.splitter)
        self.layoutWidget.setObjectName("layoutWidget")
        self.verticalLayout = QtWidgets.QVBoxLayout(self.layoutWidget)
        self.verticalLayout.setObjectName("verticalLayout")
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.lineEdit_Regex = QtWidgets.QLineEdit(self.layoutWidget)
        self.lineEdit_Regex.setObjectName("lineEdit_Regex")
        self.horizontalLayout_2.addWidget(self.lineEdit_Regex)
        self.checkBox_IgnoreCase = QtWidgets.QCheckBox(self.layoutWidget)
        self.checkBox_IgnoreCase.setChecked(True)
        self.checkBox_IgnoreCase.setObjectName("checkBox_IgnoreCase")
        self.horizontalLayout_2.addWidget(self.checkBox_IgnoreCase)
        self.checkBox_Regex = QtWidgets.QCheckBox(self.layoutWidget)
        self.checkBox_Regex.setObjectName("checkBox_Regex")
        self.horizontalLayout_2.addWidget(self.checkBox_Regex)
        self.pushButton_Search = QtWidgets.QPushButton(self.layoutWidget)
        self.pushButton_Search.setObjectName("pushButton_Search")
        self.horizontalLayout_2.addWidget(self.pushButton_Search)
        self.verticalLayout.addLayout(self.horizontalLayout_2)
        self.listWidget_Referrers = QtWidgets.QListWidget(self.layoutWidget)
        self.listWidget_Referrers.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
        self.listWidget_Referrers.setObjectName("listWidget_Referrers")
        self.verticalLayout.addWidget(self.listWidget_Referrers)
        self.textBrowser_DisasInfo = QtWidgets.QTextBrowser(self.splitter)
        self.textBrowser_DisasInfo.setLineWrapMode(QtWidgets.QTextEdit.NoWrap)
        self.textBrowser_DisasInfo.setObjectName("textBrowser_DisasInfo")
        self.gridLayout.addWidget(self.splitter, 0, 0, 1, 1)

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)
项目:pysport    作者:sportorg    | 项目源码 | 文件源码
def apply_changes_impl(self):
        for i in Qualification:
            name = i.name
            if i in self.group.ranking.rank:
                rank = self.group.ranking.rank[i]
                assert isinstance(rank, RankingItem)
                rank.is_active = self.findChild(QCheckBox, name + '_checkbox').isChecked()
                rank.max_place = self.findChild(QSpinBox, name + '_place').value()
                rank.max_time = time_to_otime(self.findChild(QTimeEdit, name + '_time').time())
                rank.use_scores = self.findChild(AdvComboBox, name + '_combo').currentText() == _('Rank')
        ResultCalculation().set_rank(self.group)
项目:pysport    作者:sportorg    | 项目源码 | 文件源码
def init_ui(self):
        self.setWindowTitle(_('Settings'))
        self.setWindowIcon(QIcon(config.ICON))
        self.setSizeGripEnabled(False)
        self.setModal(True)
        # self.setMinimumWidth(540)
        # self.setMinimumHeight(250)
        self.layout = QFormLayout(self)

        self.auto_save = QCheckBox(_('Auto save'))
        self.auto_save.setChecked(Config().configuration.get('autosave'))
        self.layout.addRow(self.auto_save)

        self.auto_connect = QCheckBox(_('Auto connect to station'))
        self.auto_connect.setChecked(Config().configuration.get('autoconnect'))
        self.layout.addRow(self.auto_connect)

        self.open_recent_file = QCheckBox(_('Open recent file'))
        self.open_recent_file.setChecked(Config().configuration.get('open_recent_file'))
        self.layout.addRow(self.open_recent_file)

        def cancel_changes():
            self.close()

        def apply_changes():
            try:
                self.apply_changes_impl()
            except Exception as e:
                logging.exception(str(e))
            self.close()

        self.button_ok = QPushButton(_('OK'))
        self.button_ok.clicked.connect(apply_changes)
        self.button_cancel = QPushButton(_('Cancel'))
        self.button_cancel.clicked.connect(cancel_changes)
        self.layout.addRow(self.button_ok, self.button_cancel)

        self.show()
项目:kalbur    作者:ahmetax    | 项目源码 | 文件源码
def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(216, 152)
        self.verticalLayout_2 = QtWidgets.QVBoxLayout(Dialog)
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.verticalLayout = QtWidgets.QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        self.chkStopword = QtWidgets.QCheckBox(Dialog)
        self.chkStopword.setObjectName("chkStopword")
        self.verticalLayout.addWidget(self.chkStopword)
        self.chkEnuzunkok = QtWidgets.QCheckBox(Dialog)
        self.chkEnuzunkok.setObjectName("chkEnuzunkok")
        self.verticalLayout.addWidget(self.chkEnuzunkok)
        self.chkTumKokleriListele = QtWidgets.QCheckBox(Dialog)
        self.chkTumKokleriListele.setObjectName("chkTumKokleriListele")
        self.verticalLayout.addWidget(self.chkTumKokleriListele)
        self.verticalLayout_2.addLayout(self.verticalLayout)
        spacerItem = QtWidgets.QSpacerItem(20, 17, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
        self.verticalLayout_2.addItem(spacerItem)
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.pushButton = QtWidgets.QPushButton(Dialog)
        self.pushButton.setObjectName("pushButton")
        self.horizontalLayout.addWidget(self.pushButton)
        spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem1)
        self.pushButton_2 = QtWidgets.QPushButton(Dialog)
        self.pushButton_2.setObjectName("pushButton_2")
        self.horizontalLayout.addWidget(self.pushButton_2)
        self.verticalLayout_2.addLayout(self.horizontalLayout)

        self.retranslateUi(Dialog)
        self.pushButton.clicked.connect(Dialog.close)
        self.pushButton_2.clicked.connect(Dialog.secenekKaydet)
        QtCore.QMetaObject.connectSlotsByName(Dialog)
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def setLang(self, langName):
        lang_data = self.memoData['lang'][langName]
        for ui_name in lang_data.keys():
            if ui_name in self.uiList.keys() and lang_data[ui_name] != '':
                ui_element = self.uiList[ui_name]
                # '' means no translation availdanle in that data file
                if isinstance(ui_element, (QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox) ):
                    # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox
                    ui_element.setText(lang_data[ui_name])
                elif isinstance(ui_element, (QtWidgets.QGroupBox, QtWidgets.QMenu) ):
                    # uiType: QMenu, QGroupBox
                    ui_element.setTitle(lang_data[ui_name])
                elif isinstance(ui_element, QtWidgets.QTabWidget):
                    # uiType: QTabWidget
                    tabCnt = ui_element.count()
                    tabNameList = lang_data[ui_name].split(';')
                    if len(tabNameList) == tabCnt:
                        for i in range(tabCnt):
                            if tabNameList[i] != '':
                                ui_element.setTabText(i,tabNameList[i])
                elif isinstance(ui_element, QtWidgets.QComboBox):
                    # uiType: QComboBox
                    itemCnt = ui_element.count()
                    itemNameList = lang_data[ui_name].split(';')
                    ui_element.clear()
                    ui_element.addItems(itemNameList)
                elif isinstance(ui_element, QtWidgets.QTreeWidget):
                    # uiType: QTreeWidget
                    labelCnt = ui_element.headerItem().columnCount()
                    labelList = lang_data[ui_name].split(';')
                    ui_element.setHeaderLabels(labelList)
                elif isinstance(ui_element, QtWidgets.QTableWidget):
                    # uiType: QTableWidget
                    colCnt = ui_element.columnCount()
                    headerList = lang_data[ui_name].split(';')
                    cur_table.setHorizontalHeaderLabels( headerList )
                elif isinstance(ui_element, (str, unicode) ):
                    # uiType: string for msg
                    self.uiList[ui_name] = lang_data[ui_name]
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def loadLang(self):
        self.quickMenu(['language_menu;&Language'])
        cur_menu = self.uiList['language_menu']
        self.quickMenuAction('langDefault_atnLang', 'Default','','langDefault.png', cur_menu)
        cur_menu.addSeparator()
        self.uiList['langDefault_atnLang'].triggered.connect(partial(self.setLang,'default'))
        # store default language
        self.memoData['lang']={}
        self.memoData['lang']['default']={}
        for ui_name in self.uiList:
            ui_element = self.uiList[ui_name]
            if type(ui_element) in [ QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox ]:
                # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox
                self.memoData['lang']['default'][ui_name] = str(ui_element.text())
            elif type(ui_element) in [ QtWidgets.QGroupBox, QtWidgets.QMenu ]:
                # uiType: QMenu, QGroupBox
                self.memoData['lang']['default'][ui_name] = str(ui_element.title())
            elif type(ui_element) in [ QtWidgets.QTabWidget]:
                # uiType: QTabWidget
                tabCnt = ui_element.count()
                tabNameList = []
                for i in range(tabCnt):
                    tabNameList.append(str(ui_element.tabText(i)))
                self.memoData['lang']['default'][ui_name]=';'.join(tabNameList)
            elif type(ui_element) == str:
                # uiType: string for msg
                self.memoData['lang']['default'][ui_name] = self.uiList[ui_name]

        # try load other language
        lang_path = os.path.dirname(self.location) # better in packed than(os.path.abspath(__file__))
        baseName = os.path.splitext( os.path.basename(self.location) )[0]
        for fileName in os.listdir(lang_path):
            if fileName.startswith(baseName+"_lang_"):
                langName = fileName.replace(baseName+"_lang_","").split('.')[0].replace(" ","")
                self.memoData['lang'][ langName ] = self.readRawFile( os.path.join(lang_path,fileName) )
                self.quickMenuAction(langName+'_atnLang', langName.upper(),'',langName + '.png', cur_menu)
                self.uiList[langName+'_atnLang'].triggered.connect(partial(self.setLang,langName))
        # if no language file detected, add export default language option
        if len(self.memoData['lang']) == 1:
            self.quickMenuAction('langExport_atnLang', 'Export Default Language','','langExport.png', cur_menu)
            self.uiList['langExport_atnLang'].triggered.connect(self.exportLang)
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def setLang(self, langName):
        lang_data = self.memoData['lang'][langName]
        for ui_name in lang_data.keys():
            if ui_name in self.uiList.keys() and lang_data[ui_name] != '':
                ui_element = self.uiList[ui_name]
                # '' means no translation availdanle in that data file
                if isinstance(ui_element, (QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox) ):
                    # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox
                    ui_element.setText(lang_data[ui_name])
                elif isinstance(ui_element, (QtWidgets.QGroupBox, QtWidgets.QMenu) ):
                    # uiType: QMenu, QGroupBox
                    ui_element.setTitle(lang_data[ui_name])
                elif isinstance(ui_element, QtWidgets.QTabWidget):
                    # uiType: QTabWidget
                    tabCnt = ui_element.count()
                    tabNameList = lang_data[ui_name].split(';')
                    if len(tabNameList) == tabCnt:
                        for i in range(tabCnt):
                            if tabNameList[i] != '':
                                ui_element.setTabText(i,tabNameList[i])
                elif isinstance(ui_element, QtWidgets.QComboBox):
                    # uiType: QComboBox
                    itemCnt = ui_element.count()
                    itemNameList = lang_data[ui_name].split(';')
                    ui_element.clear()
                    ui_element.addItems(itemNameList)
                elif isinstance(ui_element, QtWidgets.QTreeWidget):
                    # uiType: QTreeWidget
                    labelCnt = ui_element.headerItem().columnCount()
                    labelList = lang_data[ui_name].split(';')
                    ui_element.setHeaderLabels(labelList)
                elif isinstance(ui_element, QtWidgets.QTableWidget):
                    # uiType: QTableWidget
                    colCnt = ui_element.columnCount()
                    headerList = lang_data[ui_name].split(';')
                    cur_table.setHorizontalHeaderLabels( headerList )
                elif isinstance(ui_element, (str, unicode) ):
                    # uiType: string for msg
                    self.uiList[ui_name] = lang_data[ui_name]
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def qui(self, ui_list_string, parentObject_string='', opt=''):
        # pre-defined user short name syntax
        type_dict = {
            'vbox': 'QVBoxLayout','hbox':'QHBoxLayout','grid':'QGridLayout', 'form':'QFormLayout',
            'split': 'QSplitter', 'grp':'QGroupBox', 'tab':'QTabWidget',
            'btn':'QPushButton', 'btnMsg':'QPushButton', 'label':'QLabel', 'input':'QLineEdit', 'check':'QCheckBox', 'choice':'QComboBox',
            'txtEdit': 'LNTextEdit', 'txt': 'QTextEdit',
            'tree': 'QTreeWidget', 'table': 'QTableWidget',
            'space': 'QSpacerItem', 
        }
        # get ui_list, creation or existing ui object
        ui_list = [x.strip() for x in ui_list_string.split('|')]
        for i in range(len(ui_list)):
            if ui_list[i] in self.uiList:
                # - exisiting object
                ui_list[i] = self.uiList[ui_list[i]]
            else:
                # - string creation: 
                # get part info
                partInfo = ui_list[i].split(';',1)
                uiName = partInfo[0].split('@')[0]
                uiType = uiName.rsplit('_',1)[-1]
                if uiType in type_dict:
                    uiType = type_dict[uiType]
                # set quickUI string format
                ui_list[i] = partInfo[0]+';'+uiType
                if len(partInfo)==1:
                    # give empty button and label a place holder name
                    if uiType in ('btn', 'btnMsg', 'QPushButton','label', 'QLabel'):
                        ui_list[i] = partInfo[0]+';'+uiType + ';'+uiName 
                elif len(partInfo)==2:
                    ui_list[i]=ui_list[i]+";"+partInfo[1]
        # get parentObject or exisiting object
        parentObject = parentObject_string
        if parentObject in self.uiList:
            parentObject = self.uiList[parentObject]
        # process quickUI
        self.quickUI(ui_list, parentObject, opt)
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def loadLang(self):
        self.quickMenu(['language_menu;&Language'])
        cur_menu = self.uiList['language_menu']
        self.quickMenuAction('langDefault_atnLang', 'Default','','langDefault.png', cur_menu)
        cur_menu.addSeparator()
        self.uiList['langDefault_atnLang'].triggered.connect(partial(self.setLang,'default'))
        # store default language
        self.memoData['lang']={}
        self.memoData['lang']['default']={}
        for ui_name in self.uiList:
            ui_element = self.uiList[ui_name]
            if type(ui_element) in [ QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox ]:
                # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox
                self.memoData['lang']['default'][ui_name] = str(ui_element.text())
            elif type(ui_element) in [ QtWidgets.QGroupBox, QtWidgets.QMenu ]:
                # uiType: QMenu, QGroupBox
                self.memoData['lang']['default'][ui_name] = str(ui_element.title())
            elif type(ui_element) in [ QtWidgets.QTabWidget]:
                # uiType: QTabWidget
                tabCnt = ui_element.count()
                tabNameList = []
                for i in range(tabCnt):
                    tabNameList.append(str(ui_element.tabText(i)))
                self.memoData['lang']['default'][ui_name]=';'.join(tabNameList)
            elif type(ui_element) == str:
                # uiType: string for msg
                self.memoData['lang']['default'][ui_name] = self.uiList[ui_name]

        # try load other language
        lang_path = os.path.dirname(self.location) # better in packed than(os.path.abspath(__file__))
        baseName = os.path.splitext( os.path.basename(self.location) )[0]
        for fileName in os.listdir(lang_path):
            if fileName.startswith(baseName+"_lang_"):
                langName = fileName.replace(baseName+"_lang_","").split('.')[0].replace(" ","")
                self.memoData['lang'][ langName ] = self.readRawFile( os.path.join(lang_path,fileName) )
                self.quickMenuAction(langName+'_atnLang', langName.upper(),'',langName + '.png', cur_menu)
                self.uiList[langName+'_atnLang'].triggered.connect(partial(self.setLang,langName))
        # if no language file detected, add export default language option
        if len(self.memoData['lang']) == 1:
            self.quickMenuAction('langExport_atnLang', 'Export Default Language','','langExport.png', cur_menu)
            self.uiList['langExport_atnLang'].triggered.connect(self.exportLang)
项目:universal_tool_template.py    作者:shiningdesign    | 项目源码 | 文件源码
def setLang(self, langName):
        lang_data = self.memoData['lang'][langName]
        for ui_name in lang_data.keys():
            if ui_name in self.uiList.keys() and lang_data[ui_name] != '':
                ui_element = self.uiList[ui_name]
                # '' means no translation availdanle in that data file
                if isinstance(ui_element, (QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox) ):
                    # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox
                    ui_element.setText(lang_data[ui_name])
                elif isinstance(ui_element, (QtWidgets.QGroupBox, QtWidgets.QMenu) ):
                    # uiType: QMenu, QGroupBox
                    ui_element.setTitle(lang_data[ui_name])
                elif isinstance(ui_element, QtWidgets.QTabWidget):
                    # uiType: QTabWidget
                    tabCnt = ui_element.count()
                    tabNameList = lang_data[ui_name].split(';')
                    if len(tabNameList) == tabCnt:
                        for i in range(tabCnt):
                            if tabNameList[i] != '':
                                ui_element.setTabText(i,tabNameList[i])
                elif isinstance(ui_element, QtWidgets.QComboBox):
                    # uiType: QComboBox
                    itemCnt = ui_element.count()
                    itemNameList = lang_data[ui_name].split(';')
                    ui_element.clear()
                    ui_element.addItems(itemNameList)
                elif isinstance(ui_element, QtWidgets.QTreeWidget):
                    # uiType: QTreeWidget
                    labelCnt = ui_element.headerItem().columnCount()
                    labelList = lang_data[ui_name].split(';')
                    ui_element.setHeaderLabels(labelList)
                elif isinstance(ui_element, QtWidgets.QTableWidget):
                    # uiType: QTableWidget
                    colCnt = ui_element.columnCount()
                    headerList = lang_data[ui_name].split(';')
                    cur_table.setHorizontalHeaderLabels( headerList )
                elif isinstance(ui_element, (str, unicode) ):
                    # uiType: string for msg
                    self.uiList[ui_name] = lang_data[ui_name]
项目:bubblesub    作者:rr-    | 项目源码 | 文件源码
def __init__(self, parent):
        super().__init__('Font', parent)
        self.font_name_edit = QtWidgets.QComboBox(
            self,
            editable=False,
            sizePolicy=QtWidgets.QSizePolicy(
                QtWidgets.QSizePolicy.Expanding,
                QtWidgets.QSizePolicy.Preferred),
            insertPolicy=QtWidgets.QComboBox.NoInsert)
        self.font_size_edit = QtWidgets.QSpinBox(self, minimum=0)
        self.bold_checkbox = QtWidgets.QCheckBox('Bold', self)
        self.italic_checkbox = QtWidgets.QCheckBox('Italic', self)
        self.underline_checkbox = QtWidgets.QCheckBox('Underline', self)
        self.strike_out_checkbox = QtWidgets.QCheckBox('Strike-out', self)

        all_fonts = QtGui.QFontDatabase().families()
        self.font_name_edit.addItems(all_fonts)

        layout = QtWidgets.QGridLayout(self)
        layout.setColumnStretch(0, 1)
        layout.setColumnStretch(1, 2)
        layout.addWidget(QtWidgets.QLabel('Name:', self), 0, 0)
        layout.addWidget(self.font_name_edit, 0, 1)
        layout.addWidget(QtWidgets.QLabel('Size:', self), 1, 0)
        layout.addWidget(self.font_size_edit, 1, 1)
        layout.addWidget(QtWidgets.QLabel('Style:', self), 2, 0)
        layout.addWidget(self.bold_checkbox, 2, 1)
        layout.addWidget(self.italic_checkbox, 3, 1)
        layout.addWidget(self.underline_checkbox, 4, 1)
        layout.addWidget(self.strike_out_checkbox, 5, 1)
项目:bubblesub    作者:rr-    | 项目源码 | 文件源码
def __init__(self, parent=None):
        super().__init__(parent)

        self.style_edit = QtWidgets.QComboBox(
            self,
            editable=True,
            sizePolicy=QtWidgets.QSizePolicy(
                QtWidgets.QSizePolicy.Expanding,
                QtWidgets.QSizePolicy.Preferred),
            insertPolicy=QtWidgets.QComboBox.NoInsert)
        self.actor_edit = QtWidgets.QComboBox(
            self,
            editable=True,
            sizePolicy=QtWidgets.QSizePolicy(
                QtWidgets.QSizePolicy.Expanding,
                QtWidgets.QSizePolicy.Preferred),
            insertPolicy=QtWidgets.QComboBox.NoInsert)
        self.effect_edit = QtWidgets.QLineEdit(self)
        self.comment_checkbox = QtWidgets.QCheckBox('Comment', self)

        layout = QtWidgets.QHBoxLayout(self)
        layout.setSpacing(12)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(QtWidgets.QLabel('Style:', self))
        layout.addWidget(self.style_edit)
        layout.addWidget(QtWidgets.QLabel('Actor:', self))
        layout.addWidget(self.actor_edit)
        layout.addStretch()
        layout.addWidget(QtWidgets.QLabel('Effect:', self))
        layout.addWidget(self.effect_edit)
        layout.addWidget(self.comment_checkbox)
项目:DCheat    作者:DCheat    | 项目源码 | 文件源码
def __init__(self, socket, pui, pCourseList, parent=None):
        QtWidgets.QDialog.__init__(self, parent)
        self.ui = uic.loadUi(config.config.ROOT_PATH +'view/registerCourse.ui', self)

        self.sock = socket
        self.pui = pui
        self.pCourseList = pCourseList

        self.banList = []
        self.allowList = []
        self.students = []

        self.ui.dateEdit.setDate(datetime.datetime.now().date())

        pListWidget = QtWidgets.QWidget()
        self.ui.scrollArea.setWidgetResizable(True)
        self.ui.scrollArea.setWidget(pListWidget)
        pListLayout = QtWidgets.QVBoxLayout()
        pListLayout.setAlignment(Qt.AlignTop)
        pListWidget.setLayout(pListLayout)

        for i in range(1, len(config.config.BAN_PROGRAM)):
            checkBox = QtWidgets.QCheckBox(config.config.BAN_PROGRAM[i])
            checkBox.clicked.connect(self.set_ban_list)
            pListLayout.addWidget(checkBox)

        sListWidget = QtWidgets.QWidget()
        self.ui.scrollArea_2.setWidgetResizable(True)
        self.ui.scrollArea_2.setWidget(sListWidget)
        sListLayout = QtWidgets.QVBoxLayout()
        sListLayout.setAlignment(Qt.AlignTop)
        sListWidget.setLayout(sListLayout)

        for i in range(1, len(config.config.ALLOW_SITE)):
            checkBox = QtWidgets.QCheckBox(config.config.ALLOW_SITE[i])
            checkBox.clicked.connect(self.set_allow_list)
            sListLayout.addWidget(checkBox)

        self.ui.show()
项目:OpenTutorials_PyQt    作者:RavenKyu    | 项目源码 | 文件源码
def init_widget(self):
        """
        ?? ??? ???? ???
        """
        self.setWindowTitle("Hello World")
        form_lbx = QBoxLayout(QBoxLayout.TopToBottom, parent=self)
        self.setLayout(form_lbx)

        # 1? ???? ??
        gb_1 = QGroupBox(self)
        gb_1.setTitle("GroupBox")
        form_lbx.addWidget(gb_1)
        lbx = QBoxLayout(QBoxLayout.LeftToRight, parent=self)
        gb_1.setLayout(lbx)
        lbx.addWidget(QCheckBox("check box #1"))
        lbx.addWidget(QCheckBox("check box #2"))
        lbx.addWidget(QCheckBox("check box #3"))

        # 2? ????, ???? ??? ??, ?? ??? ????
        gb_2 = QGroupBox(self)
        gb_2.setTitle("GroupBox")
        gb_2.setCheckable(True)
        gb_2.setChecked(False)
        form_lbx.addWidget(gb_2)
        lbx = QBoxLayout(QBoxLayout.LeftToRight, parent=self)
        gb_2.setLayout(lbx)
        lbx.addWidget(QRadioButton("radio button #1"))
        lbx.addWidget(QRadioButton("radio button #2"))
        lbx.addWidget(QRadioButton("radio button #3"))