Created
April 5, 2017 17:07
-
-
Save Bakterija/b2feec023e4e047cb53e4708fda6ddc3 to your computer and use it in GitHub Desktop.
TextInput crashes in open() method
This file contains 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
from text_editor import TextEditorPopup | |
from kivy.core.window import Window | |
from kivy.uix.button import Button | |
from kivy.uix.label import Label | |
from kivy.app import App | |
class TApp(App): | |
def build(self): | |
root = Label(text='Press "Enter" to open TextInput') | |
Window.bind(on_key_down=self.on_key_down2) | |
return root | |
def on_key_down2(self, *args): | |
if args[1] == 13: | |
self.open_editor() | |
def open_editor(self): | |
popup = TextEditorPopup(text='') | |
popup.open() | |
app = TApp() | |
app.run() |
This file contains 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
from kivy.properties import StringProperty | |
from kivy.uix.boxlayout import BoxLayout | |
from kivy.uix.popup import Popup | |
from kivy.lang import Builder | |
from kivy.clock import Clock | |
Builder.load_string(''' | |
<TextEditor>: | |
orientation: 'vertical' | |
TextInput: | |
id: input | |
multiline: True | |
font_size: 14 | |
''') | |
class TextEditor(BoxLayout): | |
pass | |
class TextEditorPopup(Popup): | |
text = StringProperty() | |
title = 'Text editor' | |
def __init__(self, **kwargs): | |
super(TextEditorPopup, self).__init__(**kwargs) | |
self.content = TextEditor() | |
def open(self, *args): | |
super(TextEditorPopup, self).open(*args) | |
self.content.ids.input.text = self.text | |
self.content.ids.input.focus = True | |
11 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment