1
I’m trying to program a calendar using Python and the module kivy
, but I have a problem that I don’t understand how I can solve:
This is the calendar.py file:
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.screenmanager import ScreenManager, Screen
import calendar
from datetime import datetime
now = datetime.now()
cal = calendar.Calendar()
class Gerenciador(ScreenManager):
pass
class Tarefas(Screen):
def __init__(self,**kwargs):
super().__init__(**kwargs)
for dia in cal.itermonthdays(now.year, now.month):
self.ids.box.add_widget(Tarefa(text=str(dia)))
class Tarefa(BoxLayout):
def __init__(self,text='',**kwargs):
super().__init__(**kwargs)
self.ids.label.text = text
class Window(App):
def build(self):
return Gerenciador()
Window().run()
This is Window.KV:
<Gerenciador>:
Tarefas:
<Tarefas>:
BoxLayout:
orientation:'vertical'
ScrollView:
BoxLayout:
id:box
orientation:'vertical'
size_hint_y:None
height:self.minimum_height
<Tarefa>:
size_hint_y:None
height:200
Label:
id:label
font_size:30
When running, it results in error:
'super' Object has no attribute 'getattr'
Pointing to the line: self.ids.box.add_widget(Tarefa(text=str(dia)))
.