Python PySide.QtCore 模块,QSettings() 实例源码

我们从Python开源项目中,提取了以下18个代码示例,用于说明如何使用PySide.QtCore.QSettings()

项目:KicadSolderTool    作者:pioupus    | 项目源码 | 文件源码
def openTransformation(self):
        fileName = QtGui.QFileDialog.getOpenFileName(self, self.tr("Open Kicad board File"),
                                                        self.currentPath, "*.trans")[0]
        if fileName!="":
            settings = QtCore.QSettings(fileName,QtCore.QSettings.IniFormat)

            self.spin_transformation_a_x.setValue(int(settings.value("pcb_ax",0)))
            self.spin_transformation_a_y.setValue(int(settings.value("pcb_ay",0)))
            self.spin_transformation_b_x.setValue(int(settings.value("pcb_bx",1)))
            self.spin_transformation_b_y.setValue(int(settings.value("pcb_by",1)))
            self.spin_offset_x.setValue(int(settings.value("off_x",1)))
            self.spin_offset_y.setValue(int(settings.value("off_y",1)))
            self.transform_target_topleft.setX(int(settings.value("view_ax",0)))
            self.transform_target_topleft.setY(int(settings.value("view_ay",0)))
            self.transform_target_bottom_right.setX(int(settings.value("view_bx",1)))
            self.transform_target_bottom_right.setY(int(settings.value("view_by",1)))
            self.calc_transform(0)
项目:KicadSolderTool    作者:pioupus    | 项目源码 | 文件源码
def saveTransformation(self):
        if self.pcb_fileName!="":
            print(self.pcb_fileName+'.trans')
            settings = QtCore.QSettings(self.pcb_fileName+'.trans',QtCore.QSettings.IniFormat)

            settings.setValue("pcb_ax",self.spin_transformation_a_x.value())
            settings.setValue("pcb_ay",self.spin_transformation_a_y.value())
            settings.setValue("pcb_bx",self.spin_transformation_b_x.value())
            settings.setValue("pcb_by",self.spin_transformation_b_y.value())
            settings.setValue("off_x",self.spin_offset_x.value())
            settings.setValue("off_y",self.spin_offset_y.value())
            settings.setValue("view_ax",self.transform_target_topleft.x())
            settings.setValue("view_ay",self.transform_target_topleft.y())
            settings.setValue("view_bx",self.transform_target_bottom_right.x())
            settings.setValue("view_by",self.transform_target_bottom_right.y())
            settings.sync()
项目:KicadSolderTool    作者:pioupus    | 项目源码 | 文件源码
def openFile(self, path=""):
        if path=="":
            fileName = QtGui.QFileDialog.getOpenFileName(self, self.tr("Open Kicad board File"),
                                                        self.currentPath, "*.kicad_pcb")[0]
        else:
            fileName = path

        if fileName!="":
            self.pcb_fileName = fileName
            QtCore.QSettings("./KicadSolderTool.ini",QtCore.QSettings.IniFormat).setValue("recent_file",fileName);
            self.transform_target_topleft_set = False
            self.transform_target_bottom_right_set = False
            svg_filename_top = fileName+'top.svg'
            svg_filename_bot = fileName+'bot.svg'
            kicad_handler.pcb_to_svg(fileName,svg_filename_top,svg_filename_bot )
            self.footprintlist = query_footprints.query_and_sort(fileName)
            self.showFile(svg_filename_top,svg_filename_bot)
            self.footprintlist_window = FootPrintList(self,self.footprintlist)
项目:ida-settings    作者:williballenthin    | 项目源码 | 文件源码
def export_settings(settings, config_path):
    """
    Export the given settings instance to the given file system path.

    type settings: IDASettingsInterface
    type config_path: str
    """
    other = QtCore.QSettings(config_path, QtCore.QSettings.IniFormat)
    for k, v in settings.iteritems():
        other.setValue(k, v)


