1.1 --- a/main.py Fri Sep 11 09:53:30 2009 +0300
1.2 +++ b/main.py Mon Sep 21 22:42:40 2009 +0300
1.3 @@ -108,28 +108,104 @@
1.4 grid.SetColSize(1,grid.GetColSize(0))
1.5 grid.Show()
1.6
1.7 +class AddDirectory(wx.Dialog):
1.8 + def __init__(self,parent,id,dir_list) :
1.9 + wx.Dialog.__init__(self,parent,id,title='Add directory',
1.10 + style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
1.11 +
1.12 + ## get IDs for all controls
1.13 + self.ID_ADD = wx.NewId()
1.14 + self.ID_DEL = wx.NewId()
1.15 +
1.16 + wx.EVT_BUTTON(self, self.ID_DEL, self.OnDel)
1.17 + wx.EVT_BUTTON(self, self.ID_ADD, self.OnAdd)
1.18 +
1.19 + panel = wx.Panel(self,wx.ID_ANY)
1.20 + box = wx.StaticBox(panel,label='Search Path')
1.21 + self.list = wx.ListBox(panel,wx.ID_ANY,choices=dir_list,
1.22 + style=wx.LB_SINGLE | wx.LB_SORT )
1.23 + ok = wx.Button(panel, wx.ID_OK)
1.24 + cancel = wx.Button(panel, wx.ID_CANCEL)
1.25 + add = wx.Button(panel, self.ID_ADD,label='&Add ...')
1.26 + delete = wx.Button(panel, self.ID_DEL,label='&Delete')
1.27 +
1.28 + path_strip = wx.BoxSizer(wx.HORIZONTAL)
1.29 + path_strip.Add(add,0, wx.ALL|wx.EXPAND, 5)
1.30 + path_strip.Add(delete,0, wx.ALL|wx.EXPAND, 5)
1.31 +
1.32 + path = wx.StaticBoxSizer(box,wx.VERTICAL)
1.33 + path.Add(self.list , 1, wx.ALL|wx.EXPAND, 5)
1.34 + path.Add(path_strip , 0, wx.ALL, 5)
1.35 +
1.36 + bottom_strip = wx.BoxSizer(wx.HORIZONTAL)
1.37 + bottom_strip.Add(ok,0, wx.ALL|wx.EXPAND, 5)
1.38 + bottom_strip.Add(cancel,0, wx.ALL|wx.EXPAND, 5)
1.39 +
1.40 + toplevel = wx.BoxSizer(wx.VERTICAL)
1.41 + toplevel.Add(path,1,wx.ALL|wx.EXPAND, 5)
1.42 + toplevel.Add(bottom_strip,0,wx.ALL, 5)
1.43 + panel.SetSizer(toplevel)
1.44 + toplevel.Fit(panel)
1.45 +
1.46 + def OnDel(self,event):
1.47 + sel = self.list.GetSelection()
1.48 + if sel != wx.NOT_FOUND :
1.49 + ans = wx.MessageDialog(self,
1.50 + message='Delete "%s"?'
1.51 + % self.list.GetString(sel),
1.52 + ).ShowModal()
1.53 + if ans == wx.ID_OK :
1.54 + self.list.Delete(sel)
1.55 +
1.56 + def OnAdd(self,event):
1.57 + dir_dial = wx.DirDialog(self,
1.58 + style=wx.DD_DEFAULT_STYLE,
1.59 + message='Select a directory to add')
1.60 + if dir_dial.ShowModal() == wx.ID_OK :
1.61 + self.list.Append(dir_dial.GetPath())
1.62 +
1.63 + def GetStrings(self) :
1.64 + return self.list.GetStrings()
1.65 +
1.66 +
1.67 class Canvas(BorderLessWindow):
1.68 - ID_INFO = 555
1.69 - ID_OPTIONS = 556
1.70 - ID_ABOUT = 557
1.71 - ID_TIMER = 600
1.72 def __init__(self, parent, id):
1.73 BorderLessWindow.__init__(self,parent, id)
1.74 +
1.75 + ## get IDs for all controls
1.76 + self.ID_INFO = wx.NewId()
1.77 + self.ID_OPTIONS = wx.NewId()
1.78 + self.ID_ABOUT = wx.NewId()
1.79 + self.ID_TIMER = wx.NewId()
1.80
1.81 wx.EVT_PAINT (self, self.OnPaint)
1.82 wx.EVT_CONTEXT_MENU (self, self.OnContextMenu)
1.83 wx.EVT_MENU (self, wx.ID_EXIT, self.OnExit)
1.84 wx.EVT_MENU (self, self.ID_ABOUT, self.OnAbout)
1.85 + wx.EVT_MENU (self, self.ID_OPTIONS, self.OnOptions)
1.86 wx.EVT_MENU (self, self.ID_INFO, self.OnInfo)
1.87
1.88 wx.EVT_TIMER (self, self.ID_TIMER, self.OnTimer)
1.89 self.timer = wx.Timer(self, self.ID_TIMER)
1.90 self.timer.Start(1000)
1.91
1.92 + self.config = wx.Config('DeskFrame')
1.93 +
1.94 + self.dir_list = self.ReadDirList()
1.95 +
1.96 def image(self,fname) :
1.97 self.im = wx.Image(fname)
1.98 self.EXIF = EXIF.process_file(file(fname))
1.99
1.100 + def ReadDirList(self) :
1.101 + try :
1.102 + return self.config.Read('dir_list').split(':')
1.103 + except :
1.104 + return []
1.105 +
1.106 + def WriteDirList(self,dir_list) :
1.107 + self.config.Write('dir_list',':'.join(dir_list))
1.108 +
1.109 def OnTimer(self,event):
1.110 return
1.111
1.112 @@ -148,6 +224,12 @@
1.113 def OnInfo(self,event) :
1.114 EXIFviewer(self,wx.ID_ANY,self.EXIF).Show()
1.115
1.116 + def OnOptions(self,event) :
1.117 + add_dir = AddDirectory(self,wx.ID_ANY,self.dir_list)
1.118 + if add_dir.ShowModal() == wx.ID_OK:
1.119 + self.dir_list = add_dir.GetStrings()
1.120 + self.WriteDirList(self.dir_list)
1.121 +
1.122 def OnExit(self,event) :
1.123 self.Close(True)
1.124