Skip to content
Advertisement

How to reference widgets inside widgets using IDs in Kivy, Kivy Lang, Kivy MD

okay, THIS HAS BEEN DRIVING ME INSANE FOR LIKE THE PAST TWO DAYS. and its really annoying, so i am building an application using kivy, after getting used “easy as pie” tkinter I thought it was time to learn kivy (as it has mobile compatibility).

#I wanted to learn to reference different widgets# I searched YouTube and google for hours but to no avail I keep getting an error message

my code:

.py

JavaScript

.kv

JavaScript

and

my error

JavaScript

P.S: THE ERROR ONLY SHOWS AFTER I HAVE PRESSED THE BUTTON

please help, thanks in advance, to who ever took the time to read my post

Advertisement

Answer

In order to use ids, you must define the id within your kv. So, to use the raw_search id you must define it in your kv like this:

JavaScript

Then in your code:

JavaScript

Note that the ids dictionary is built within the widget that is the root of the rule containing the id. In your case, the ids are in the GridLayout. So, to access that GridLayout widget, you must use self.a. Also, I assumed that the <HyperSearch>: line in your kv was a typo and removed it.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement