Super class combining Image with ButtonBehaviour does not work as a button when setting size_hint from formula (Python) #43
Unanswered
FilipKosel
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello all,
First post on here, apologies in advance for any issues. I'll try to keep this short.
TL;DR: Super class combining ButtonBehaviour with Image does not work as a button when size_hint is set using formula to calculate values.
We're using Kivy in a Python project to create touchscreen tasks (see https://github.com/FilipKosel/TouchCog for more details). For reference, all Kivy coding is done directly in Python (i.e., we do not use .kv files); this is how the project was started before I joined on and this will not change in the foreseeable future.
We have an ImageButton super class that combines ButtonBehaviour with Image as follows:
In most situations, we hardcode the size_hint for each ImageButton, and this works well; the images show up as the appropriate size and function as buttons if the user touches within the boundaries of the image. However, in one scenario, the screen is divided into a grid of equally-sized squares, although the number of squares for each axis can change. Please see the following (simplified) code block:
For the above:
This code will display an appropriately-sized image, but the ButtonBehaviour does not work. Based on our troubleshooting:
The only thing I can think of is that the size_hint is correctly passed to the Image component, but not ButtonBehaviour, so the program is not correctly identifying the button boundaries (and therefore is not registering that a touch is occuring within the boundaries).
Does anyone have any insight on how to address this? We've been stuck on this for a couple weeks and I'm running out of ideas.
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions