Created
August 1, 2018 12:11
-
-
Save onslauth/93853f261ec057f8150150aa6d19d75b 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
from kivy.config import Config | |
Config.set('kivy', 'log_level', 'debug') | |
from kivy.app import App | |
from kivy.lang import Builder | |
from kivy.factory import Factory | |
from kivy.uix.boxlayout import BoxLayout | |
from kivy.uix.image import Image | |
from kivy.properties import ObjectProperty | |
kv = """ | |
#:import rand_float random.uniform | |
<Test>: | |
image_list: image_list | |
GridLayout: | |
id: image_list | |
size_hint_y: None | |
size_hint_x: None | |
width: root.width | |
spacing: 20, 0 | |
padding: 100, 50, 0, 50 | |
cols: 1 | |
height: sum( ( x.height + 50 ) for x in self.children ) | |
""" | |
class Test(BoxLayout): | |
image_list = ObjectProperty( ) | |
def __init__(self, *args, **kwargs): | |
super(Test, self).__init__(*args, **kwargs) | |
self.add_images( ) | |
self.image_list.export_to_png( "test.png" ) | |
def add_images( self ): | |
for i in range( 1, 5 ): | |
widget = Image( source = "{:04d}.JPG".format( i ), size_hint = ( None, None ), size = ( 2000, 500 ) ) | |
self.image_list.add_widget( widget ) | |
class TestApp(App): | |
def build(self): | |
return Test() | |
if __name__ == '__main__': | |
Builder.load_string(kv) | |
TestApp().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment