class SlideshowApp(wx.App):
    def __init__(self, program, auto_start=True):
        wx.App.__init__(self)        

        self.program = program
        self.mediabackend = figure_mediabackend()
        self.auto_start = auto_start
        
        print("Using %s for media backend" % self.mediabackend)
        
        pub.subscribe(self.__handle_load_img_msg, "load_img")
        pub.subscribe(self.__handle_load_song_msg, "load_song")
        pub.subscribe(self.__handle_close_msg, "close")

        W,H = wx.Display(0).GetGeometry().GetSize()
        size = (W,H)
        pos = (0,0)
        self.frame = SlideshowFrame(
            pos=pos,
            size=size,
            parent=None, 
            title='Slideshow')
        self.mediaCtrl = wx.media.MediaCtrl(self.frame, 
                                            style=wx.TRANSPARENT_WINDOW,
                                            szBackend=self.mediabackend)        
        self.Bind(event=wx.media.EVT_MEDIA_LOADED, handler=self.__handle_media_loaded_evt)        
        
        self.frame.ShowFullScreen(True)
        if self.auto_start:
            self.program.start()        

    def __handle_close_msg(self):
        self.frame.Close()
        
    def __handle_load_img_msg(self,data):
        self.frame.load_img(data)

    def __handle_load_song_msg(self,data):
        self.load_song(data)
        
    def load_song(self, song_path):
        if self.mediaCtrl.GetState() == wx.media.MEDIASTATE_PLAYING:
            self.mediaCtrl.Stop()
        
        loaded = self.mediaCtrl.Load(song_path)
        if not loaded:
            print("Could not load song file %s" % song_path)
      
    def __handle_media_loaded_evt(self,event):
        self.mediaCtrl.Play()
    def __init__(self, program, auto_start=True):
        wx.App.__init__(self)        

        self.program = program
        self.mediabackend = figure_mediabackend()
        self.auto_start = auto_start
        
        print("Using %s for media backend" % self.mediabackend)
        
        pub.subscribe(self.__handle_load_img_msg, "load_img")
        pub.subscribe(self.__handle_load_song_msg, "load_song")
        pub.subscribe(self.__handle_close_msg, "close")

        W,H = wx.Display(0).GetGeometry().GetSize()
        size = (W,H)
        pos = (0,0)
        self.frame = SlideshowFrame(
            pos=pos,
            size=size,
            parent=None, 
            title='Slideshow')
        self.mediaCtrl = wx.media.MediaCtrl(self.frame, 
                                            style=wx.TRANSPARENT_WINDOW,
                                            szBackend=self.mediabackend)        
        self.Bind(event=wx.media.EVT_MEDIA_LOADED, handler=self.__handle_media_loaded_evt)        
        
        self.frame.ShowFullScreen(True)
        if self.auto_start:
            self.program.start()        
Beispiel #3
0
    def scan(self):
        new_files = []
        for r, dirs, files in os.walk(os.path.abspath(self.root)):
            for name in files:
                if os.path.splitext(name)[1].lower() in ('.jpg', '.png',
                                                         '.jpeg'):
                    new_files.append(os.path.join(r, name))

        metadata = {}
        for fname in new_files:
            try:
                md = self.read_metadata(fname)
                if 'Name' in md:
                    metadata[fname] = md
            except:
                pass

        new_files = self.sort(new_files, metadata)
        frames = []
        for filename in new_files:
            frame = SlideshowFrame(
                self, QRectF(0, 0, self.frame_width, self.frame_height),
                filename, metadata.get(filename))
            frames.append(frame)

        with self.lock:
            self.new_frames = frames