python - How can I have a button in Kivy that when pressed, creates a label? -
i make button when pressed, label appears.
simply define function creates label , assign button's on_press event. consider following code:
from kivy.uix.label import label kivy.uix.button import button kivy.uix.gridlayout import gridlayout kivy.app import app layout = gridlayout(cols = 1) mybtn = button(on_press = myfunction) layout.add_widget(mybtn) def myfunction(): mylabel = label(text = "this label") layout.add_widget(mylabel) class myapp(app): def build(self): return mylayout if __name__ == '__main__': myapp().run()
all of this, however, covered in kivy documentation, comprehensive , has examples. before anything, should hang of reading , trying out examples yourself.
Comments
Post a Comment