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

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

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

asp.net mvc - breakpoint on javascript in CSHTML? -