Help with referring to a TextInput In my main.py

21 views
Skip to first unread message

Frederik Findsen

unread,
Feb 17, 2018, 2:05:01 PM2/17/18
to Kivy users support
Hello

Very new to both python and Kivy, just trying to figure stuff out.

I am trying to find my TextInput in my main.py. This way I should be able to get the value intered by a user, then make it to a variable so I can manage it.
I should then be able to run the variable through a function and print the return value in my main.kv.

My main issue is that I can't find a way to find my TextInput in my main.py from the main.kv.

It's the TextInput in the "Vilkscreen" widget Screen.


Hoping someone can find a solution for me.
Skærmbillede 2018-02-17 kl. 14.49.04.png
Skærmbillede 2018-02-17 kl. 14.50.04.png

ZenCODE

unread,
Feb 17, 2018, 2:23:04 PM2/17/18
to Kivy users support
It would be much easier to help if you could post the code....

Frederik Findsen

unread,
Feb 17, 2018, 2:46:26 PM2/17/18
to Kivy users support
Here u go.

Help would be appreciated. 
main.kv
main.py

ZenCODE

unread,
Feb 17, 2018, 4:22:53 PM2/17/18
to Kivy users support
So, there might be better ways to do it, but you can start with changing your ScreenManagement kv to:

ScreenManagement:
MainScreen:
VilkScreen:
id: vk_screen
RetScreen:

And then, in your py file

class ScreenManagement(ScreenManager):
def on_current_screen(self, widget, value):
print("on_current_screen")
if self.ids:
print("vinkela: ", self.ids.vk_screen.ids.vinkela.text)

You could make the link more direct. but this shows how to make it available in your ScreenManagent class. Without being able to understand what you are  trying to do (or your variable names), that at least makes it workable?

Frederik Findsen

unread,
Feb 18, 2018, 2:46:42 AM2/18/18
to Kivy users support
It helps a lot! Thanks.

Have a great day!
Reply all
Reply to author
Forward
0 new messages