Python Forum
[Kivy] AttributeError: 'NoneType' object has no attribute 'bind'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Kivy] AttributeError: 'NoneType' object has no attribute 'bind'
#1
Hey guys, I'm pretty new at coding kivy and think one of you could help me with a simple solution. I want to include the variable named [show_text] into my [Label] , [text] at the [main.kv]. right now i get the Message:


BuilderException: Parser: File "C:\Users\Lukas\PycharmProjects\test_app\main.kv", line 57:
...
55: pos_hint: {"top": 1, "left": 2}
56: size_hint: 1, .7
>> 57: text: app.show_text
58: id: aufgaben_player
...
AttributeError: 'NoneType' object has no attribute 'bind'



Thanks for helping me!


main.py
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.button import ButtonBehavior
from kivy.uix.image import Image
from kivy.uix.screenmanager import Screen, ScreenManager
from kivy.properties import StringProperty, ObjectProperty
import random
from karten import *

class WindowManager(ScreenManager):
    home_screen = ObjectProperty(None)
    game_text_screen = ObjectProperty(None)

class ImageButton(ButtonBehavior, Image):
    pass

class HomeScreen(Screen):
    pass

class GameText(Screen):
    pass

kv = Builder.load_file("main.kv")

class MainApp(App):
    show_text = StringProperty()

    def build(self):
        return kv

    def show_game_text_first(self):
        show_text = Karten[random.randint(0, 2)]
        print(show_text)

if __name__ == "__main__":
    MainApp().run()
main.kv

#:import utils kivy.utils

WindowManager:

    HomeScreen:
        name: "home_screen"
        FloatLayout:
            canvas:
                Color:
                    rgb: utils.get_color_from_hex("#3983F2")
                Rectangle:
                    size: self.size
                    pos: self.pos

            Label:
                pos_hint: {"top": 0.7, "left": 1}
                size_hint: 1, .1
                text: "Schere Stein Papier"
                font_size: min(root.height, root.width)/15
                id: title_label

            GridLayout:
                rows: 1
                pos_hint: {"top": .2, "left": 5}
                size_hint: 1, .1

                ImageButton:
                    source: "icons/weiter.png"
                    on_press:
                        self.source = "icons/weiterhell.png"
                    on_release:
                        self.source = "icons/weiter.png"
                        app.root.current = "game_text_screen"
                        app.show_game_text_first()


    GameText:
        name: "game_text_screen"
        FloatLayout:
            canvas:
                Color:
                    rgb: utils.get_color_from_hex("#3983F2")
                Rectangle:
                    size: self.size
                    pos: self.pos

            Label:
                pos_hint: {"top": 1, "left": 1}
                size_hint: 1, .1
                text: "Schere Stein Papier"
                font_size: min(root.height, root.width)/15
                id: title_label

            Label:
                pos_hint: {"top": 1, "left": 2}
                size_hint: 1, .7
                text: app.show_text
                id: aufgaben_player
Reply


Messages In This Thread
AttributeError: 'NoneType' object has no attribute 'bind' - by faszination_92 - Apr-12-2020, 01:43 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  'NoneType' object has no attribute 'get' zunebuggy 8 8,377 Oct-13-2023, 06:39 PM
Last Post: zunebuggy
  tkinter AttributeError: 'GUI' object has no attribute pfdjhfuys 3 4,838 May-18-2023, 03:30 PM
Last Post: pfdjhfuys
  [Kivy] Windows 10: AttributeError: 'WM_PenProvider' object has no attribute 'hwnd' mikepy 1 3,720 Feb-20-2023, 09:26 PM
Last Post: deanhystad
  [Tkinter] Can't update label in new tk window, object has no attribute tompranks 3 5,821 Aug-30-2022, 08:44 AM
Last Post: tompranks
  [Tkinter] bind menator01 1 1,997 Apr-15-2022, 08:47 PM
Last Post: menator01
  How to move in entries using the arrow keys by applying the bind and focus? pymn 4 9,863 Apr-06-2022, 04:29 AM
Last Post: pymn
  AttributeError: 'NoneType' object has no attribute 'get' George87 5 24,634 Dec-23-2021, 04:47 AM
Last Post: George87
  [PyQt] AttributeError: 'NoneType' object has no attribute 'text' speedev 9 15,674 Sep-25-2021, 06:14 PM
Last Post: Axel_Erfurt
  [Tkinter] bind lambda keypress counter knoxvilles_joker 15 11,612 Apr-19-2021, 01:56 AM
Last Post: knoxvilles_joker
  [Tkinter] AttributeError: '' object has no attribute 'tk' Maryan 2 18,986 Oct-29-2020, 11:57 PM
Last Post: Maryan

Forum Jump:

User Panel Messages

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