SourceForge: deskframe/deskframe: changeset 4:0e2c84627502
now gets images and changes them
authorShai Ayal <shaiay@users.sourceforge.net>
Thu Sep 24 22:04:55 2009 +0300 (2 months ago)
changeset 40e2c84627502
parent 3a11b64fc7c10
child 551f02f4367ff
now gets images and changes them
main.py
picture_list.py
     1.1 --- a/main.py	Mon Sep 21 22:42:40 2009 +0300
     1.2 +++ b/main.py	Thu Sep 24 22:04:55 2009 +0300
     1.3 @@ -23,6 +23,8 @@
     1.4  import wx.grid
     1.5  import EXIF
     1.6  
     1.7 +from picture_list import indexed_files
     1.8 +
     1.9  class BorderLessWindow(wx.Frame):
    1.10      """A window with no title and only a resize border. Moving is done
    1.11      by left dragging anywhere inside"""
    1.12 @@ -192,6 +194,13 @@
    1.13          self.config = wx.Config('DeskFrame')
    1.14  
    1.15          self.dir_list = self.ReadDirList()
    1.16 +        self.LoadImageList()
    1.17 +        self.image_idx = 0
    1.18 +
    1.19 +    def LoadImageList(self) :
    1.20 +        self.image_list = indexed_files()
    1.21 +        for dd in self.dir_list :
    1.22 +            self.image_list.add_root(dd)
    1.23  
    1.24      def image(self,fname) :
    1.25          self.im = wx.Image(fname)
    1.26 @@ -207,6 +216,9 @@
    1.27          self.config.Write('dir_list',':'.join(dir_list))
    1.28  
    1.29      def OnTimer(self,event):
    1.30 +        self.image(self.image_list.get_file(self.image_idx))
    1.31 +        self.image_idx += 1
    1.32 +        self.Refresh()
    1.33          return
    1.34  
    1.35      def OnContextMenu(self,event):
    1.36 @@ -229,6 +241,7 @@
    1.37          if add_dir.ShowModal() == wx.ID_OK:
    1.38              self.dir_list = add_dir.GetStrings()
    1.39              self.WriteDirList(self.dir_list)
    1.40 +            self.LoadImageList()
    1.41  
    1.42      def OnExit(self,event) :
    1.43          self.Close(True)
     2.1 --- a/picture_list.py	Mon Sep 21 22:42:40 2009 +0300
     2.2 +++ b/picture_list.py	Thu Sep 24 22:04:55 2009 +0300
     2.3 @@ -24,9 +24,11 @@
     2.4  
     2.5  
     2.6  class indexed_files(object):
     2.7 -    files = []
     2.8 -    dirs  = []
     2.9      def __init__(self) :
    2.10 +        self.clear()
    2.11 +        self.regexp_list = ['\.jpg$']
    2.12 +
    2.13 +    def clear(self) :
    2.14          self.files = []
    2.15          self.dirs = []
    2.16  
    2.17 @@ -35,7 +37,10 @@
    2.18          return len(self.dirs)-1
    2.19  
    2.20      def add_file(self,filename,parent_idx) :
    2.21 -        self.files.append( (filename,parent_idx))
    2.22 +        for regexp in self.regexp_list :
    2.23 +            if re.search(regexp,filename) :
    2.24 +                self.files.append( (filename,parent_idx))
    2.25 +                return
    2.26  
    2.27      def walk_dir(self,curr_dir,curr_idx):
    2.28          for entry in os.listdir(curr_dir):