本文整理汇总了Python中Configuration.Configuration.get_option方法的典型用法代码示例。如果您正苦于以下问题:Python Configuration.get_option方法的具体用法?Python Configuration.get_option怎么用?Python Configuration.get_option使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Configuration.Configuration
的用法示例。
在下文中一共展示了Configuration.get_option方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LMS
# 需要导入模块: from Configuration import Configuration [as 别名]
# 或者: from Configuration.Configuration import get_option [as 别名]
class LMS(Widget):
error_window_height = NumericProperty(10)
font_size = NumericProperty(14)
files = ListProperty([None, ])
def __init__(self):
super(LMS, self).__init__()
self.configuration = Configuration()
self.lexer = SMLLexer(self.configuration)
self.parser = SMLParser(self.configuration)
self.config_popup = ConfigPopup(self)
self._keyboard = Window.request_keyboard(self._keyboard_closed, self)
self._keyboard.bind(on_key_down=self._on_keyboard_down)
ewh = self.configuration.get_option('GUI_Error_Window_Height')
if ewh:
ewh.set_prop(self.error_window_height)
#Clock.schedule_once(self.initialize, 10)
def initialize(self, time):
print dir(self)
print self.font_size
print self.config_popup.font_size
self.error_window_height = 100
def _keyboard_closed(self):
pass
def _on_keyboard_down(self, keyboard, keycode, text, modifiers):
if keycode[0] == 286: # F5
self.parse()
return False
def parse(self):
tokens = self.lexer.lex(str(self.code_input.text))
print tokens
self.parser.clear()
ASTToplevel, position = self.parser.parse(tokens)
print str(ASTToplevel), position
nodes = []
ASTToplevel.traverse(lambda x: (nodes.append(x) if x.is_expression else None),
pred_recurse = lambda x: x not in nodes)
self.expression_list.clear_widgets()
for node in nodes:
self.expression_list.add_widget(Button(text='%s' % str(node), background_color=[.2, .2, .2, 1]))
node= nodes[0]
i = self.expression_tree_image_area.size[1]
self.expression_tree_image_area.add_widget(Label(text=node.get_token_text(), pos=(self.expression_tree_image_area.size[0]/2, i)))
for child in node.children:
i-=20
self.expression_tree_image_area.add_widget(Label(text=child.get_token_text(), pos=(self.expression_tree_image_area.size[0]/2, i)))
print self.expression_list.children
print nodes
def traverse_ast(self, node, predicate, recurse = True):
nodes = []
for child in node.children:
if predicate(child):
nodes.append(child)
if recurse:
nodes += self.traverse_ast(child, predicate, recurse)
else:
nodes += self.traverse_ast(child, predicate, recurse)
return nodes
def on_font_size(self, instance, value):
self.code_input.font_size = value
def _open_config(self):
self.config_popup.open()
def _update_size(self, instance, size):
self.code_input.font_size = float(size)
def _update_font(self, instance, fnt_name):
instance.font_name = self.code_input.font_name =\
fonts.match_font(fnt_name)
def _file_menu_selected(self, instance, value):
if value == 'File':
return
instance.text = 'File'
if value == 'Open':
if not hasattr(self, 'load_dialog'):
self.load_dialog = LoadDialog()
self.load_dialog.open()
self.load_dialog.bind(choosen_file=self.setter('files'))
elif value == 'SaveAs':
if not hasattr(self, 'saveas_dialog'):
self.saveas_dialog = SaveDialog()
self.saveas_dialog.text = self.code_input.text
self.saveas_dialog.open()
elif value == 'Save':
if self.files[0]:
_file = codecs.open(self.files[0], 'w', encoding='utf8')
#.........这里部分代码省略.........