Rekovni
Rekovni

Reputation: 7344

Kivy - How to set the window size based off display size?

I have just been starting to use the Kivy framework, and am slightly confused on setting the window size based off the display size of the screen. For example if my display size is 200x100mm, how would I set that in Kivy?

I've looked at examples such as this one from SO, however I can't change seem to alter the size based off of the mm metric.

I have also tried converting mm to pixels, however that is also the wrong size on my screen, and I think it is a frowned upon technique from what I have read online.

import kivy
kivy.require('1.9.1')

from kivy.config import Config
Config.set('graphics', 'width', '200')
Config.set('graphics', 'height', '100')

I would like to add 200mm and 100mm in, however that brings up errors when attempting to build:

[CRITICAL] [Window      ] Unable to find any valuable Window provider at all!
sdl2 - ValueError: invalid literal for int() with base 10: '200mm'

How should I go about doing this in a correct manner?

Upvotes: 1

Views: 3195

Answers (1)

Yoav Glazner
Yoav Glazner

Reputation: 8066

I don't think that the size in mm counts, only the resolution of that screen.

So try to find out which resolutions will be in your target devices and tests them:

Config.set('graphics', 'width', '200')
Config.set('graphics', 'height', '100')

If just you want the full screen feature, Try this:

Window.fullscreen = 'auto' # you can also try True...

Upvotes: 2

Related Questions