AttributeError: super object has no attribute __getattr__

2024/10/13 8:23:06

I've been searching for the solution of this problem over the all internet but I still can't find the right solution. There are lots of generic answers but none of those have solved my problem..

I am trying to build a simple CLOCK app with kivy and python 3.6.4 but every time I run the main.py I get this error:

AttributeError: 'super' object has no attribute 'getattr'

MY MAIN "main.py" FILE IS THIS:

 from kivy.app import Appfrom kivy.clock import Clockfrom kivy.core.text import LabelBasefrom kivy.core.window import Windowfrom kivy.utils import get_color_from_hexfrom time import strftimeclass ClockApp(App):def on_start(self):Clock.schedule_interval(self.update, 0)def update(self, nap):self.root.ids.time.text = strftime('[b]%H[/b]:%M:%S')if __name__ == '__main__':Window.clearcolor = get_color_from_hex('#101216')LabelBase.register(name='Roboto',fn_regular='Roboto-Thin.ttf',fn_bold='Roboto-Medium.ttf')ClockApp().run() 

MY "clock.kv" FILE IS THIS:

 <Label>:font_name: 'Roboto'font_size: 60markup: TrueBoxLayout:orientation: 'vertical'Label:id: timetext: '[b]00[/b]:00:00'

THIS IS THE ERROR THAT APPEARS WHEN I RUN THE "main.py"

[INFO   ] [Logger      ] Record log in C:\Users\Alessandro\.kivy \logs\kivy_18-05-19_4.txt
[INFO   ] [Kivy        ] v1.10.0
[INFO   ] [Python      ] v3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)]
[INFO   ] [Factory     ] 194 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: sdl2
[INFO   ] [OSC         ] using <thread> for socket
[INFO   ] [Window      ] Provider: sdl2
[INFO   ] [GL          ] Using the "OpenGL" graphics system
[INFO   ] [GL          ] GLEW initialization succeeded
[INFO   ] [GL          ] Backend used <glew>
[INFO   ] [GL          ] OpenGL version <b'4.4.0 - Build 20.19.15.4549'>
[INFO   ] [GL          ] OpenGL vendor <b'Intel'>
[INFO   ] [GL          ] OpenGL renderer <b'Intel(R) HD Graphics 5500'>
[INFO   ] [GL          ] OpenGL parsed version: 4, 4
[INFO   ] [GL          ] Shading version <b'4.40 - Build 20.19.15.4549'>
[INFO   ] [GL          ] Texture max size <16384>
[INFO   ] [GL          ] Texture max units <32>
[INFO   ] [Shader      ] fragment shader: <b"WARNING: 0:7: '' :  #version directive missing">
[INFO   ] [Shader      ] vertex shader: <b"WARNING: 0:7: '' :  #version directive missing">
[INFO   ] [Window      ] auto add sdl2 input provider
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
[INFO   ] [Base        ] Start application main loop
[INFO   ] [Base        ] Leaving application in progress...Traceback (most recent call last):File "kivy\properties.pyx", line 836, in kivy.properties.ObservableDict.__getattr__ (kivy\properties.c:12509)KeyError: 'time'During handling of the above exception, another exception occurred:Traceback (most recent call last):File "C:\Users\Alessandro\Desktop\Clock\main.py", line 24, in <module>ClockApp().run()File "C:\Users\Alessandro\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\app.py", line 828, in runrunTouchApp()File "C:\Users\Alessandro\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\base.py", line 504, in runTouchAppEventLoop.window.mainloop()File "C:\Users\Alessandro\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\core\window\window_sdl2.py", line 663, in mainloopself._mainloop()File "C:\Users\Alessandro\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\core\window\window_sdl2.py", line 405, in _mainloopEventLoop.idle()File "C:\Users\Alessandro\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\base.py", line 339, in idleClock.tick()File "C:\Users\Alessandro\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\clock.py", line 581, in tickself._process_events()File "kivy\_clock.pyx", line 367, in kivy._clock.CyClockBase._process_events (kivy\_clock.c:7700)File "kivy\_clock.pyx", line 397, in kivy._clock.CyClockBase._process_events (kivy\_clock.c:7577)File "kivy\_clock.pyx", line 395, in kivy._clock.CyClockBase._process_events (kivy\_clock.c:7498)File "kivy\_clock.pyx", line 167, in kivy._clock.ClockEvent.tick (kivy\_clock.c:3490)File "C:\Users\Alessandro\Desktop\Clock\main.py", line 16, in updateself.root.ids.time.text = strftime('[b]%H[/b]:%M:%S')File "kivy\properties.pyx", line 839, in kivy.properties.ObservableDict.__getattr__ (kivy\properties.c:12654)AttributeError: 'super' object has no attribute '__getattr__'
Answer

