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

Popular posts from this blog

php - Passing multiple values in a url using checkbox -

compilation - PHP install fails on Ubuntu 14 (make: *** [sapi/cli/php] Error 1) PHP 5.6.20 -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -