#-*- coding: utf-8 -*-
from kivy.lang import Builder
Builder.load_string("""
<TextWidget>:
	BoxLayout:
		orientation: 'vertical'
		size: root.size
		TextInput:
			text: root.text
		Button:
			id: button1
			text: "OK"
			font_size: 48
			on_press: root.buttonClicked()
""")
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.properties import StringProperty 
class TextWidget(Widget):
	text = StringProperty()
	def __init__(self, **kwargs):
		super(TextWidget, self).__init__(**kwargs)
		self.text = ''
	def buttonClicked(self):
		for i in range(5):
			self.text += str(i) + '\n'
class TestApp(App):
	def __init__(self, **kwargs):
		super(TestApp, self).__init__(**kwargs)
		self.title = 'greeting'
	def build(self):
		return TextWidget()
if __name__ == '__main__':
	TestApp().run()
The code is mostly a quote from what is written in the following articles. https://qiita.com/dario_okazaki/items/7892b24fcfa787faface
How do I combine the kv file and the python file into one? It's getting dull to google every time, so make a note for yourself
Recommended Posts