本文整理汇总了Python中kivy.config.ConfigParser.add_callback方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigParser.add_callback方法的具体用法?Python ConfigParser.add_callback怎么用?Python ConfigParser.add_callback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.config.ConfigParser
的用法示例。
在下文中一共展示了ConfigParser.add_callback方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AddCardMenuScreen
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import add_callback [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')
示例2: EditCardMenuScreen
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import add_callback [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)
示例3: MenuScreen
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import add_callback [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()