The structure of your .kv does not look correct, for example it is observed that there are many roots that would cause you another problem, so if you want a response that tells you the reason for your problem you should improve your indentation.

Instead I'll show you a correct .kv where the root will be the BoxLayout and your child the Label with id time:

clock.kv

<Label>:font_name: 'Roboto'font_size: 60markup: TrueBoxLayout:orientation: 'vertical'Label:id: timetext: '[b]00[/b]:00:00'

main.py

from kivy.app import App
from kivy.clock import Clock
from kivy.core.text import LabelBase
from kivy.core.window import Window
from kivy.utils import get_color_from_hex
from time import strftimeclass ClockApp(App):def on_start(self):Clock.schedule_interval(self.update, 0)def update(self, *args):self.root.ids.time.text = strftime('[b]%H[/b]:%M:%S')if __name__ == '__main__':Window.clearcolor = get_color_from_hex('#101216')LabelBase.register(name='Roboto', fn_regular='Roboto-Thin.ttf', fn_bold='Roboto-Medium.ttf')ClockApp().run() 

enter image description here

https://en.xdnf.cn/q/118103.html

Related Q&A

Selenium load time errors - looking for possible workaround

I am trying to data scrape from a certain website. I am using Selenium so that I can log myself in, and then start parsing through data. I have 3 main errors:Last page # not loading properly. here I am…

How to POST ndb.StructuredProperty?

Problem:I have following EndpointsModels,class Role(EndpointsModel):label = ndb.StringProperty()level = ndb.IntegerProperty()class Application(EndpointsModel):created = ndb.DateTimeProperty(auto_now_ad…

Issue computing difference between two csv files

Im trying to obtain the difference between two csv files A.csv and B.csv in order to obtain new rows added in the second file. A.csv has the following data.acct ABC 88888888 99999999 ABC-G…

How do I display an extremly long image in Tkinter? (how to get around canvas max limit)

Ive tried multiple ways of displaying large images with tkinterreally long image No matter what Ive tried, there doesnt seem to be any code that works. The main issue is that Canvas has a maximum heigh…

NoneType has no attribute IF-ELSE solution

Im parsing an HTML file and searching for status of order in it. Sometimes, status doesnt exist, so BeautifulSoup returns NoneType, when Im using it. To solve this problem I use if-else statement, but …

looking for an inverted heap in python

Id like to comb off the n largest extremes from a timeseries. heapq works perfectly for the nlargestdef nlargest(series, n):count = 0heap = []for e in series:if count < n:count+=1hp.heappush(heap, e…

Concatenating Multiple DataFrames with Non-Standard Columns

Is there a good way to concatenate a list of DataFrames where the columns are not regular between DataFrames? The desired outcome is to match up all columns that are a match but to keep the ones that …

Python Conditionally Add Class to td Tags in HTML Table

I have some data in the form of a csv file that Im reading into Python and converting to an HTML table using Pandas.Heres some example data:name threshold col1 col2 col3 A 10 12 9 13…

Sort a dictionary of dictionaries python

I have a dictionary of dictionaries like the followingd = {hain: {facet: 1, wrapp: 1, chinoiserie: 1}, library: {sconc: 1, floor: 1, wall: 2, lamp: 6, desk: 1, table: 1, maine: 1} }So, I want to rever…

How can I get python generated excel document to correctly calculate array formulas

I am generating some excel files with python using python 3.6 and openpyxl.At one point I have to calculate standard deviations of a subsection of data. In excel this is done with an array formula. Wri…