Exemple #1
0
 def berkelium_is_installed(self):
     try : 
         #from kivy.ext import load
         berkelium = load('berkelium', (1, 1))
         return True
     except :
         return False
Exemple #2
0
from kivy.properties import ObjectProperty, NumericProperty,StringProperty, \
    BooleanProperty, DictProperty, ListProperty
from kivy.uix.widget import Widget
from kivy.uix.scatter import Scatter
from kivy.uix.label import Label
from kivy.uix.image import Image
from kivy.vector import Vector
from kivy.animation import Animation
from kivy.clock import Clock

from video_player import VideoPlayer
from square import Square, GeometrySquare

try : 
    from kivy.ext import load
    berkelium = load('berkelium', (1, 1))
except :
    print "Warning : Berkelium not setup. Don't use html pagesas layouts"   
    pass

class VideoPlayer2(VideoPlayer):
    def on_touch_down(self,touch):
        super(VideoPlayer2,self).on_touch_down(touch)  
        return True      
        

class Field(Widget):
    app = ObjectProperty(None)
    style = DictProperty({'geometry_square_margin':0  })
    activate_animations = BooleanProperty( False )
    #internal variables
Exemple #3
0
    def init_layouts(self):

        def layers2texture(layers, berkelium):
            #convert either an image or an html webpage to texture
            #to be used as a background by the square
            converted_layers = {}
            bk = {}
            for key,path in layers.iteritems():
                #fileName, fileExtension = os.path.splitext(path)
                #if fileName[4] in ['http','file']: #fileExtension in ['.org','.com','.fr','.html','.htm'] :
                if path[:4] in ['http','file']:
                    if self.berkelium_is_installed == False : return None
                    size = (600,600)
                    bk[key] = berkelium.Webbrowser(url=path, size=size)
                    texture = bk[key]._bk.texture
                    converted_layers[key] = texture
                    #finally delete the berkelium instance
                    del bk[key]   
                else :
                    from kivy.uix.image import Image
                    img = Image(source=path)
                    texture = img.texture
                    converted_layers[key] = texture
            #print path, texture
            return converted_layers   
        
        #load berkelium
        berkelium = None
        if self.berkelium_is_installed == True : 
            from kivy.ext import load
            berkelium = load('berkelium', (1, 1))            

        #extract textures from layouts
        self.layers = layers2texture(self.layers, berkelium)

        #get current layout
        layout_type = self.layout_type
        param = self.square_parameters[layout_type] #load parameters specific to that size (small, medium, large)
        
        #color
        a,b,c,d = self.color_up
        
        ######################### LAYOUT ##########################################################
        
        self.texture_path = texture_path = str(param['texture_path']) #self.style['square_texture_path']
        #text layer
        self.layer_texture_path = self.layers[layout_type]
        """
        from kivy.uix.image import Image
        self.layer = Image(source = "apps/layers/xyz/large.png", size_hint = (1,1))
        self.layout.add_widget(self.layer)
        """         
        #top part : Title, app_type, authors
        self.box_top = BoxLayout(size_hint = param['box_top_size_hint'] )#orientation = 'horizontal', 
        font_size = self.process_font_size( self.title, int( param['title_label_font_size']) )
        text_size = (len(self.title)*font_size +100,None )
        self.title_label = Label( text=self.title, font_size = font_size, color = self.color_text, halign = 'left', valign = 'top',text_size = text_size, padding = (5,0) ) #font_name = 'DEJAVU SANS CONDENSED', bold = False
        self.box2 = BoxLayout(orientation = 'horizontal',  size_hint = (None,1) , width = self.title_label.text_size[0], pos_hint={'top': 1,'left':1} )
        #self.app_type_pic = Image(source = str(self.app_type), pos_hint={'top': 1,'right':1}, size_hint = (1,3) )
        #self.box3 = AnchorLayout( anchor_x = 'right', anchor_y = 'bottom')
        #self.authors_label = Label(text = self.authors, font_size = int( param['authors_label_font_size'] ), pos_hint ={'right':1},  color = self.color_text, halign = 'right') #, pos_hint={'bottom': 1,'right':1} )        
        self.box2.add_widget(self.title_label)
        self.box_top.add_widget(self.box2)
        #self.box3.add_widget(self.authors_label)
        #self.box_top.add_widget(self.box3)
        self.layout.add_widget( self.box_top )
        
        #middle part : Image or Video
        self.box_middle = BoxLayout(orientation = 'horizontal', size_hint = param['box_middle_size_hint'] )
        self.box_middle1 = BoxLayout(orientation = 'horizontal', size_hint = param['box_middle1_size_hint'], padding = 0, spacing = 0 )
        self.box_middle2 = BoxLayout(orientation = 'horizontal', size_hint = param['box_middle2_size_hint'], padding = 0, spacing = 0 )
        self.box_middle.add_widget( self.box_middle1 ) 
        self.box_middle.add_widget( self.box_middle2 )
 
        if self.main_media_type == 'webpage' :
            #berkelium installed was already checked by field
            try : 
                self.webpage = berkelium.Webbrowser(url=self.webpage_path, size=(50,50) )
                self.box_middle1.add_widget( self.webpage ) 
            except :
                print 'Cannot load url: '+str(self.webpage_path)
                self.main_media_type = 'image'
            
        if self.main_media_type == 'image' : 
            from kivy.uix.image import Image
            image = Image(source = self.image_path, allow_stretch = True, keep_ratio = False, size_hint = (1,1), pos_hint={'left': 1, 'top' : 1} )
            self.box_middle1.add_widget( image ) 

        elif self.main_media_type == 'video' :
            #if self.main_media_type == 'video' :
            self.video = VideoPlayer(source = self.video_path)
            self.video.bind(on_unmute =self.on_unmute)
            self.video.bind(on_start=self.on_start)
            self.video.bind(on_fullscreen = self.on_fullscreen)
            self.video.bind(on_leave_fullscreen = self.on_leave_fullscreen)
            self.box_middle1.add_widget( self.video ) 
        
        self.layout.add_widget( self.box_middle ) 

        #Bottom part : buttons
        self.box_bottom = BoxLayout(orientation = 'horizontal', size_hint = param['box_bottom_size_hint'] )
        self.subbox = BoxLayout(orientation = 'horizontal' )
        self.box_bottom.padding = int( param['box_bottom_padding'] ) #box.height*0.15 
        self.vote_button = SuperButton(background_normal = 'style/square/bouton-vote-T2-off.png', background_down = 'style/square/bouton-vote-T2-on.png', size_hint = (None,None), size=param["vote_button_size"] )
        self.vote_button.bind( on_press = self.vote ) 
        self.subbox.add_widget( self.vote_button )
        #vote feedback
        from kivy.uix.image import Image
        self.fb = Image(source = 'style/square/like'+self.convert_vote_feedback()+'.png', size_hint=(None,None), size=param["vote_feedback_size"])
        self.subbox.add_widget( self.fb )
        self.box_bottom.add_widget(self.subbox)
        self.launch_button = SuperButton(background_normal = 'style/square/bouton-lancer-T2-off.png',background_down = 'style/square/bouton-lancer-T2-on.png', size_hint = (None,None), size=param["launch_button_size"] ) 
        self.launch_button.bind( on_press = self.launch ) 
        self.box_bottom.add_widget( self.launch_button )
        self.box_bottom.spacing = (self.layout.width - self.vote_button.width - self.launch_button.width)*0.97
        self.layout.add_widget( self.box_bottom )

        self.add_widget(self.layout)
