( self )
Configuration files in python
		There are several ways to do this depending on the file format required.
		ConfigParser [.ini format]
		Write a file like so:
			from ConfigParser import SafeConfigParser
			config = SafeConfigParser()
			config.read('config.ini')
			config.add_section('main')
			config.set('main', 'key1', 'value1')
			config.set('main', 'key2', 'value2')
			config.set('main', 'key3', 'value3')
Configuration files in python
		There are several ways to do this depending on the file format required.
		ConfigParser [.ini format]
		Write a file like so:
			from ConfigParser import SafeConfigParser
			config = SafeConfigParser()
			config.read('config.ini')
			config.add_section('main')
			config.set('main', 'key1', 'value1')
			config.set('main', 'key2', 'value2')
			config.set('main', 'key3', 'value3')
Configuration files in python There are several ways to do this depending on the file format required . ConfigParser [ . ini format ] Write a file like so : from ConfigParser import SafeConfigParser config = SafeConfigParser () config . read ( config . ini ) config . add_section ( main ) config . set ( main key1 value1 ) config . set ( main key2 value2 ) config . set ( main key3 value3 )
def BuildPage ( self ):
		# Setup default folder to save pictures and videos
		f = MyLabelFrame(self,'Set default directories',0,0)

		self.iconCameraBig = PIL.Image.open('Assets/camera-icon.png')
		self.iconCameraBig = ImageTk.PhotoImage(self.iconCameraBig.resize((22,22),Image.ANTIALIAS))
		self.iconVideoBig = PIL.Image.open('Assets/video-icon-b.png')
		self.iconVideoBig = ImageTk.PhotoImage(self.iconVideoBig.resize((22,22),Image.ANTIALIAS))
		self.iconFiles = PIL.Image.open('Assets/files.png')
		self.iconFiles = ImageTk.PhotoImage(self.iconFiles.resize((22,22),Image.ANTIALIAS))

		b = ttk.Button(f,text="Photos...",image=self.iconCameraBig,compound='left',
			command=self.SelectPhotoDirectory,width=7)
		b.grid(row=0,column=0,sticky='W',pady=(5,5))
		ToolTip(b,6000)
		self.PhotoDirLabel = Label(f,foreground='#0000FF',
			text=PreferencesDialog.DefaultPhotoDir,anchor=W)
		self.PhotoDirLabel.grid(row=0,column=1,sticky='EW',padx=10);
		ToolTip(self.PhotoDirLabel,6001)

		b = ttk.Button(f,text="Videos...",image=self.iconVideoBig,compound='left',
			command=self.SelectVideoDirectory,width=7)
		b.grid(row=1,column=0,sticky='W')
		ToolTip(b,6002)
		self.VideoDirLabel = Label(f,foreground='#0000FF',
			text=PreferencesDialog.DefaultVideoDir,anchor=W)
		self.VideoDirLabel.grid(row=1,column=1,sticky='EW',padx=10);
		ToolTip(self.VideoDirLabel,6003)

		b = ttk.Button(f,text="Files...",image=self.iconFiles,compound='left',
			command=self.SelectFilesDirectory,width=7)
		b.grid(row=2,column=0,sticky='W',pady=(5,5))
		ToolTip(b,6004)
		self.FilesDirLabel = Label(f,foreground='#0000FF',
			text=PreferencesDialog.DefaultFilesDir,anchor=W)
		self.FilesDirLabel.grid(row=2,column=1,sticky='EW',padx=10);
		ToolTip(self.FilesDirLabel,6005)

		f = MyLabelFrame(self,'Photo/Video capture formats',1,0)

		ttk.Label(f,text='Photo capture format',padding=(5,5,5,5)) \
			.grid(row=0,column=0,sticky='W')
		self.photoCaptureFormatCombo = Combobox(f,height=15,width=8,
			state='readonly')#,width=15)
		self.photoCaptureFormatCombo.grid(row=0,column=1,sticky='EW')
		self.photoFormats = ['jpeg','png','bmp',
			'gif','yuv','rgb','rgba','bgr','bgra','raw']
		self.photoCaptureFormatCombo['values'] = self.photoFormats
		self.photoCaptureFormatCombo.current( \
			self.photoFormats.index(PreferencesDialog.DefaultPhotoFormat))
		self.photoCaptureFormatCombo.bind('<<ComboboxSelected>>',
			self.photoCaptureFormatChanged)
		ToolTip(self.photoCaptureFormatCombo, msg=6010)
		self.ModFormatParams = ttk.Button(f,text='Params...',
			command=self.ModifyFormatParamPressed,
			underline=0,padding=(5,3,5,3),width=8)
		self.ModFormatParams.grid(row=0,column=2,sticky='W',padx=5)
		ToolTip(self.ModFormatParams, msg=6011)

		ttk.Label(f,text='Video capture format',padding=(5,5,5,5)) \
			.grid(row=1,column=0,sticky='W')
		self.VideoCaptureFormatCombo = Combobox(f,height=15,width=8,
			state='readonly')#,width=15)
		self.VideoCaptureFormatCombo.grid(row=1,column=1,sticky='EW')
		self.videoFormats = ['h264','mjpeg','yuv',
			'rgb','rgba','bgr','bgra']
		self.VideoCaptureFormatCombo['values'] = self.videoFormats
		self.VideoCaptureFormatCombo.current( \
			self.videoFormats.index(PreferencesDialog.DefaultVideoFormat))
		self.VideoCaptureFormatCombo.bind('<<ComboboxSelected>>',
			self.VideoCaptureFormatChanged)
		ToolTip(self.VideoCaptureFormatCombo,6020)
		self.ModVideoFormatParams = ttk.Button(f,text='Params...',
			command=self.ModifyVideoFormatParamPressed,
			underline=0,padding=(5,3,5,3),width=8)
		self.ModVideoFormatParams.grid(row=1,column=2,sticky='W',padx=5)
		ToolTip(self.ModVideoFormatParams,6021)
		# Save / Restore camera settings? This may be a bit to do

		f = MyLabelFrame(self,'Photo/Video naming',2,0)
		Label(f,text='Timestamp format:') \
			.grid(row=0,column=0,sticky='W')
		okCmd = (self.register(self.ValidateTimestamp),'%P')
		self.TimeStamp = MyStringVar(PreferencesDialog.DefaultTimestampFormat)
		e = Entry(f,width=20,validate='all',
			textvariable=self.TimeStamp)
		e.grid(row=0,column=1,sticky='W')
		ToolTip(e,6050)

		image = PIL.Image.open('Assets/help.png')
		self.helpimage = ImageTk.PhotoImage(image.resize((16,16)))
		b = ttk.Button(f,image=self.helpimage,width=10,
			command=self.FormatHelp,padding=(2,2,2,2))
		b.grid(row=0,column=2,padx=5)
		ToolTip(b,6052)

		Label(f,text='Sample timestamp:').grid(row=1,column=0,sticky='W')
		self.TimestampLabel = MyStringVar(datetime.datetime.now() \
			.strftime(PreferencesDialog.DefaultTimestampFormat))
		self.tsl = Label(f,textvariable=self.TimestampLabel,foreground='#0000FF')
		self.tsl.grid(row=1,column=1,columnspan=2,sticky='W')
		ToolTip(self.tsl,6051)
		self.after(1000,self.UpdateTimestamp)

		self.PhotoTimestampVar = MyBooleanVar(PreferencesDialog.PhotoTimestamp)
		self.PhotoTimestamp = Checkbutton(f,text='Include timestamp in photo name',
			variable=self.PhotoTimestampVar, command=self.PhotoTimestampChecked)
		self.PhotoTimestamp.grid(row=2,column=0,columnspan=2,sticky='W')
		ToolTip(self.PhotoTimestamp,6060)

		self.VideoTimestampVar = MyBooleanVar(PreferencesDialog.VideoTimestamp)
		self.VideoTimestamp = Checkbutton(f,text='Include timestamp in video name',
			variable=self.VideoTimestampVar, command=self.VideoTimestampChecked)
		self.VideoTimestamp.grid(row=3,column=0,columnspan=2,sticky='W')
		ToolTip(self.VideoTimestamp,6061)

		e.config(validatecommand=okCmd)
		'''
		Configuration files in python
		There are several ways to do this depending on the file format required.
		ConfigParser [.ini format]
		Write a file like so:
			from ConfigParser import SafeConfigParser
			config = SafeConfigParser()
			config.read('config.ini')
			config.add_section('main')
			config.set('main', 'key1', 'value1')
			config.set('main', 'key2', 'value2')
			config.set('main', 'key3', 'value3')
		'''
		self.photoCaptureFormatChanged(None)
		self.VideoCaptureFormatChanged(None)
