python 2.7 - getting input from kivy textinput -


i want use later project, want print user's input textinput clicking button on mainscreen, when run , click on button text "print text" nothing happens no errors , no output.

the .kv file:

#: import fadetransition kivy.uix.screenmanager.fadetransition  screenmanagement:     transition: fadetransition()     mainscreen:     secondscreen:  <mainscreen>:     name: "main"     button:         on_release: root.get_text         text: "print text"         font_size: 50         size_hint:0.3,0.1      textinput:         text:"hello world"         size_hint: 0.35,0.25         pos_hint:{"right":1, "top":1}         color:1,0,0,1         id: user_text      button:             color: 0,1,0,1             font_size: 25             size_hint: 0.3,0.25             text: "continue"             on_release: app.root.current = "other"             pos_hint:{"right":1, "top":0}   <secondscreen>:     name: "other"     floatlayout:         button:             color: 0,1,0,1             font_size: 25             size_hint: 0.3,0.25             text: "back home"             on_release: app.root.current = "main"             pos_hint:{"right":1, "top":1} 

the python code:

from kivy.app import app #kivy.require("1.9.1") kivy.lang import builder kivy.uix.screenmanager import screenmanager, screen , fadetransition kivy.uix.widget import widget  kivy.graphics import line kivy.uix.textinput import textinput  class mainscreen(screen):     def get_text(self,*args):         textinput= self.ids.user_text         user=  textinput.text         print(user)    class secondscreen(screen):     pass  class screenmanagement(screenmanager):     pass   gui = builder.load_file("main.kv")   class mainapp(app):   def build(self):     return gui   mainapp().run()    

when code in kv, bind directly if you'd call function e.g.

on_release: do_this() 

but did without parenthesis if casual python binding:

self.bind(on_release=do_this) 

add parenthesis , should print:

on_release: root.get_text() 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -