2424from time import sleep
2525from Dialog import *
2626from Mapping import *
27- from NotePage import *
27+ from NotePage import *
28+ from tkinter import filedialog
2829
2930class Timelapse ( BasicNotepage ):
3031 def BuildPage ( self ):
3132 f = ttk .LabelFrame (self ,text = 'Photo Time lapse settings' )
3233 f .grid (row = 0 ,column = 0 ,sticky = 'NEWS' )
33- f .columnconfigure (1 ,weight = 1 )
34+ f .columnconfigure (0 ,weight = 1 )
35+ f .columnconfigure (1 ,weight = 2 )
36+ f .columnconfigure (2 ,weight = 2 )
3437
3538
3639 #------------------- Type of time lapse --------------------
@@ -46,76 +49,161 @@ def BuildPage ( self ):
4649 #------------------- Use same Setting for all pictures --------------------
4750 self .PersistSetting = True
4851 self .PersistCheck = ttk .Checkbutton (f ,text = 'Same image setting for all pictures' ,
49- variable = self .PersistSetting , command = self .Clear )
52+ variable = self .PersistSetting , command = self .TogglePersistentSettings )
5053 self .PersistCheck .grid (row = 1 ,column = 0 ,sticky = 'NW' ,pady = 5 , columnspan = 2 )
5154 #ToolTip(self.PersistCheck,msg=102)
5255
5356 #------------------- Use Video Port --------------------
5457 self .UseVideo = False
55- self .UseVideoCheck = ttk .Checkbutton (f ,text = 'Use vdeo port (faster)' ,
56- variable = self .UseVideo , command = self .Clear )
58+ self .UseVideoCheck = ttk .Checkbutton (f ,text = 'Use video port (faster)' ,
59+ variable = self .UseVideo , command = self .ToggleUseVideoPort )
5760 self .UseVideoCheck .grid (row = 2 ,column = 0 ,sticky = 'NW' ,pady = 5 , columnspan = 2 )
5861 #ToolTip(self.UseVideoCheck,msg=102)
5962
6063 #------------------- Start Schedule --------------------
6164 l = Label (f ,text = 'Start Schedule:' )
6265 l .grid (row = 3 ,column = 0 ,sticky = 'W' ,pady = 5 )
6366
64- self .StartCombo = Combobox (f ,state = 'readonly' ,width = 20 )
67+ self .StartCombo = Combobox (f ,state = 'readonly' ,width = 10 )
6568 self .StartCombo .grid (row = 3 ,column = 1 ,columnspan = 3 ,sticky = 'W' )
6669 self .StartCombo ['values' ] = ('Inmediately' , 'Delay' ,'Date' )
6770 self .StartCombo .current (0 )
6871 #self.StartCombo.bind('<<ComboboxSelected>>',self.MeteringModeChanged)
6972 #ToolTip(self.StartCombo,200)
70- self .txt = Entry (f ,width = 20 )
71- self .txt .grid (row = 3 , column = 2 ,sticky = 'W' )
73+ self .StartTxt = Entry (f ,width = 10 )
74+ self .StartTxt .grid (row = 3 , column = 2 ,sticky = 'W' )
7275
7376 #------------------- Delay between shots --------------------
7477 l = Label (f ,text = 'Delay between shots:' )
7578 l .grid (row = 4 ,column = 0 ,sticky = 'W' ,pady = 5 )
7679
77- self .StartCombo = Combobox (f ,state = 'readonly' ,width = 20 )
78- self .StartCombo .grid (row = 4 ,column = 1 ,columnspan = 3 ,sticky = 'W' )
79- self .StartCombo ['values' ] = ('Delay' , 'On every' ,'Every Day at' )
80- self .StartCombo .current (0 )
80+ self .DelayCombo = Combobox (f ,state = 'readonly' ,width = 20 )
81+ self .DelayCombo .grid (row = 4 ,column = 1 ,columnspan = 3 ,sticky = 'W' )
82+ self .DelayCombo ['values' ] = ('Delay' , 'On every' ,'Every Day at' )
83+ self .DelayCombo .current (0 )
8184 #self.StartCombo.bind('<<ComboboxSelected>>',self.MeteringModeChanged)
8285 #ToolTip(self.StartCombo,200)
83- self .txt = Entry (f ,width = 20 )
84- self .txt .grid (row = 4 , column = 2 ,sticky = 'W' )
86+ self .DelayTxt = Entry (f ,width = 10 )
87+ self .DelayTxt .grid (row = 4 , column = 2 ,sticky = 'W' )
8588
8689 #------------------- End Schedule --------------------
8790 l = Label (f ,text = 'End Schedule:' )
8891 l .grid (row = 5 ,column = 0 ,sticky = 'W' ,pady = 5 )
8992
90- self .StartCombo = Combobox (f ,state = 'readonly' ,width = 20 )
91- self .StartCombo .grid (row = 5 ,column = 1 ,columnspan = 3 ,sticky = 'W' )
92- self .StartCombo ['values' ] = ('After n Shots' , 'After t Elapsed Time' ,'Date' )
93- self .StartCombo .current (0 )
93+ self .EndCombo = Combobox (f ,state = 'readonly' ,width = 20 )
94+ self .EndCombo .grid (row = 5 ,column = 1 ,columnspan = 3 ,sticky = 'W' )
95+ self .EndCombo ['values' ] = ('After n Shots' , 'After t Elapsed Time' ,'Date' )
96+ self .EndCombo .current (0 )
9497 #self.StartCombo.bind('<<ComboboxSelected>>',self.MeteringModeChanged)
9598 #ToolTip(self.StartCombo,200)
96- self .txt = Entry (f ,width = 20 )
97- self .txt .grid (row = 5 , column = 2 ,sticky = 'W' )
98-
99- #------------------- Filename --------------------
100- l = Label (f ,text = 'Filename ' )
99+ self .EndTxt = Entry (f ,width = 10 )
100+ self .EndTxt .grid (row = 5 , column = 2 ,sticky = 'W' )
101+
102+ #------------------- Directory to save --------------------
103+ l = Label (f ,text = 'Path to save ' )
101104 l .grid (row = 6 ,column = 0 ,sticky = 'W' ,pady = 5 )
105+ self .Directory = './'
106+ self .DirectoryButton = Button (f ,text = 'Select' ,width = 10 , command = self .AskDirectoryToSave )
107+ self .DirectoryButton .grid (row = 6 ,column = 2 ,sticky = 'W' )
108+ self .DirectoryLbl = Label (f ,text = str (self .Directory ))
109+ self .DirectoryLbl .grid (row = 6 ,column = 1 ,sticky = 'W' ,pady = 5 )
110+
111+ #------------------- Base Filename --------------------
112+ l = Label (f ,text = 'Base FileName' )
113+ l .grid (row = 7 ,column = 0 ,sticky = 'W' ,pady = 5 )
114+ self .BaseTxt = Entry (f ,width = 20 )
115+ self .BaseTxt .grid (row = 7 , column = 1 ,sticky = 'W' )
116+ self .BaseTxt .insert (0 , "photo" )
117+ #------------------- Append to Filename --------------------
118+ l = Label (f ,text = 'Append to filename:' )
119+ l .grid (row = 7 + 1 ,column = 0 ,sticky = 'W' ,pady = 5 )
120+
121+ self .AppendCombo = Combobox (f ,state = 'readonly' ,width = 20 )
122+ self .AppendCombo .grid (row = 7 + 1 ,column = 1 ,columnspan = 3 ,sticky = 'W' )
123+ self .AppendCombo ['values' ] = ('_nnn' , '_Date_Time' ,'_Date_Time_nnn' )
124+ self .AppendCombo .current (1 )
125+ #self.StartCombo.bind('<<ComboboxSelected>>',self.MeteringModeChanged)
126+ #ToolTip(self.StartCombo,200)
102127
128+ #------------------- File Extension--------------------
129+ l = Label (f ,text = 'Extension:' )
130+ l .grid (row = 7 + 1 + 1 ,column = 0 ,sticky = 'W' ,pady = 5 )
103131
104- self .txt = Entry (f ,width = 20 )
105- self .txt .grid (row = 6 , column = 1 ,sticky = 'W' )
106-
107-
132+ self .ExtensionCombo = Combobox (f ,state = 'readonly' ,width = 20 )
133+ self .ExtensionCombo .grid (row = 7 + 1 + 1 ,column = 1 ,columnspan = 3 ,sticky = 'W' )
134+ self .ExtensionCombo ['values' ] = ('.png' ,'.jpg' )
135+ self .ExtensionCombo .current (0 )
136+ #self.StartCombo.bind('<<ComboboxSelected>>',self.MeteringModeChanged)
137+ #ToolTip(self.StartCombo,200)
138+ #------------------- Capture Scripts --------------------
139+ f1 = ttk .LabelFrame (self ,text = 'Scripts' )
140+ f1 .grid (row = 8 + 1 ,column = 0 ,sticky = 'NEWS' , pady = 5 )
141+
142+ #------------------- Before Capture Script --------------------
143+ self .BeforeFile = 'Nothing Selected'
144+ l = Label (f1 ,text = 'Execute before each capture:' )
145+ l .grid (row = 8 ,column = 0 ,sticky = 'W' ,pady = 5 )
146+ self .BeforeFileButton = Button (f1 ,text = 'Select File' ,width = 10 , command = self .OpenBeforeFileDialog )
147+ self .BeforeFileButton .grid (row = 8 ,column = 1 ,sticky = 'W' )
148+ self .BeforeFileLbl = Label (f1 ,text = str (self .BeforeFile ))
149+ self .BeforeFileLbl .grid (row = 9 ,column = 0 ,sticky = 'W' ,pady = 5 )
150+
151+ #------------------- After Capture Script --------------------
152+ self .AfterFile = 'Nothing Selected'
153+ l = Label (f1 ,text = 'Execute after each capture:' )
154+ l .grid (row = 10 ,column = 0 ,sticky = 'W' ,pady = 5 )
155+ self .AfterFileLbl = Label (f1 ,text = str (self .AfterFile ))
156+ self .AfterFileLbl .grid (row = 11 ,column = 0 ,sticky = 'W' ,pady = 5 )
157+ self .AfterFileButton = Button (f1 ,text = 'Select File' ,width = 10 , command = self .OpenAfterFileDialog )
158+ self .AfterFileButton .grid (row = 10 ,column = 1 ,sticky = 'W' )
159+
160+
161+ #------------------- Start Button --------------------
162+ self .Started = False
163+ self .StartButton = Button (self ,text = 'Start' ,width = 10 , command = self .ToggleTL )
164+ self .StartButton .grid (row = 15 ,column = 0 ,sticky = 'NEWS' )
165+
166+ def OpenBeforeFileDialog ( self ):
167+ self .BeforeFile = filedialog .askopenfilename ()
168+ if self .BeforeFile is not None :
169+ self .BeforeFileLbl .configure (text = str (self .BeforeFile ))
170+ pass
171+ def OpenAfterFileDialog ( self ):
172+ self .AfterFile = filedialog .askopenfilename ()
173+ if self .AfterFile is not None :
174+ self .AfterFileLbl .configure (text = str (self .AfterFile ))
175+ pass
176+ def AskDirectoryToSave ( self ):
177+ self .Directory = filedialog .askdirectory ()
178+ if self .Directory is not None :
179+ self .DirectoryLbl .configure (text = str (self .Directory ))
180+ pass
181+
108182 def CaptureLowLight ( self ):
109183 self .camera .capture ('foo.jpg' )
110184 pass
111185 def ReadEntry ( self ):
112- self .res = "Welcome to " + self .txt .get ()
186+ self .res = "Welcome to " + self .BaseTxt .get ()
113187 pass
188+ def ToggleTL ( self ):
189+ self .Started = not self .Started
190+ if self .Started :
191+ self .StartButton .configure (text = 'Stop' )
192+ else :
193+ self .StartButton .configure (text = 'Start' )
194+ self .camera .capture (str (self .Directory + self .BaseTxt .get ()+ self .ExtensionCombo .get ()))
195+ self .Started = not self .Started
196+ if self .Started :
197+ self .StartButton .configure (text = 'Stop' )
198+ else :
199+ self .StartButton .configure (text = 'Start' )
200+ pass
114201 def Clear ( self ):
115202 pass
116- def Clear ( self ):
117- self .combo .get ()
118- pass
203+ def TogglePersistentSettings ( self ):
204+ pass
205+ def ToggleUseVideoPort ( self ):
206+ pass
119207 def StartDelayCapture ( self ):
120208 pass
121209 #### TODO: Implement Reset NEEDS LOTS OF WORK!!
0 commit comments