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


Python ConfigParser.getboolean方法代码示例

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


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

示例1: UserPrefs

# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import getboolean [as 别名]

#.........这里部分代码省略.........

                if content_dict.has_key('screens'):
                    self._prefs_dict['screens'] = content_dict['screens']

                if content_dict.has_key('alerts'):
                    for channel, alertrules in content_dict['alerts'].iteritems():
                        self._prefs_dict['alerts'][channel] = AlertRuleCollection.from_dict(alertrules)

        except Exception as e:
            Logger.error('Error loading preferences, using defaults. {}'.format(e))

    def init_pref_section(self, section):
        '''
        Initializes a preferences section with the specified name. 
        if the section already exists, there is no effect. 
        :param section the name of the preference section
        :type string
        '''
        self.config.adddefaultsection(section)

    def get_pref_bool(self, section, option, default=None):
        '''
        Retrieve a preferences value as a bool. 
        return default value if preference does not exist
        :param section the configuration section for the preference
        :type section string
        :param option the option for the section
        :type option string
        :param default
        :type default bool
        :return bool preference value
        '''
        try:
            return self.config.getboolean(section, option)
        except (NoOptionError, ValueError):
            return default

    def get_pref_float(self, section, option, default=None):
        '''
        Retrieve a preferences value as a float. 
        return default value if preference does not exist
        :param section the configuration section for the preference
        :type section string
        :param option the option for the section
        :type option string
        :param default
        :type default float
        :return float preference value
        '''
        try:
            return self.config.getfloat(section, option)
        except (NoOptionError, ValueError):
            return default

    def get_pref_int(self, section, option, default=None):
        '''
        Retrieve a preferences value as an int. 
        return default value if preference does not exist
        :param section the configuration section for the preference
        :type section string
        :param option the option for the section
        :type option string
        :param default
        :type default user specified
        :return int preference value
        '''
开发者ID:autosportlabs,项目名称:RaceCapture_App,代码行数:70,代码来源:prefs.py

示例2: ConfigParser

# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import getboolean [as 别名]
if platform.startswith('win'):
    fname = 'bgm.ini'
else:
    fname = 'bgm_home.ini'

CP = ConfigParser(name='BGM')
CP.read(fname)

gamepath = CP.get('Path', 'gamepath')
if not isdir(gamepath):
    Logger.warn('No Existing Game Path found')
    gamepath = None
else:
    resource_add_path(gamepath)

FORCE_FIT_FORMAT = CP.getboolean('Layout','force_fit_format')

def set_force_fit_format(force):
    CP.set('Layout','force_fit_format',int(force))
    CP.write()
    global FORCE_FIT_FORMAT
    FORCE_FIT_FORMAT = int(force)

def startup_tips(stop):
    CP.set('Startup','startup_tips',stop)
    CP.write()

USE_PROXY = CP.getboolean('Proxy', 'use_proxy')

if USE_PROXY:
    Logger.info('Using Proxy')
开发者ID:opqopq,项目名称:BoardGameMaker,代码行数:33,代码来源:conf.py

示例3: UserPrefs

# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import getboolean [as 别名]

#.........这里部分代码省略.........
        self.set_config_defaults()

        self._prefs_dict = {'range_alerts': {}, 'gauge_settings':{}}

        try:
            with open(self.prefs_file, 'r') as data:
                content = data.read()
                content_dict = json.loads(content)

                if content_dict.has_key("range_alerts"):
                    for name, settings in content_dict["range_alerts"].iteritems():
                        self._prefs_dict["range_alerts"][name] = Range.from_dict(settings)

                if content_dict.has_key("gauge_settings"):
                    for id, channel in content_dict["gauge_settings"].iteritems():
                        self._prefs_dict["gauge_settings"][id] = channel

        except Exception:
            pass

    def get_pref_bool(self, section, option, default=None):
        '''
        Retrieve a preferences value as a bool. 
        return default value if preference does not exist
        :param section the configuration section for the preference
        :type section string
        :param option the option for the section
        :type option string
        :param default
        :type default bool
        :return bool preference value
        '''
        try:
            return self.config.getboolean(section, option)
        except (NoOptionError, ValueError):
            return default

    def get_pref_float(self, section, option, default=None):
        '''
        Retrieve a preferences value as a float. 
        return default value if preference does not exist
        :param section the configuration section for the preference
        :type section string
        :param option the option for the section
        :type option string
        :param default
        :type default float
        :return float preference value
        '''
        try:
            return self.config.getfloat(section, option)
        except (NoOptionError, ValueError):
            return default

    def get_pref_int(self, section, option, default=None):
        '''
        Retrieve a preferences value as an int. 
        return default value if preference does not exist
        :param section the configuration section for the preference
        :type section string
        :param option the option for the section
        :type option string
        :param default
        :type default user specified
        :return int preference value
        '''
开发者ID:ddimensia,项目名称:RaceCapture_App,代码行数:70,代码来源:prefs.py

示例4: getbool

# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import getboolean [as 别名]
 def getbool(self, section, option):
     try:
         return KivyConfigParser.getboolean(self, section, option)
     except NoOptionError:
         self.set(section, option, "off")
         return False
开发者ID:Davideddu,项目名称:karaokivy,代码行数:8,代码来源:plugin_utils.py


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