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


Python ConfigParser.add_section方法代码示例

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


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

示例1: AddCardMenuScreen

# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import add_section [as 别名]
 class AddCardMenuScreen(Screen):
     question = ""
     answer = ""
     def __init__(self):
         Screen.__init__(self)
         self.name = "add"
         
         self.config = ConfigParser()
         self.config.add_section("add")
         self.config.set("add", "question", "Question")
         self.config.set("add", "answer", "Answer")
         self.config.set("add", "make", "action")
         self.config.add_callback(self.update_qa, section="add", key="question")
         self.config.add_callback(self.update_qa, section="add", key="answer")
         self.menu = SettingsWithNoMenu()
         
         
         self.menu.register_type("action", FlashcardAppManager.SettingDoAction)
         self.menu.add_json_panel("Add a card", self.config, os.path.join(os.path.dirname(__file__), 'add_menu.json'))
         
         self.add_widget(self.menu)
         
         
     def update_qa(self, *args):
         FlashcardAppManager.AddCardMenuScreen.question = self.config.get('add', 'question')
         FlashcardAppManager.AddCardMenuScreen.answer = self.config.get('add', 'answer')
开发者ID:kockiya,项目名称:Flashcards,代码行数:28,代码来源:main.py

示例2: update

# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import add_section [as 别名]
    def update(self):
        """
        add data to Category settings

        retrieves data from database for a particular 'catid'
        """
        #/// add data ///

        self.clear_widgets()

        #define structure of fields (like an INI file)
        config = ConfigParser()
        config.add_section('market')
        config.add_section('location')

        #--- set values (needs to come from database)
        #config.set('category','category_name','TestnameID: ' + str(self.catid))
        if self.data == None:
            config.set('market','day','Enter the market DAY here')
            config.set('location','lon','enter longitude here')
            config.set('location','lat','enter latitude here')
            config.set('location','place_name','enter place name here')
            config.set('location','ranking','Ranking here')
            config.set('location','visited',False)
        else:
            config.set('market','day',self.data['day'])

        return config
开发者ID:bulli92,项目名称:mytrip,代码行数:30,代码来源:main.py

示例3: EditCardMenuScreen

# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import add_section [as 别名]
 class EditCardMenuScreen(Screen):
     question = ""
     answer = ""
     nquestion = ""
     nanswer = ""
     EditCardMenuConfig = None
     
     def update_qa(self, *args):
             FlashcardAppManager.EditCardMenuScreen.nquestion = self.config.get('edit', 'nquestion')
             FlashcardAppManager.EditCardMenuScreen.nanswer = self.config.get("edit", "nanswer")
             
     def __init__(self):
         Screen.__init__(self)
         
         self.name = "edit"
         
         self.config = ConfigParser()
         self.config.add_section("edit")
         self.config.set("edit", "question", "Question")
         self.config.set("edit", "answer", "Answer")
         self.config.set("edit", "nquestion", "Question")
         self.config.set("edit", "nanswer", "Answer")
         self.config.set("edit", "edit", "action")
         
         FlashcardAppManager.EditCardMenuScreen.question = self.config.get('edit', 'question')
         FlashcardAppManager.EditCardMenuScreen.answer = self.config.get('edit', 'answer')
         FlashcardAppManager.EditCardMenuScreen.nquestion = self.config.get('edit', 'nquestion')
         FlashcardAppManager.EditCardMenuScreen.nanswer = self.config.get('edit', 'nanswer')
         
         
             
         self.config.add_callback(self.update_qa, section="edit", key="nquestion")
         self.config.add_callback(self.update_qa, section="edit", key="nanswer")
         
         self.menu = SettingsWithNoMenu()
         
         
         self.menu.register_type("action", FlashcardAppManager.SettingDoAction)
         self.menu.add_json_panel("Add a card", self.config, os.path.join(os.path.dirname(__file__), 'edit_menu.json'))
         
         FlashcardAppManager.EditCardMenuScreen.EditCardMenuConfig = self.config
         
         self.add_widget(self.menu)
         
         def on_pre_enter(self, *args):
             FlashcardAppManager.EditCardMenuScreen.question = FlashcardAppManager.deck_widget.deck.get_selected().get_question()
             FlashcardAppManager.EditCardMenuScreen.answer = FlashcardAppManager.deck_widget.deck.get_selected().get_answer()
             self.config.set("edit", "question", FlashcardAppManager.EditCardMenuScreen.question)
             self.config.set("edit", "answer", FlashcardAppManager.EditCardMenuScreen.answer)
开发者ID:kockiya,项目名称:Flashcards,代码行数:51,代码来源:main.py

示例4: MenuScreen

# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import add_section [as 别名]
 class MenuScreen(Screen):
     def __init__(self):
         Screen.__init__(self)
         self.name = 'menu'
         self.config = ConfigParser()
         self.config.add_section("deck")
         self.config.add_section("card")
         self.config.adddefaultsection("menu")
         self.config.set("deck", "start_studying", 1)
         self.config.set("deck", "change_deck_mode", "Normal")
         self.config.set("deck", "show_list", True)
         self.config.set("deck", "undo", True)
         self.config.set("deck", "redo", True)
         self.config.set("card", "add", "")
         self.config.set("card", "edit", True)
         self.config.set("card", "remove", True)
         
         self.config.add_callback(self.check_deck_locks, "deck", "redo")
         self.config.add_callback(self.check_deck_locks, "deck", "undo")
         
         self.config.add_callback(self.check_card_locks, "card", "edit")
         self.config.add_callback(self.check_card_locks, "card", "add")
         
         
         self.menu = SettingsWithNoMenu()
         self.menu.register_type("screen", FlashcardAppManager.SettingNewScreen)
         self.menu.register_type("action", FlashcardAppManager.SettingDoAction)
         self.menu.add_json_panel("Flashcards", self.config, os.path.join(os.path.dirname(__file__), 'menu.json'))
         
         self.add_widget(self.menu)
         
 
     def check_deck_locks(self, section, key, value):
         print(self.config.get(section, key))
     
     def check_card_locks(self, section, key, value):
         print()
开发者ID:kockiya,项目名称:Flashcards,代码行数:39,代码来源:main.py

示例5: cBaseScript

# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import add_section [as 别名]
class cBaseScript(object):
    ''' basic script class to inherit all scrpts from '''
    def __init__(self):
        self.bIsInit                = False
        self.uMyPath                = u''
        self.uScriptName            = u''
        self.uScriptFile            = u''
        self.iMyVersion             = ToIntVersion('1.0.0')
        self.fOrcaVersion           = ToIntVersion('1.0.0')
        self.uType                  = u'Generic'
        self.uSubType               = u'Generic'
        self.aScriptIniSettings     = QueryDict()
        self.oConfigParser          = KivyConfigParser()
        self.uDefaultConfigName     = ""
        self.uConfigFileName        = ""
        self.uSection               = ""

    def RunScript(self, args):
        ''' Dummy '''
        pass

    def Init(self,oParORCA,uScriptName,uScriptFile):
        ''' Initializes the script '''
        self.bIsInit            = True
        self.uScriptName        = uScriptName
        self.uScriptFile        = uScriptFile
        self.uDefaultConfigName = uScriptName

        self.uMyPath            = AdjustPathToOs(oORCA.uScriptsPath+'/'+self.uScriptName)
        if not os.path.exists(self.uMyPath):
            CreateDir(self.uMyPath)
        oORCA.oTheScreen.oLanguage.LoadXmlFile("SCRIPT", uScriptName)

        self.uConfigFileName    = AdjustPathToOs(self.uMyPath+u'/config.ini')
        oRepManagerEntry=cRepManagerEntry()
        oRepManagerEntry.uFileName=uScriptFile
        if oRepManagerEntry.ParseFromSourceFile():
            self.iMyVersion     = oRepManagerEntry.oRepEntry.iVersion
            self.fOrcaVersion   = oRepManagerEntry.oRepEntry.iMinOrcaVersion
            #OrcaVersion defines for what Orca Version the Interface has been developed

        self.ShowDebug(u'Init')
        if not FileExists(self.uConfigFileName):
            self.CreateAndInitializeIniFile()

        oRepManagerEntry=cRepManagerEntry()
        oRepManagerEntry.uFileName=uScriptFile
        if oRepManagerEntry.ParseFromSourceFile():
            self.iMyVersion     = oRepManagerEntry.oRepEntry.iVersion
            self.fOrcaVersion   = oRepManagerEntry.oRepEntry.iMinOrcaVersion
            #OrcaVersion defines for what Orca Version the Script has been developed
        self.ReadConfigFromIniFile(self.uDefaultConfigName)

    def InitializeSection(self,uSection):
        ''' Initializes a section in the config.ini file for the script '''
        self.ReadConfigFromIniFile(uSection)
    def CreateAndInitializeIniFile(self):
        ''' Creates the ini file '''
        self.oConfigParser.add_section(self.uDefaultConfigName)
        self.InitializeSection(self.uDefaultConfigName)
        self.oConfigParser.write()
    def LoadConfig(self):
        ''' loads a config from the ini file '''
        self.oConfigParser.filename=self.uConfigFileName
        if len(self.oConfigParser._sections)==0:
            if FileExists(self.uConfigFileName):
                self.ShowDebug(u'Reading Config File')
                self.oConfigParser.read(self.uConfigFileName)
    def GetConfigJSONStringforSection(self,uSection):
        ''' dummy '''
        return u'{}'

    def ReadConfigFromIniFile(self,uConfigName):
        ''' reads a config from the ini file '''
        self.uSection = uConfigName

        try:
            SetVar('ScriptConfigSection',uConfigName)
            self.LoadConfig()
            oIniDef = json.loads(self.GetConfigJSONStringforSection(uConfigName))

            for oLine in oIniDef:
                uType       = oLine.get("type")
                uKey        = oLine.get("key")
                uDefault    = oLine.get("default")

                if uType == "scrolloptions" or uType == "string":
                    uPre = "u" + uKey
                    self.aScriptIniSettings[uPre]=Config_getdefault(self.oConfigParser,self.uSection, uKey,uDefault)
                elif uType == "numeric" or uType == "numericslider":
                    uPre= "i" + uKey
                    self.aScriptIniSettings[uPre]=ToInt(Config_getdefault(self.oConfigParser,self.uSection, uKey,uDefault))
                elif uType == "numericfloat" :
                    uPre= "f" + uKey
                    self.aScriptIniSettings[uPre]=ToFloat(Config_getdefault(self.oConfigParser,self.uSection, uKey,uDefault))
                elif uType == "bool":
                    uPre = "b" + uKey
                    self.aScriptIniSettings[uPre]=ToBool(Config_getdefault(self.oConfigParser,self.uSection, uKey,uDefault))
                elif uType == "title":
                    pass
#.........这里部分代码省略.........
开发者ID:thica,项目名称:ORCA-Remote,代码行数:103,代码来源:ScriptClass.py


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