Exemple #4
0
'''
Berkelium extension demo
========================

Check http://github.com/kivy/kivy-berkelium for more information.
You must have berkelium-1.2 extension installed before running the demo

'''
from kivy.uix.scatter import Scatter
from kivy.uix.floatlayout import FloatLayout
from kivy.app import App

from kivy.ext import load
berkelium = load('berkelium', (1, 2))

urls = (
    'http://kivy.org',
    'http://www.youtube.com/watch?v=QKh1Rv0PlOQ',
)

class BerkeliumBrowserApp(App):
    def build(self):
        root = FloatLayout()
        size = (1024, 768)
        for url in urls:
            scatter = Scatter(size=size)
            bk = berkelium.Webbrowser(url=url, size=size)
            scatter.add_widget(bk)
            root.add_widget(scatter)
        return root
Exemple #5
0
'''
Berkelium extension demo
========================

Check http://github.com/kivy/kivy-berkelium for more information.
You must have berkelium-1.2 extension installed before running the demo

'''
from kivy.uix.scatter import Scatter
from kivy.uix.floatlayout import FloatLayout
from kivy.app import App

from kivy.ext import load
berkelium = load('berkelium', (1, 2))

urls = (
    'http://kivy.org',
    'http://www.youtube.com/watch?v=QKh1Rv0PlOQ',
)


class BerkeliumBrowserApp(App):
    def build(self):
        root = FloatLayout()
        size = (1024, 768)
        for url in urls:
            scatter = Scatter(size=size)
            bk = berkelium.Webbrowser(url=url, size=size)
            scatter.add_widget(bk)
            root.add_widget(scatter)
        return root