Skip to content

Instantly share code, notes, and snippets.

@Bakterija
Created April 5, 2017 17:07
Show Gist options
  • Save Bakterija/b2feec023e4e047cb53e4708fda6ddc3 to your computer and use it in GitHub Desktop.
Save Bakterija/b2feec023e4e047cb53e4708fda6ddc3 to your computer and use it in GitHub Desktop.
TextInput crashes in open() method
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()
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