<BackgroundColour@Widget>:
background_color: 0, 0, 0, 0
canvas.before:
Color:
rgba: root.background_color
Rectangle:
size: self.size
pos: self.pos
<Border@Widget>:
border_color: 0, 0, 0, 0
border_width: 1
canvas.before:
Color:
rgba: root.border_color
Line:
width: root.border_width
rectangle: self.x, self.y, self.width, self.height
<MyLabel@Label+BackgroundColour+Border>
Is there a way now to reference that MyLabel class in Python code without having to move the BackgroundColour and Border functionality to Python (which I don't want to do because writing canvas.before and binding properties in Python is a pain)?
I’m not sure I completely understand your objective, there are a number of ways to move between KV and the Python code.
I have attached a KV file and a py file. Apologies for the colors, they were the result of random choices.
Key concept, you can simply declare the class in python
class BackgroundColour(Widget):
pass
and define the style in kv:
<BackgroundColour>:
canvas.before:
Color:
rgba: root.bg_color
Rectangle:
size: self.size
pos: self.pos
Doing this bridges the name space letting you use the names in both KV and Python.
Let me know if the attached code answers your question.
--
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/d91a3024-7fec-4ab8-99ff-878e5c641c3b%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/5d42682f.1c69fb81.1683.e234SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/d91a3024-7fec-4ab8-99ff-878e5c641c3b%40googlegroups.com.
--
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-...@googlegroups.com.