Created
October 22, 2020 16:28
-
-
Save tshirtman/7b56618fd9e005d933b2aa269ef5e4e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''Simulate a specific device that is not in kivy's screen module | |
''' | |
width = 1480 | |
height = 720 | |
dpi = 274 | |
density = 1 | |
scale = .5 | |
portrait = True | |
if portrait: | |
width, height = height, width | |
from os import environ | |
from kivy.config import Config | |
environ['KIVY_METRICS_DENSITY'] = str(density * scale) | |
environ['KIVY_DPI'] = str(dpi * scale) | |
Config.set('graphics', 'width', str(int(width * scale))) | |
# simulate with the android bar | |
# FIXME should be configurable | |
Config.set('graphics', 'height', str(int(height * scale - 25 * density))) | |
Config.set('graphics', 'fullscreen', '0') | |
Config.set('graphics', 'show_mousecursor', '1') | |
from kivy.app import App | |
from kivy.lang import Builder | |
KV = ''' | |
BoxLayout: | |
orientation: 'vertical' | |
Label: | |
text: 'test' | |
font_size: 30 | |
Label: | |
text: 'test' | |
font_size: dp(30) | |
Label: | |
text: 'test' | |
font_size: sp(30) | |
Label: | |
text: 'test' | |
font_size: cm(3) | |
''' | |
class Application(App): | |
def build(self): | |
return Builder.load_string(KV) | |
if __name__ == "__main__": | |
Application().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment