![]() |
[Kivy] AttributeError: 'NoneType' object has no attribute 'bind' - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: [Kivy] AttributeError: 'NoneType' object has no attribute 'bind' (/thread-25817.html) |
AttributeError: 'NoneType' object has no attribute 'bind' - faszination_92 - Apr-12-2020 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 RE: AttributeError: 'NoneType' object has no attribute 'bind' - faszination_92 - Apr-12-2020 sry still same RE: AttributeError: 'NoneType' object has no attribute 'bind' - Larz60+ - Apr-12-2020 Please always show complete, unaltered error traceback (in error tags) as it contains important information that can be used to isolate cause of error, and call stack prior to failure. |