Skip to content
Advertisement

How to increase size of a screen and center it in the monitor?

I am making a program with several screens and each one has its own size, so each time I change of screen I must re-size the App.
The problem is that, when I change the size of the window, Kivy only increase or reduce the lenght of the right and the bottom sides, not the four sides, so the screen always get “uncentered” after change the size.
I’ll try to make an example with lines:

JavaScript

Like you can see the program only change the lengh of the right and bottom sides.

How can I center again the screen or better change the size of the four sides and not only two?

This is an example of my code but I don’t have any idea of what to do:

This is an .py example:

JavaScript

This is an my.kv example (my in order to work with MyApp):

JavaScript

I have found a way but I don’t like it much:

JavaScript

Advertisement

Answer

I couldn’t find any hint that kivy was able to supply the screen size of the host device, so I hope if there is one, someone will tell us. In the meantime, I borrowed some setup code from another forum. I’ve only tested it on my macbook, and it seems to work, getting the screen size. I don’t know what will happen on windows, or linux, or multiple monitors. But here’s the new code:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement