Python Forum
[Kivy] AttributeError setting the label text
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Kivy] AttributeError setting the label text
#1
Hi All,
I receive this error message when I try to set an input text value to a label text.

self.b5.text="You wrote " + self.username.txt
AttributeError: 'LoginScreen' object has no attribute 'b5'

This is the Python code.
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button 

class LoginScreen(GridLayout):

    def buttonClicked(self, instance):
        self.b4.text="You wrote " + self.username.text

    def __init__(self, **kwargs):
       super(LoginScreen, self).__init__(**kwargs)
       self.cols = 1
       
       self.add_widget(Label(text="Hello"))
       self.username = TextInput(multiline=True)
       self.add_widget(self.username)
       
       b1=(Button(text="Find"))
       self.add_widget(b1)
       b1.bind(on_press=self.buttonClicked)

       b4=(Label(text="Answer:"))
       self.add_widget(b4)

       b5=(Label(text=''))
       self.add_widget(b5)

class SimpleKivy(App):
   def build(self):
       return LoginScreen()

if __name__ == "__main__":
    SimpleKivy().run()
Any help will be greatly appreciated.
Thanks in advance for your kind support.

Regards,
Giovanni
Reply


Messages In This Thread
AttributeError setting the label text - by gio123 - Mar-14-2018, 09:24 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] The Text in the Label widget Tkinter cuts off the Long text in the view malmustafa 4 4,960 Jun-26-2022, 06:26 PM
Last Post: menator01
  [PyQt] AttributeError: 'NoneType' object has no attribute 'text' speedev 9 11,485 Sep-25-2021, 06:14 PM
Last Post: Axel_Erfurt
  update text variable on label with keypress knoxvilles_joker 3 4,954 Apr-17-2021, 11:21 PM
Last Post: knoxvilles_joker
  How to read text in kivy textinput or Label jadel440 1 5,289 Dec-29-2020, 10:47 AM
Last Post: joe_momma
  [Kivy] Kivy text label won't shows up! AVD_01 1 2,949 Jun-21-2020, 04:01 PM
Last Post: AVD_01
  [Tkinter] Python 3 change label text gw1500se 6 4,734 May-08-2020, 05:47 PM
Last Post: deanhystad
  [Tkinter] how to update label text from list Roshan 8 5,482 Apr-25-2020, 08:04 AM
Last Post: Roshan
  [PyQt] Python PyQt5 - Change label text dynamically based on user Input ppel123 1 13,803 Mar-20-2020, 07:21 AM
Last Post: deanhystad
  [Tkinter] Help setting text/title in dock/panel in tkinter gui FluxApex 2 4,432 Mar-18-2020, 07:15 PM
Last Post: FluxApex
  [Tkinter] Label, align imported text from pandas kundrius 2 4,247 Dec-11-2019, 08:26 AM
Last Post: kundrius

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020