I want to make a "notes board" app where you can type in multiple inputs and be able to drag them around in the label, is this possible using Kivy, or is it not meant for such purposes?
So far I am able to type one string into the label, but when I try to move it around, the TextInput and button move to the middle of the screen. I am not sure if I am using Scatter correctly.
I am also using two BoxLayouts because I was having a hard time resizing/ anchoring the TextInput and Button with others
import kivy
from kivy.app import App
from kivy.properties import ObjectProperty
from kivy.uix.label import Label
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.textinput import TextInput
from kivy.uix.scatter import Scatter
from kivy.uix.widget import Widget
class MyLayout(Widget):
txt_input = ObjectProperty(None)
txt_output = ObjectProperty(None)
def press(self):
todo = self.txt_input.text
# update label
self.txt_output.text = todo
class MainApp(App):
def build(self):
return MyLayout()
if __name__ == "__main__":
MainApp().run()
--
#:kivy 2.0.0
<MyLayout>:
txt_input: txt_input
txt_output: txt_output
BoxLayout:
orientation: 'vertical'
size: root.width, root.height
Scatter:
Label:
id: txt_output
font_size: 150
BoxLayout:
cols: 2
TextInput:
pos: (0,0)
id: txt_input
size_hint_x: .8
size_hint_y: None
font_size: 150
Button:
pos: (1278,0)
size_hint_x: .2
size_hint_y: None
text: "add"
on_press: root.press()
Thanks in advance!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…