Created
April 22, 2014 03:56
-
-
Save PaarthBatra/11164900 to your computer and use it in GitHub Desktop.
.gif Images runs backgrounds blinks when run via kivyLauncher and runs perfectly fine in windows .
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.uix.screenmanager import ScreenManager, Screen,FallOutTransition | |
from kivy.uix.image import Image | |
from kivy.uix.gridlayout import GridLayout | |
from kivy.uix.boxlayout import BoxLayout | |
from kivy.uix.button import Button | |
from kivy.core.window import Window | |
from kivy.graphics import BorderImage | |
from kivy.graphics import Color, Rectangle ,Line | |
################# Images ###################### | |
S = Image(source='images/Stick.png') | |
L = 'images/spinningFly.gif' | |
z= 'images/level1.zip' | |
################# Images ###################### | |
class CButtonW(BoxLayout): | |
def __init__(self, **kwargs): | |
print "init --> CButton self.pos is ",self.pos | |
super(CButtonW, self).__init__(**kwargs) | |
self.orientation = 'vertical' | |
with self.canvas.before: | |
Color(1, 1, 0, 1, mode='rgba') | |
self.rect = Rectangle(pos=self.pos,size=self.size) | |
self.I=BorderImage(pos=self.pos,size=self.size, | |
border=(10, 10, 10, 10), | |
source='images/tex.png') | |
self.bind(pos=self.update_rect) | |
self.bind(size=self.update_rect) | |
self.add_widget(S) | |
self.add_widget(Button(text="Button 1")) | |
#If use this - works ok on windows - but background blinks if run y kivy launcher | |
self.add_widget(Image(source=L)) | |
# If use this - works ok at both windows as well as in kivy launcher | |
self.add_widget(Image(source=z)) | |
def update_rect(self, *args): | |
self.rect.pos = self.pos | |
self.rect.size = self.size | |
self.I.pos = self.pos | |
self.I.size = self.size | |
class LevelScreen(Screen,GridLayout): | |
def __init__(self, **kwargs): | |
super(LevelScreen, self).__init__(**kwargs) | |
with self.canvas: | |
Line(points=(10, 10, 20, 30, 40, 50)) | |
Color(1, 0, 1, 1, mode='rgba') | |
Rectangle(pos=self.pos, size=Window.size) | |
self.layout = GridLayout(cols=3,spacing=1,padding=10) | |
self.Button1 = CButtonW(id='1',text='Level 1') | |
self.layout.add_widget(self.Button1) | |
LevelScreen.add_widget(self,self.layout) | |
# App Class | |
class MyJBApp(App): | |
def build(self): | |
sm = ScreenManager(transition= FallOutTransition()) | |
sm.add_widget(LevelScreen(name='level')) | |
return sm | |
if __name__ == '__main__': | |
MyJBApp().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use any .gif image example http://www.picgifs.com/graphics/flies/graphics-flies-339574-765326/
and use any .zip files for animation