[Python] kivy.factory.FactoryException: Unknown class <*classname*>

Discussão em 'Python' iniciado por Stack, Fevereiro 22, 2025.

  1. Stack

    Stack Membro Participativo

    I have checked this problem all over, and with everyone else it seems it's simply a problem of them not having the class on both their KV and Python files, however, I'm still getting this error message with the class on both sides.

    This is a problem in multiple parts of my program, but the most recent one is this: raise FactoryException('Unknown class <%s>' % name) kivy.factory.FactoryException: Unknown class <ShowCurrentMeds>

    Here is my KV for this area:

    <ShowCurrentMeds>:
    name: 'ShowCurrentMeds'
    RecycleDataViewBahavior:
    # scroll layout of buttons
    # shows med


    And my python:

    class ShowCurrentMeds(RecycleDataViewBehavior):
    def currentmeds(self,meds):
    def edit(self, instance):
    EditMedPage.editmed_enter(temp[8])
    ScreenManager.current = 'EditMedPage'
    dates = {1:'Jan', 2:'Feb', 3:'Mar', 4:'Apr', 5:'May', 6:'Jun', 7:'Jul', 8:'Aug', 9:'Sep', 10:'Oct', 11:'Nov', 12:'Dec'}

    meds = MedsPage.meds
    for med in range(len(meds[0])):
    temp = meds[0][med]
    currentmed = DropDown()
    # med name
    currentmed.add_widget(Label(text=temp[0]))
    if temp[1] is not None:
    # brand
    currentmed.add_widget(Label(text=temp[1]))
    if temp[2] is not None:
    # type of med
    currentmed.add_widget(Label(text=temp[2]))
    if temp[3] is not None:
    # explanation
    currentmed.add_widget(Label(text=temp[3]))
    # year
    if temp[4] is not None:
    # month
    if temp[5] is not None:
    # date
    if temp[6] is not None:
    currentmed.add_widget(Label(text='Started '+temp[6]+'/'+temp[5]+'/'+temp[4]))
    currentmed.add_widget(Label(text='Started '+dates.get(temp[5])+' '+temp[4]))
    currentmed.add_widget(Label(text= 'Started '+temp[4]))
    if temp[7] is not None:
    # end date
    currentmed.add_widget(Label(text='Ends '+temp[7]))

    thereisatime = False
    doselayout = GridLayout(cols=2)
    for time in range(len(meds[1])):
    temptime = meds[1][time]
    if temptime[0] == temp[0]:
    thereisatime = True
    doselayout.add_widget(Label(text=temptime[1]))
    # time
    doselayout.add_widget(Label(text=temptime[2]))
    # dose
    if thereisatime:
    currentmed.add_widget(doselayout)

    editbutton = Button(text='Edit')
    editbutton.bind(on_press=edit)
    currentmed.add_widget(editbutton)

    medbutton = Button(text=temp[1])
    medbutton.bind(on_release=currentmed.open)


    which is called by

    class MedsPage(Screen):
    def med_enter(self):
    meds = json.loads(requests.get('http://CyanUnicorn26.eu.pythonanywhere.com/meds/current/main/', json={'SessionID':app.sessionID}).text)
    ShowCurrentMeds.currentmeds(meds)


    With the classes in both sides, I just don't see why that error is still coming up? Thanks in advance, I apologise in advance if it's just a silly error, I have a tendency for them, but considering it's happened with 4 classes-in-screens I think it's a problem with that?

    Continue reading...

Compartilhe esta Página