-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigFrame.py
More file actions
209 lines (187 loc) · 9.27 KB
/
Copy pathConfigFrame.py
File metadata and controls
209 lines (187 loc) · 9.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
################################################################################
# Copyright 2010 Andreas Neustifter (andreas.neustifter@gmail.com)
#
# This file is part of PhotoImport.
#
# PhotoImport is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# PhotoImport is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# PhotoImport. If not, see <http://www.gnu.org/licenses/>.
################################################################################
"""
The ConfigFrame module is called as first module to read all the configurations.
"""
# -*- coding: utf-8 -*-
# generated by wxGlade 0.6.3 on Sat Nov 6 16:31:28 2010
import wx
import ConfigData
import logging
# begin wxGlade: dependencies
# end wxGlade
# begin wxGlade: extracode
# end wxGlade
class ConfigFrame(wx.Frame):
"""
This class defines the configuration frame for PhotoImport. It then creates
the FileList and this list copies the files.
"""
def __init__(self, *args, **kwds):
# begin wxGlade: ConfigFrame.__init__
kwds["style"] = wx.CAPTION | wx.CLOSE_BOX | wx.MINIMIZE_BOX | wx.MAXIMIZE_BOX | wx.SYSTEM_MENU | wx.RESIZE_BORDER | wx.TAB_TRAVERSAL | wx.CLIP_CHILDREN
wx.Frame.__init__(self, *args, **kwds)
self.mainpanel = wx.Panel(self, -1, style=wx.NO_BORDER)
self.srcrecursive = wx.CheckBox(self.mainpanel, -1, "Recursive")
self.srcvalue = wx.TextCtrl(self.mainpanel, -1, "")
self.srcselect = wx.Button(self.mainpanel, -1, ". . .")
self.sizer_2_staticbox = wx.StaticBox(self.mainpanel, -1, "Source Folder")
self.spacepanel5 = wx.Panel(self.mainpanel, -1)
self.destvalue = wx.TextCtrl(self.mainpanel, -1, "")
self.destselect = wx.Button(self.mainpanel, -1, ". . .")
self.sizer_3_staticbox = wx.StaticBox(self.mainpanel, -1, "Destination Folder")
self.foldernamelbl = wx.StaticText(self.mainpanel, -1, "Folder Naming")
self.foldernamevalue = wx.TextCtrl(self.mainpanel, -1, "<date>_<name>")
self.spacepanel1 = wx.Panel(self.mainpanel, -1)
self.renamefiles = wx.CheckBox(self.mainpanel, -1, "Rename")
self.filenamevalue = wx.TextCtrl(self.mainpanel, -1, "<date>-<time>.<ext>")
self.spacepanel4 = wx.Panel(self.mainpanel, -1)
self.sizer_5_staticbox = wx.StaticBox(self.mainpanel, -1, "File Renaming")
self.spacepanel3 = wx.Panel(self.mainpanel, -1)
self.cancelbtn = wx.Button(self.mainpanel, wx.ID_CANCEL, "")
self.okbtn = wx.Button(self.mainpanel, wx.ID_OK, "")
self.spacepanel2 = wx.Panel(self.mainpanel, -1)
self.__set_properties()
self.__do_layout()
self.Bind(wx.EVT_BUTTON, self.evt_browsesource, self.srcselect)
self.Bind(wx.EVT_BUTTON, self.evt_browsedest, self.destselect)
self.Bind(wx.EVT_CHECKBOX, self.evt_renamefiles, self.renamefiles)
self.Bind(wx.EVT_BUTTON, self.evt_cancelbtn, self.cancelbtn)
self.Bind(wx.EVT_BUTTON, self.evt_okbtn, self.okbtn)
# end wxGlade
self.Bind(wx.EVT_CLOSE, self.evt_close, self)
self.config = None
self.filelist = None
self.__get_config()
def __set_properties(self):
# begin wxGlade: ConfigFrame.__set_properties
self.SetTitle("Configuration")
self.SetSize((784, 357))
self.srcrecursive.SetMinSize((100,37))
self.srcvalue.SetMinSize((300, 27))
self.srcselect.SetMinSize((60, 29))
self.spacepanel5.SetMinSize((100,37))
self.destvalue.SetMinSize((300, 27))
self.destselect.SetMinSize((60, 29))
self.foldernamelbl.SetMinSize((100, 17))
self.foldernamevalue.SetMinSize((300, 27))
self.spacepanel1.SetMinSize((65,29))
self.renamefiles.SetMinSize((100, 37))
self.filenamevalue.SetMinSize((300, 27))
self.spacepanel4.SetMinSize((65,29))
self.cancelbtn.SetMinSize((70, 29))
self.okbtn.SetMinSize((100, 29))
self.spacepanel2.SetMinSize((60, 29))
# end wxGlade
def __do_layout(self):
# begin wxGlade: ConfigFrame.__do_layout
mainsizer = wx.BoxSizer(wx.HORIZONTAL)
sizer_1 = wx.BoxSizer(wx.VERTICAL)
sizer_6 = wx.BoxSizer(wx.HORIZONTAL)
self.sizer_5_staticbox.Lower()
sizer_5 = wx.StaticBoxSizer(self.sizer_5_staticbox, wx.HORIZONTAL)
sizer_4 = wx.BoxSizer(wx.HORIZONTAL)
self.sizer_3_staticbox.Lower()
sizer_3 = wx.StaticBoxSizer(self.sizer_3_staticbox, wx.HORIZONTAL)
self.sizer_2_staticbox.Lower()
sizer_2 = wx.StaticBoxSizer(self.sizer_2_staticbox, wx.HORIZONTAL)
sizer_2.Add(self.srcrecursive, 0, wx.LEFT | wx.RIGHT | wx.EXPAND, 6)
sizer_2.Add(self.srcvalue, 1, wx.ALL, 4)
sizer_2.Add(self.srcselect, 0, wx.ALL, 4)
sizer_1.Add(sizer_2, 0, wx.ALL | wx.EXPAND, 4)
sizer_3.Add(self.spacepanel5, 0, wx.LEFT | wx.RIGHT | wx.EXPAND, 6)
sizer_3.Add(self.destvalue, 1, wx.ALL, 4)
sizer_3.Add(self.destselect, 0, wx.ALL, 4)
sizer_1.Add(sizer_3, 0, wx.ALL | wx.EXPAND, 4)
sizer_4.Add(self.foldernamelbl, 0, wx.ALL | wx.ALIGN_RIGHT, 8)
sizer_4.Add(self.foldernamevalue, 1, wx.ALL, 4)
sizer_4.Add(self.spacepanel1, 0, wx.ALL | wx.EXPAND, 4)
sizer_1.Add(sizer_4, 0, wx.ALL | wx.EXPAND, 4)
sizer_5.Add(self.renamefiles, 0, wx.LEFT | wx.RIGHT | wx.EXPAND, 6)
sizer_5.Add(self.filenamevalue, 1, wx.ALL, 4)
sizer_5.Add(self.spacepanel4, 0, wx.ALL | wx.EXPAND, 4)
sizer_1.Add(sizer_5, 0, wx.ALL | wx.EXPAND, 4)
sizer_6.Add(self.spacepanel3, 1, wx.EXPAND, 0)
sizer_6.Add(self.cancelbtn, 0, wx.ALL, 4)
sizer_6.Add(self.okbtn, 0, wx.ALL, 4)
sizer_6.Add(self.spacepanel2, 0, wx.ALL | wx.EXPAND, 4)
sizer_1.Add(sizer_6, 0, wx.ALL | wx.EXPAND, 4)
self.mainpanel.SetSizer(sizer_1)
mainsizer.Add(self.mainpanel, 1, wx.EXPAND, 0)
self.SetSizer(mainsizer)
mainsizer.SetSizeHints(self)
self.Layout()
self.Centre()
# end wxGlade
def __get_config(self):
""" This creates a configuration object and sets the GUI values accordingly."""
self.config = ConfigData.ConfigData()
self.srcrecursive.SetValue(self.config.srcrecursive)
self.srcvalue.SetValue(self.config.srcvalue)
self.destvalue.SetValue(self.config.destvalue)
self.foldernamevalue.SetValue(self.config.foldernamevalue)
self.renamefiles.SetValue(self.config.renamefiles)
self.filenamevalue.SetValue(self.config.filenamevalue)
self.evt_renamefiles(None)
def __set_config(self):
""" This writes back the GUI values to the configuration. """
self.config.srcrecursive = self.srcrecursive.GetValue()
self.config.srcvalue = self.srcvalue.GetValue()
self.config.destvalue = self.destvalue.GetValue()
self.config.foldernamevalue = self.foldernamevalue.GetValue()
self.config.renamefiles = self.renamefiles.GetValue()
self.config.filenamevalue = self.filenamevalue.GetValue()
def evt_cancelbtn(self, event): # wxGlade: ConfigFrame.<event_handler>
""" Closes the window. """
self.Close()
def evt_okbtn(self, event): # wxGlade: ConfigFrame.<event_handler>
""" Creates the FileList and hands control to it. """
import FileList
self.__set_config()
self.filelist = FileList.FileList(self.config, self, wx.GetTopLevelParent(self).loghandler)
self.filelist.filter()
self.filelist.showdialog()
self.Close()
def evt_browsesource(self, event): # wxGlade: ConfigFrame.<event_handler>
""" Opens a dialog to select source folder. """
try:
dlg = wx.DirDialog(self, "Choose a Source Folder", style=wx.DD_DEFAULT_STYLE | wx.DD_NEW_DIR_BUTTON)
dlg.SetPath(self.srcvalue.GetValue())
if dlg.ShowModal() == wx.ID_OK:
self.srcvalue.SetValue(dlg.GetPath())
except:
logging.error("Error during source folder selection.")
def evt_browsedest(self, event): # wxGlade: ConfigFrame.<event_handler>
""" Opens dialog to select destination folder. """
try:
dlg = wx.DirDialog(self, "Choose a Destination Folder", style=wx.DD_DEFAULT_STYLE | wx.DD_NEW_DIR_BUTTON)
dlg.SetPath(self.srcvalue.GetValue())
if dlg.ShowModal() == wx.ID_OK:
self.destvalue.SetValue(dlg.GetPath())
except:
logging.error("Error during destination folder selection.")
def evt_close(self, event):
""" Stores the configured values to the config, saves it and exits. """
self.__set_config()
self.config.save()
event.Skip()
def evt_renamefiles(self, event): # wxGlade: ConfigFrame.<event_handler>
""" Toggles the changebility of the file rename pattern. """
self.filenamevalue.Enable(self.renamefiles.GetValue())
# end of class ConfigFrame