Created
April 28, 2020 18:25
-
-
Save tshirtman/71f267f0b305f8613c06c019b1fe8320 to your computer and use it in GitHub Desktop.
simple cover image / letterboxing implementation in kivy
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
from kivy.app import App | |
from kivy.lang import Builder | |
from kivy.factory import Factory | |
KV = ''' | |
FloatLayout: | |
Image: | |
size_hint: None, None | |
source: 'landscape.png' | |
pos_hint: {'center': (.5, .5)} | |
taller: self.image_ratio > (root.width / root.height) | |
width: (root.height * self.image_ratio) if self.taller else root.width | |
height: (root.width / self.image_ratio) if not self.taller else root.height | |
allow_stretch:True | |
''' | |
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