From cc675849066ce8b84c4bfcacc73804048582af94 Mon Sep 17 00:00:00 2001 From: qua-non Date: Sat, 15 Dec 2012 09:11:20 +0530 Subject: [PATCH] Example:KivyCatalog make call to change_kv on ctrl+s use absolute path instead of relaive. Make error handeling consistent --- examples/demo/kivycatalog/kivycatalog.kv | 1 + examples/demo/kivycatalog/main.py | 26 +++++++++--------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/examples/demo/kivycatalog/kivycatalog.kv b/examples/demo/kivycatalog/kivycatalog.kv index 6b07414a2..929d26b3d 100644 --- a/examples/demo/kivycatalog/kivycatalog.kv +++ b/examples/demo/kivycatalog/kivycatalog.kv @@ -116,6 +116,7 @@ ScrollView: id: kr_scroll KivyRenderTextInput: + catalog: root id: language_box lexer: KivyLexer() size_hint: 1, None diff --git a/examples/demo/kivycatalog/main.py b/examples/demo/kivycatalog/main.py index ce737f68d..b667f79af 100644 --- a/examples/demo/kivycatalog/main.py +++ b/examples/demo/kivycatalog/main.py @@ -17,8 +17,6 @@ from kivy.clock import Clock CATALOG_ROOT = os.path.dirname(__file__) -print Config.get('graphics', 'width') - Config.set('graphics', 'width', '1024') Config.set('graphics', 'height', '768') @@ -69,7 +67,7 @@ class KivyRenderTextInput(CodeInput): # This allows *either* ctrl *or* cmd, but not both. if modifiers == ['ctrl'] or (is_osx and modifiers == ['meta']): if key == ord('s'): - self.parent.parent.parent.change_kv(True) + self.catalog.change_kv(True) return super(KivyRenderTextInput, self)._keyboard_on_key_down( @@ -142,20 +140,16 @@ class Catalog(BoxLayout): Builder._apply_rule(widget, parser.root, parser.root) kv_container.add_widget(widget) except (SyntaxError, ParserException) as e: - self.info_label.text = str(e) - self.anim = Animation(top=190.0, opacity=1, d=2, t='in_back') +\ - Animation(top=190.0, d=2) +\ - Animation(top=0, opacity=0, d=2) - self.anim.start(self.info_label) - except: - import traceback - traceback.print_exc() - popup = Popup(title="Boom", - content=Label(text='Something horrible happened while parsing' - + 'your Kivy Language', text_size=(350, None), - size_hint=(None, None), size=(400, 400))) - popup.open() + self.show_error(e) + except Exception, e: + self.show_error(e) + def show_error(self, e): + self.info_label.text = str(e) + self.anim = Animation(top=190.0, opacity=1, d=2, t='in_back') +\ + Animation(top=190.0, d=3) +\ + Animation(top=0, opacity=0, d=2) + self.anim.start(self.info_label) class KivyCatalogApp(App): '''The kivy App that runs the main root. All we do is build a catalog