L
L
lightmanLP2019-09-11 21:09:56
Python
lightmanLP, 2019-09-11 21:09:56

How to change label by id kivy?

There is a small code.

from kivy.lang import Builder
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.button import Button
from kivy.uix.boxlayout import BoxLayout

Builder.load_string("""
<Gex>:
  orientation: 'vertical'
  Button:
    text: 'UwU'
    on_press: root.upd
  Label:
    id: fer
    text: ' '
""")
class Gex(BoxLayout):
 def upd(self):
  self.ids.fer.text = ':<'

class FakeApp(App):
 def build(self):
  return Gex()

FakeApp().run()

I don’t know what I’m doing wrong, but it doesn’t give an error, but it doesn’t change anything either. If you turn to Gex.upd, then he does not find it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Albert, 2019-09-16
@lightmanLP

1. on_press: root.upd()
2.self.ids['fer'].text = ':<'

from kivy.lang import Builder
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.button import Button
from kivy.uix.boxlayout import BoxLayout

Builder.load_string("""
<Gex>:
  orientation: 'vertical'
  Button:
    text: 'UwU'
    on_press: root.upd()
  Label:
    id: fer
    text: ' '
""")
class Gex(BoxLayout):
 def upd(self):
  self.ids['fer'].text = ':<'

class FakeApp(App):
 def build(self):
  return Gex()

FakeApp().run()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question