main.py
#-*- coding: utf-8 -*-
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.properties import NumericProperty
class TestWidget(Widget):
testTextInput2_Opacity = NumericProperty()
testTextInput2_size_hint_y = NumericProperty()
show_hide = 0
def __init__(self, **kwargs):
super(TestWidget, self).__init__(**kwargs)
self.testTextInput2_Opacity = 1
self.testTextInput2_size_hint_y = 0.2
def buttonClicked(self):
if self.show_hide == 0:
self.ids.box.remove_widget(self.ids.testTextInput2)
self.ids.box.add_widget(self.ids.testTextInput2, 0)
self.testTextInput2_Opacity = 0
self.show_hide = 1
else:
self.ids.box.remove_widget(self.ids.testTextInput3)
self.ids.box.add_widget(self.ids.testTextInput3, 0)
self.testTextInput2_Opacity = 1
self.show_hide = 0
class TestApp(App):
def __init__(self, **kwargs):
super(TestApp, self).__init__(**kwargs)
def build(self):
return TestWidget()
if __name__ == '__main__':
TestApp().run()
test.kv
#-*- coding: utf-8 -*-
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.properties import NumericProperty
class TestWidget(Widget):
testTextInput2_Opacity = NumericProperty()
testTextInput2_size_hint_y = NumericProperty()
show_hide = 0
def __init__(self, **kwargs):
super(TestWidget, self).__init__(**kwargs)
self.testTextInput2_Opacity = 1
self.testTextInput2_size_hint_y = 0.2
def buttonClicked(self):
if self.show_hide == 0:
self.ids.box.remove_widget(self.ids.testTextInput2)
self.ids.box.add_widget(self.ids.testTextInput2, 0)
self.testTextInput2_Opacity = 0
self.show_hide = 1
else:
self.ids.box.remove_widget(self.ids.testTextInput3)
self.ids.box.add_widget(self.ids.testTextInput3, 0)
self.testTextInput2_Opacity = 1
self.show_hide = 0
class TestApp(App):
def __init__(self, **kwargs):
super(TestApp, self).__init__(**kwargs)
def build(self):
return TestWidget()
if __name__ == '__main__':
TestApp().run()
これで中間の要素をshow/hideできる
なんかあんまり使い方がしっくりこない
自分用メモ