Creating a Class for another widget in my .kv file

8 views
Skip to first unread message
Assigned to ericis...@gmail.com by me

Eric B

unread,
Mar 9, 2020, 2:11:15 PM3/9/20
to Kivy users support
When I try to make a new class for my RBox widget, it gives me the error: AttributeError: 'RBox' object has no attribute 'test', I have no clue why. I only attached what I think should be the relevant code.
My kivy code:
<RBox@GridLayout>:
cols: 2
text: ''
group: ''
RCheckBox:
id: cb
group: root.group
on_active: root.test()

My python code:
class RBox:
def test(self):
print('test')
class FormScreen(BoxLayout):
    #a bunch of other code that works
class MainApp(App):
def build(self):
return FormScreen()


if __name__ == "__main__":
MainApp().run()

Elliot Garbus

unread,
Mar 9, 2020, 2:24:00 PM3/9/20
to kivy-...@googlegroups.com

If you are going to have attributes in Python, you do not used a dynamic rule.

Change: <RBox@GridLayout>:

To: <RBox>:

 

And

 

Change: class RBox:
to: class RBox(GridLayout):

 

If that does not fix the issue post a small executable example.

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/4cc4f1ba-a313-4620-aac3-5e52d9da83d7%40googlegroups.com.

 

Eric B

unread,
Mar 9, 2020, 2:28:50 PM3/9/20
to Kivy users support
Ok, thanks so much it worked :D, I have been struggling with this for about a week :P

Elliot Garbus

unread,
Mar 9, 2020, 2:29:31 PM3/9/20
to kivy-...@googlegroups.com

😊

 

From: Eric B
Sent: Monday, March 9, 2020 11:28 AM
To: Kivy users support

--

You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages