问题描述
我想在我的复选框中添加一个画布来更改它们的颜色.我找到了这个答案,但我正在努力实现它.我的复选框是使用以下代码在 python 中创建的:
I would like to add a canvas to my checkboxes to change their color. I have found this answer, but I am struggling to implement it. My checkboxes are created in python with this code:
尝试 1:我尝试了 这里但没有成功:
Attempt 1: I tried the solution from here but without success:
尝试 2:我还尝试在构建器中创建一个自定义复选框,但没有找到使其工作的方法(我找不到有关这种设置的任何信息,所以我不确定甚至可以让它工作):
Attempt 2: I also tried to come up with a custom checkbox created in the builder but didn't find a way to make it work (I couldn't find any info about this kind of setup, so I am not sure it's even possible to make it work):
和
<小时>
我尝试使用 with 语句:
Edit : my try with the with statement:
推荐答案
你应该使用 Python 代码中的 with 语句
You should use the with statement from your python code
您的其他方法似乎更好,只需稍微修复一下:
Your other approach seems better, just fix it a bit:
这篇关于Kivy:如何将画布用于在 python 中创建的小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!