Created
March 22, 2018 07:41
-
-
Save dolang/104d94853f65a32051a4b276c0062ca8 to your computer and use it in GitHub Desktop.
Test app for Kivy issue #2120
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| https://github.com/kivy/kivy/issues/2120 | |
| Issue was created 2014-04-28. Confirming this has not been fixed yet. | |
| """ | |
| from kivy.logger import Logger | |
| from kivy.app import App | |
| from kivy.lang import Builder | |
| from kivy.uix.boxlayout import BoxLayout | |
| from kivy.uix.button import Button | |
| KV = '''\ | |
| RootLayout: | |
| Button: | |
| id: button1 | |
| text: 'button 1' | |
| on_press: self.id = '1'; root.log_btn_press() | |
| Button: | |
| id: button1 | |
| text: 'button 2' | |
| on_press: self.id = '1'; root.log_btn_press() | |
| ''' | |
| class RootLayout(BoxLayout): | |
| def log_btn_press(self): | |
| # confirmation; always shows: kv widget with id button1 is: button 2 | |
| Logger.info("Test: button pressed. kv widget with id button1 is: " + self.ids.button1.text) | |
| Logger.info("Test: widget walk: %s", '; '.join(map(self._btn_info, self.walk()))) | |
| def _btn_info(self, widget): | |
| if not isinstance(widget, Button): | |
| return str(type(widget)) | |
| # else: | |
| return "{}: text = '{}' id = '{}'".format(type(widget).__name__, widget.text, widget.id) | |
| class MyApp(App): | |
| def build(self): | |
| return Builder.load_string(KV) | |
| if __name__ == '__main__': | |
| MyApp().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment