Changing kv label text with Python code

6 views
Skip to first unread message

Edward Anderson

unread,
Jun 2, 2026, 12:43:39 PM (18 hours ago) Jun 2
to Kivy users support
I have attached the kv and py file for the third screen created through ScreenManager. I am attempting to use StringProperty (marked with ??????????????) and a variable assignment in the load_prb method (marked with ????????????????). The print of the final question variable produces the correct string but the label text is not changed (remains the same as set by the StringProperty function. It seems to have something to do with Setting the variable to a global variable or no action is performed immediately prior to reassigning the variable. All suggestions are appreciared.
solve.kv
solve.py

ElliotG

unread,
Jun 2, 2026, 8:08:33 PM (10 hours ago) Jun 2
to Kivy users support
Let me know if this solves your problem.  If not please share a minimal runnable example.

class Solve(Screen):
    final_question = StringProperty('TEST')
#    def load_prb(q_id):  This is wrong... need self.
    def load_prb(self, q_id):  # This is a class method, self gets passed in 
        ...
        # global final_question       # Delete this
        self.final_question = question   #Kivy properties are accessed as instance variables, use self.
        print('OK222  ', self.final_question)
Reply all
Reply to author
Forward
0 new messages