#######################################################################################
#
# Test Cases
#  run this file as an IDAPython script to invoke the tests.
#
#######################################################################################
项目:KicadSolderTool    作者:pioupus    | 项目源码 | 文件源码
def openRecent(self):
        fileName = QtCore.QSettings("./KicadSolderTool.ini",QtCore.QSettings.IniFormat).value("recent_file","");
        self.openFile(fileName)
项目:ida-settings    作者:williballenthin    | 项目源码 | 文件源码
def validate(s):
    # the slash character is used by QSettings to denote a subgroup
    # we want to have a single nested structure of settings
    if "/" in s:
        return False
    if "\\" in s:
        # QSettings automatically translates '\' to '/'
        return False
    return True


# provide base constructor args required by settings providers
项目:ida-settings    作者:williballenthin    | 项目源码 | 文件源码
def has_qsettings_write_permission(settings):
    value = datetime.datetime.now().isoformat("T")
    settings.setValue(MARKER_KEY, value)
    settings.sync()
    # there's a race here, if another thread/process also
    # performs the same check at the same time
    if settings.status() != QtCore.QSettings.NoError:
        return False
    if settings.value(MARKER_KEY) != value:
        return False
    settings.remove(MARKER_KEY)
    settings.sync()
    return True
项目:ida-settings    作者:williballenthin    | 项目源码 | 文件源码
def __init__(self):
        super(PermissionError, self).__init__("Unable to write to QSettings")
项目:ida-settings    作者:williballenthin    | 项目源码 | 文件源码
def __init__(self, plugin_name, *args, **kwargs):
        super(SystemIDASettings, self).__init__(plugin_name, *args, **kwargs)
        s = QtCore.QSettings(QtCore.QSettings.SystemScope,
                             IDA_SETTINGS_ORGANIZATION,
                             IDA_SETTINGS_APPLICATION)
        s.beginGroup(self._plugin_name)
        self._qsettings = QSettingsIDASettings(s)
项目:ida-settings    作者:williballenthin    | 项目源码 | 文件源码
def __init__(self, plugin_name, *args, **kwargs):
        super(UserIDASettings, self).__init__(plugin_name, *args, **kwargs)
        s = QtCore.QSettings(QtCore.QSettings.UserScope,
                             IDA_SETTINGS_ORGANIZATION,
                             IDA_SETTINGS_APPLICATION)
        s.beginGroup(self._plugin_name)
        self._qsettings = QSettingsIDASettings(s)
项目:ida-settings    作者:williballenthin    | 项目源码 | 文件源码
def get_system_plugin_names():
        """
        Get the names of all plugins at the system scope.
        As this is a static method, you can call the directly on IDASettings:

            import ida_settings
            print( ida_settings.IDASettings.get_system_plugin_names() )

        rtype: Sequence[str]
        """
        return QtCore.QSettings(QtCore.QSettings.SystemScope,
                                IDA_SETTINGS_ORGANIZATION,
                                IDA_SETTINGS_APPLICATION).childGroups()[:]
项目:ida-settings    作者:williballenthin    | 项目源码 | 文件源码
def get_user_plugin_names():
        """
        Get the names of all plugins at the user scope.
        As this is a static method, you can call the directly on IDASettings:

            import ida_settings
            print( ida_settings.IDASettings.get_user_plugin_names() )

        rtype: Sequence[str]
        """
        return QtCore.QSettings(QtCore.QSettings.UserScope,
                                IDA_SETTINGS_ORGANIZATION,
                                IDA_SETTINGS_APPLICATION).childGroups()[:]
项目:ida-settings    作者:williballenthin    | 项目源码 | 文件源码
def get_directory_plugin_names(config_directory=None):
        """
        Get the names of all plugins at the directory scope.
        Provide a config directory path to use this method outside of IDA.
        As this is a static method, you can call the directly on IDASettings:

            import ida_settings
            print( ida_settings.IDASettings.get_directory_plugin_names("/tmp/ida/1/") )

        type config_directory: str
        rtype: Sequence[str]
        """
        ensure_ida_loaded()
        return QtCore.QSettings(get_directory_config_path(directory=config_directory),
                                QtCore.QSettings.IniFormat).childGroups()[:]
项目:ida-settings    作者:williballenthin    | 项目源码 | 文件源码
def import_settings(settings, config_path):
    """
    Import settings from the given file system path to given settings instance.

    type settings: IDASettingsInterface
    type config_path: str
    """
    other = QtCore.QSettings(config_path, QtCore.QSettings.IniFormat)
    for k in other.allKeys():
        settings[k] = other.value(k)
项目:PH5    作者:PIC-IRIS    | 项目源码 | 文件源码
def readSettings(self):
        '''
           Read position and size from QSettings
        '''
        settings = QtCore.QSettings('PH5', 'pforma')
        pos = settings.value('pos', QtCore.QPoint(200, 200))
        size = settings.value('size', QtCore.QSize(400, 400))
        self.move(pos)
        self.resize(size)
项目:PH5    作者:PIC-IRIS    | 项目源码 | 文件源码
def writeSettings(self):
        '''
            Save QSettings
        '''
        settings = QtCore.QSettings('PH5', 'pforma')
        settings.setValue('pos', self.pos())
        settings.setValue('size', self.size())
项目:ebbbe    作者:EarToEarOak    | 项目源码 | 文件源码
def __init__(self):
        self.dirFile = '.'
        self.frequency = 30.

        self._settings = QSettings('Ear to Ear Oak', 'ebbbe')

        self.dirFile = self._settings.value('dirFile', self.dirFile)
        self.frequency = float(self._settings.value('frequency', self.frequency))
项目:KicadSolderTool    作者:pioupus    | 项目源码 | 文件源码
def __init__(self, parent, footprintlist):
        QtGui.QDialog.__init__(self, parent)
        self.owner = parent
        self.combo_param_name = QtGui.QComboBox();
        self.combo_param_name.setEditable(True)
        self.footprint_list = footprintlist
        self.list_widget = PartTreeWidget(self)
        self.list_widget.setColumnCount(4)
        self.btn_load_bom = QtGui.QPushButton("load Field from xml-BOM")
        self.gridlayout = QtGui.QGridLayout()
        self.label = QtGui.QLabel("Field name:")
        self.gridlayout.addWidget(self.label,0,0,1,0)
        self.gridlayout.addWidget(self.btn_load_bom,1,1)
        self.gridlayout.addWidget(self.combo_param_name,1,0)
        self.gridlayout.addWidget(self.list_widget,2,0,1,0)
        self.label.setSizePolicy(QtGui.QSizePolicy.Minimum,QtGui.QSizePolicy.Minimum)
        self.combo_param_name.setSizePolicy(QtGui.QSizePolicy.Minimum,QtGui.QSizePolicy.Minimum)
        self.list_widget.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding,QtGui.QSizePolicy.MinimumExpanding)
        self.param_names = []
        settings = QtCore.QSettings("./KicadSolderTool.ini",QtCore.QSettings.IniFormat)
        size = settings.beginReadArray("param_names")
        for i in range(size):
            settings.setArrayIndex(i)
            self.param_names.append(settings.value("key"))

        settings.endArray()
        self.combo_param_name.addItems(self.param_names)
        self.combo_param_name.setCurrentIndex(int(settings.value("recent_field_name",0)))

        self.setLayout(self.gridlayout)
        for footprint in self.footprint_list:        
            if footprint['bot']:
                caption = 'bot'
            else:
                caption = 'top'
            if footprint['other_side']:
                caption += "(also other side)"
            item = QtGui.QTreeWidgetItem(caption)
            item.setText(0,footprint['ref'])
            item.setText(1,caption)
            item.setText(2,footprint['val'])
            item.setCheckState(0,QtCore.Qt.Unchecked)   

            self.list_widget.addTopLevelItem(item)
        for i in range(self.list_widget.columnCount()):
            self.list_widget.resizeColumnToContents(i);
        self.setMinimumWidth(600)
        self.show()

        self.connect(self.list_widget, QtCore.SIGNAL("itemSelectionChanged()"), self.on_select)
        self.connect(self.btn_load_bom, QtCore.SIGNAL("clicked()"), self.on_load_bom)