How do I solve this code in kivy python

0

I'm trying to schedule a calendar using python and the kivy module, but I'm having a problem that I do not 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 the error 'super' object has no attribute ' getattr ' pointing to the line self.ids.box.add_widget (Task (text = str (day) br> Please help me !!

    
asked by anonymous 06.04.2018 / 16:01

1 answer

0
Hello, looking at your for every day of the month I got several zeros, did not test running on kivy, but try this way to observe if the error persists. Abs

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)
        dias = [str(dia) for dia in cal.itermonthdays(now.year, now.month) if dia]
        for dia in dias:
            self.ids.box.add_widget(Tarefa(text=dia))

class Tarefa(BoxLayout):
    def __init__(self,text=False,**kwargs):
        super().__init__(**kwargs)
        if text:
            self.ids.label.text = text

class Window(App):
    def build(self):
        return Gerenciador()

Window().run()
    
18.04.2018 / 06:54