Help with kivy (error: Attributeerror: 'weakref' Object has no attribute 'cline_in_traceback')

Asked

Viewed 217 times

1

I’m learning the kivy (so I’m pretty virgin in the Gui subject) and I came across this mistake:

important part: Attributeerror: 'weakref' Object has no attribute 'cline_in_traceback'

full run:

[INFO   ] [Logger      ] Record log in /home/albuquerque/.kivy/logs/kivy_19-04-21_53.txt
[INFO   ] [Kivy        ] v1.11.0.dev0, git-eec3a30, 20190421
[INFO   ] [Python      ] v3.6.7 (default, Oct 22 2018, 11:32:17) 
[GCC 8.2.0]
[INFO   ] [Factory     ] 184 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: sdl2
[INFO   ] [Window      ] Provider: sdl2(['window_egl_rpi'] ignored)
[INFO   ] [GL          ] Using the "OpenGL" graphics system
[INFO   ] [GL          ] Backend used <sdl2>
[INFO   ] [GL          ] OpenGL version <b'4.6.0 NVIDIA 390.116'>
[INFO   ] [GL          ] OpenGL vendor <b'NVIDIA Corporation'>
[INFO   ] [GL          ] OpenGL renderer <b'GeForce GT 730M/PCIe/SSE2'>
[INFO   ] [GL          ] OpenGL parsed version: 4, 6
[INFO   ] [GL          ] Shading version <b'4.60 NVIDIA'>
[INFO   ] [GL          ] Texture max size <16384>
[INFO   ] [GL          ] Texture max units <32>
[INFO   ] [Window      ] auto add sdl2 input provider
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
 Traceback (most recent call last):
   File "kivy/properties.pyx", line 840, in kivy.properties.ObservableDict.__getattr__
 KeyError: 'box'

 During handling of the above exception, another exception occurred:

 Traceback (most recent call last):
   File "main.py", line 19, in <module>
     Test().run()#O método run() inicializa o app
   File "/home/albuquerque/.local/lib/python3.6/site-packages/kivy/app.py", line 829, in run
     root = self.build()
   File "main.py", line 16, in build
     return Tarefas(["a","b", "c"])
   File "main.py", line 10, in __init__
     self.ids.box.add_widget(Label(text=tarefa, font_size=30))#procura nos ids da classe no arquivo text.kv o id box
   File "kivy/properties.pyx", line 843, in kivy.properties.ObservableDict.__getattr__
 AttributeError: 'super' object has no attribute '__getattr__'
Exception ignored in: functools.partial(<function _widget_destructor at 0x7f5c199612f0>, 3)
Traceback (most recent call last):
  File "/home/albuquerque/.local/lib/python3.6/site-packages/kivy/uix/widget.py", line 265, in _widget_destructor
  File "/home/albuquerque/.local/lib/python3.6/site-packages/kivy/lang/builder.py", line 760, in unbind_widget
  File "kivy/weakproxy.pyx", line 32, in kivy.weakproxy.WeakProxy.__getat

the interface screen does not even open

below are the codes:

main py.

from kivy.app import * #importar os métodos de APPP do kivy
from kivy.uix.boxlayout import BoxLayout #empilha os widgets como se fossem caixas
from kivy.uix.label import Label
from kivy.uix.scrollview import ScrollView

class Tarefas(ScrollView):
    def __init__(self, tarefas, **kwargs): #keyword arguments, o incrivel é que ele executa os argumentos colocados a mais
        super().__init__(**kwargs)#chama as funções da classe BoxLayout
        for tarefa in tarefas:
            self.ids.box.add_widget(Label(text=tarefa, font_size=30))#procura nos ids da classe no arquivo text.kv o id box


class Test(App):#primeiro arquivo que o kivy procura (no caso, Text.kv)

    def build(self): #Métod o que constroi o aplicativo
        return Tarefas(["a","b", "c"])


Test().run()#O método run() inicializa o app

test.Kv

<Tarefas>:
    BoxLayout:
        id:box #identificação do widget
        orientation:"vertical"
        size_hint_y:None
        height:self.minimum_height

I’m kind of desperate, so if you can help me, I’m desperately grateful :D:

1 answer

1


You need to import the Kv file.

from kivy.lang import Builder

Builder.load_file('test.kv')
  • I really appreciate your reply, friend. How should I write the second line of your code (Builder.load_file('test.Kv')) in my code? within the Tasks class or external code?

  • I believe the problem is not that, since in the kivy documentation it says that it knows . Kv if it has the class name and such

  • Yes, it does, but the class and main.py have to be called Testapp and Kv has to be called Test.Kv.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.