def BuildPage ( self ) : # Setup default folder to save pictures and videos f = MyLabelFrame ( self , 'Set default directories' , 0 , 0 ) self . iconCameraBig = PIL . Image . open ( 'Assets/camera-icon.png' ) self . iconCameraBig = ImageTk . PhotoImage ( self . iconCameraBig . resize ( ( 22 , 22 ) , Image . ANTIALIAS ) ) self . iconVideoBig = PIL . Image . open ( 'Assets/video-icon-b.png' ) self . iconVideoBig = ImageTk . PhotoImage ( self . iconVideoBig . resize ( ( 22 , 22 ) , Image . ANTIALIAS ) ) self . iconFiles = PIL . Image . open ( 'Assets/files.png' ) self . iconFiles = ImageTk . PhotoImage ( self . iconFiles . resize ( ( 22 , 22 ) , Image . ANTIALIAS ) ) b = ttk . Button ( f , text = "Photos..." , image = self . iconCameraBig , compound = 'left' , command = self . SelectPhotoDirectory , width = 7 ) b . grid ( row = 0 , column = 0 , sticky = 'W' , pady = ( 5 , 5 ) ) ToolTip ( b , 6000 ) self . PhotoDirLabel = Label ( f , foreground = '#0000FF' , text = PreferencesDialog . DefaultPhotoDir , anchor = W ) self . PhotoDirLabel . grid ( row = 0 , column = 1 , sticky = 'EW' , padx = 10 ) ToolTip ( self . PhotoDirLabel , 6001 ) b = ttk . Button ( f , text = "Videos..." , image = self . iconVideoBig , compound = 'left' , command = self . SelectVideoDirectory , width = 7 ) b . grid ( row = 1 , column = 0 , sticky = 'W' ) ToolTip ( b , 6002 ) self . VideoDirLabel = Label ( f , foreground = '#0000FF' , text = PreferencesDialog . DefaultVideoDir , anchor = W ) self . VideoDirLabel . grid ( row = 1 , column = 1 , sticky = 'EW' , padx = 10 ) ToolTip ( self . VideoDirLabel , 6003 ) b = ttk . Button ( f , text = "Files..." , image = self . iconFiles , compound = 'left' , command = self . SelectFilesDirectory , width = 7 ) b . grid ( row = 2 , column = 0 , sticky = 'W' , pady = ( 5 , 5 ) ) ToolTip ( b , 6004 ) self . FilesDirLabel = Label ( f , foreground = '#0000FF' , text = PreferencesDialog . DefaultFilesDir , anchor = W ) self . FilesDirLabel . grid ( row = 2 , column = 1 , sticky = 'EW' , padx = 10 ) ToolTip ( self . FilesDirLabel , 6005 ) f = MyLabelFrame ( self , 'Photo/Video capture formats' , 1 , 0 ) ttk . Label ( f , text = 'Photo capture format' , padding = ( 5 , 5 , 5 , 5 ) ) . grid ( row = 0 , column = 0 , sticky = 'W' ) self . photoCaptureFormatCombo = Combobox ( f , height = 15 , width = 8 , state = 'readonly' ) #,width=15) self . photoCaptureFormatCombo . grid ( row = 0 , column = 1 , sticky = 'EW' ) self . photoFormats = [ 'jpeg' , 'png' , 'bmp' , 'gif' , 'yuv' , 'rgb' , 'rgba' , 'bgr' , 'bgra' , 'raw' ] self . photoCaptureFormatCombo [ 'values' ] = self . photoFormats self . photoCaptureFormatCombo . current ( self . photoFormats . index ( PreferencesDialog . DefaultPhotoFormat ) ) self . photoCaptureFormatCombo . bind ( '<<ComboboxSelected>>' , self . photoCaptureFormatChanged ) ToolTip ( self . photoCaptureFormatCombo , msg = 6010 ) self . ModFormatParams = ttk . Button ( f , text = 'Params...' , command = self . ModifyFormatParamPressed , underline = 0 , padding = ( 5 , 3 , 5 , 3 ) , width = 8 ) self . ModFormatParams . grid ( row = 0 , column = 2 , sticky = 'W' , padx = 5 ) ToolTip ( self . ModFormatParams , msg = 6011 ) ttk . Label ( f , text = 'Video capture format' , padding = ( 5 , 5 , 5 , 5 ) ) . grid ( row = 1 , column = 0 , sticky = 'W' ) self . VideoCaptureFormatCombo = Combobox ( f , height = 15 , width = 8 , state = 'readonly' ) #,width=15) self . VideoCaptureFormatCombo . grid ( row = 1 , column = 1 , sticky = 'EW' ) self . videoFormats = [ 'h264' , 'mjpeg' , 'yuv' , 'rgb' , 'rgba' , 'bgr' , 'bgra' ] self . VideoCaptureFormatCombo [ 'values' ] = self . videoFormats self . VideoCaptureFormatCombo . current ( self . videoFormats . index ( PreferencesDialog . DefaultVideoFormat ) ) self . VideoCaptureFormatCombo . bind ( '<<ComboboxSelected>>' , self . VideoCaptureFormatChanged ) ToolTip ( self . VideoCaptureFormatCombo , 6020 ) self . ModVideoFormatParams = ttk . Button ( f , text = 'Params...' , command = self . ModifyVideoFormatParamPressed , underline = 0 , padding = ( 5 , 3 , 5 , 3 ) , width = 8 ) self . ModVideoFormatParams . grid ( row = 1 , column = 2 , sticky = 'W' , padx = 5 ) ToolTip ( self . ModVideoFormatParams , 6021 ) # Save / Restore camera settings? This may be a bit to do f = MyLabelFrame ( self , 'Photo/Video naming' , 2 , 0 ) Label ( f , text = 'Timestamp format:' ) . grid ( row = 0 , column = 0 , sticky = 'W' ) okCmd = ( self . register ( self . ValidateTimestamp ) , '%P' ) self . TimeStamp = MyStringVar ( PreferencesDialog . DefaultTimestampFormat ) e = Entry ( f , width = 20 , validate = 'all' , textvariable = self . TimeStamp ) e . grid ( row = 0 , column = 1 , sticky = 'W' ) ToolTip ( e , 6050 ) image = PIL . Image . open ( 'Assets/help.png' ) self . helpimage = ImageTk . PhotoImage ( image . resize ( ( 16 , 16 ) ) ) b = ttk . Button ( f , image = self . helpimage , width = 10 , command = self . FormatHelp , padding = ( 2 , 2 , 2 , 2 ) ) b . grid ( row = 0 , column = 2 , padx = 5 ) ToolTip ( b , 6052 ) Label ( f , text = 'Sample timestamp:' ) . grid ( row = 1 , column = 0 , sticky = 'W' ) self . TimestampLabel = MyStringVar ( datetime . datetime . now ( ) . strftime ( PreferencesDialog . DefaultTimestampFormat ) ) self . tsl = Label ( f , textvariable = self . TimestampLabel , foreground = '#0000FF' ) self . tsl . grid ( row = 1 , column = 1 , columnspan = 2 , sticky = 'W' ) ToolTip ( self . tsl , 6051 ) self . after ( 1000 , self . UpdateTimestamp ) self . PhotoTimestampVar = MyBooleanVar ( PreferencesDialog . PhotoTimestamp ) self . PhotoTimestamp = Checkbutton ( f , text = 'Include timestamp in photo name' , variable = self . PhotoTimestampVar , command = self . PhotoTimestampChecked ) self . PhotoTimestamp . grid ( row = 2 , column = 0 , columnspan = 2 , sticky = 'W' ) ToolTip ( self . PhotoTimestamp , 6060 ) self . VideoTimestampVar = MyBooleanVar ( PreferencesDialog . VideoTimestamp ) self . VideoTimestamp = Checkbutton ( f , text = 'Include timestamp in video name' , variable = self . VideoTimestampVar , command = self . VideoTimestampChecked ) self . VideoTimestamp . grid ( row = 3 , column = 0 , columnspan = 2 , sticky = 'W' ) ToolTip ( self . VideoTimestamp , 6061 ) e . config ( validatecommand = okCmd ) self . photoCaptureFormatChanged ( None ) self . VideoCaptureFormatChanged ( None )