Kivy CheckBox看起来像纯黑框(不是复选框) [英] Kivy CheckBox Looks Like Solid Black Box (Not a Checkbox)

查看:76
本文介绍了Kivy CheckBox看起来像纯黑框(不是复选框)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个BoxLayout小部件(orientation ='horizo​​ntal'),其中包含三个小部件,一个标签,一个文本框和一个复选框.

I am making a BoxLayout widget (orientation = 'horizontal') that contains three widgets inside of it, a label, a text box, and a check box.

thisRow = BoxLayout(orientation='horizontal')
l = Label(text='Enter plate 1:\n(Plate #)')
t = TextInput(text = 'this is a text box')
c = CheckBox()
thisRow.add_widget(l)
thisRow.add_widget(t)
thisRow.add_widget(c)

这将产生以下窗口小部件(thisRow):

This produces the following widget (thisRow):

选中该框后...

最右边的黑框实际上是复选框,并且可以正常工作,但是用户无法知道它实际上是复选框.如图片此处所示.

The rightmost black box is actually the checkbox, and works functionally, however there is no way for the user to know that it is in fact a checkbox. I would expect a smaller empty square in the middle, as is depicted in pictures here.

如何获取传统的复选框图像(较小的空方框)?还是一般来说,如何使该框更明显是一个复选框,而不仅仅是一个空标签?

How do i get the traditional checkbox image (smaller empty square box)? Or generally, how can I make it more obvious that the box is a check box and not just an empty label?

谢谢

推荐答案

这是一个非常有趣的问题,Malonge很好地尝试了这个问题.现在(1.9.2-dev)在CheckBox的孔上仍然有固定的大小,称为背景.这是一张Widget从地图集中获取的图像,如果状态发生变化,它也会发生变化.因此,直到现在,还没有明确的方法来做到这一点.这是一个例子.很快在master上将出现CheckBox(color=[r,g,b,a])选项.谢谢;)

This is really interesting question and Malonge tried it in a good way. Right now(1.9.2-dev) there is still fixed size on CheckBox's well, call it a background. It's an image that Widget takes from atlas and changes if the state changes. Therefore until now there was no clear way how to do it. Here is an example. Soon on master there'll be CheckBox(color=[r,g,b,a]) option. Thanks ;)

from kivy.lang import Builder
from kivy.base import runTouchApp
from kivy.uix.boxlayout import BoxLayout
Builder.load_string('''
<CheckBoxBG>:
    Label:
    TextInput:
    CheckBox:
        canvas.before:
            Color:
                rgb: 1,0,0
            Rectangle:
                pos:self.center_x-8, self.center_y-8
                size:[16,16]
            Color:
                rgb: 0,0,0
            Rectangle:
                pos:self.center_x-7, self.center_y-7
                size:[14,14]
''')
class CheckBoxBG(BoxLayout):pass
runTouchApp(CheckBoxBG())

这篇关于Kivy CheckBox看起来像纯黑框(不是复选框)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