Resize Checkbox

201 views
Skip to first unread message

Big Red Eyes Productions

unread,
Nov 12, 2022, 1:32:22 PM11/12/22
to Kivy users support

I think what I want is simple, but I don't see any way of doing it.

I want to be able to set the size of the checkbox. I have a label next to a checkbox that resizes, but the checkbox stays the same size.

If this can already be done please educate me and I will share the informational wealth.

Thank you team.

Here's an example of what I'm using.


CheckBox:
        id: remember
        active: False
        size_hint_y: None
        size_hint_x: 1
        height: '36dp'
        width: '30dp'
        pos_hint: {'left':1.0, 'top':0.045}


One helper offered this:

CheckBox:
    id: remember
    active: False
    size_hint_y: None
    size_hint_x: 1
    height: '36dp'
    width: '30dp'
    pos_hint: {'left':1.0, 'top':0.045}
    canvas:
        Clear
         Color:
                      rgba: self.color
         Rectangle:
                     source: self._radio_image if self.group else self._checkbox_image
                     size: sp(32), sp(32)
                     pos: int(self.center_x - sp(16)), int(self.center_y - sp(16))

Which seems to make no difference, as seen in the images below.

image

image

The boxing gets bigger, but not the actual checkbox.


Elliot Garbus

unread,
Nov 12, 2022, 3:06:48 PM11/12/22
to kivy-...@googlegroups.com

To create a scalable checkbox, create a new class that adds ToggleButtonBehavior to the Image class.

See the example:  https://kivy.org/doc/stable/api-kivy.uix.behaviors.togglebutton.html?highlight=toggle#module-kivy.uix.behaviors.togglebutton

Set the Image attribues allow_stretch to True and the keep_ratio to True

 

Using this same method you could also create any two images for your checkbox.  The examples uses the default checkbox images.

Let me know if that if you get it working or if you need more assistance. 

--
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/428266d9-1919-418e-adfa-caea9799b526n%40googlegroups.com.

 

Reply all
Reply to author
Forward
0 new messages