Strategies for debugging layouts?

119 views
Skip to first unread message

Yannick Gingras

unread,
Jun 2, 2022, 10:14:07 AM6/2/22
to kivy-...@googlegroups.com

I was trying to nest an AnchorLayout inside a FloatLayout yesterday and
didn't get it to do what I want, which was to put a label at the top-
center of the float.

Since the layouts are invisible, debugging this felt like a shot in the
dark. In the debugger, I can traverse the widget tree until I get to
the layout and then inspect the position and size, but that seems like
a lot of work and I'm sure some of you have figured a strategy that is
more efficient to debug layout formatting.

The easiest would probably be to draw an outline around all my layouts,
maybe selecting a distinct colour for each of them. Is there an easy
way to do something like that?

How is everyone generally troubleshooting their layout arrangements?

Thanks!

--
Yannick Gingras
http://ygingras.net

signature.asc

Elliot Garbus

unread,
Jun 2, 2022, 10:52:12 AM6/2/22
to kivy-...@googlegroups.com

There is a very nice tool in kivy called the inspector.

You invoke it on the command line:

  • python main.py -m inspector

 

then press ctrl-e to bring up the tool.  When you click on widgets they are highlighted you can navigate to parent or child widgets.

More details: https://kivy.org/doc/stable/api-kivy.modules.inspector.html?highlight=inspector#module-kivy.modules.inspector

--

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/399c13c9ece568d356056b886602a5e4677ec0ee.camel%40ygingras.net.

 

Yannick Gingras

unread,
Jun 2, 2022, 11:32:41 AM6/2/22
to kivy-...@googlegroups.com

Woah, this is great! 

It turns out my label actually was exactly where I wanted it to be, but
the text alignment inside the label was off, which is why the text was
not where I expected it. It took me less than one minute to find that
out with the inspector. Awesome!

On Thu, 2022-06-02 at 07:52 -0700, Elliot Garbus wrote:
> There is a very nice tool in kivy called the inspector.
> You invoke it on the command line:
>  * python main.py -m inspector
> https://groups.google.com/d/msgid/kivy-users/6298ce94.1c69fb81.c7408.ee77SMTPIN_ADDED_MISSING%40gmr-mx.google.com
> .
signature.asc

Elliot Garbus

unread,
Jun 2, 2022, 11:41:03 AM6/2/22
to kivy-...@googlegroups.com

Happy to help. I agree – great, very useful tool!

Reply all
Reply to author
Forward
0 new messages