Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kivy CheckBox Looks Like Solid Black Box (Not a Checkbox)

Tags:

python

kivy

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)

This produces the following widget (thisRow):

enter image description here

After the box is checked...

enter image description here

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?

Thank you

like image 371
Malonge Avatar asked Apr 16 '15 20:04

Malonge


1 Answers

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())
like image 148
Peter Badida Avatar answered Oct 23 '22 00:10

Peter Badida