Exemplo n.º 1
0
	def get_settings_window(self,title,pos,settings):
		window=Window(title)
		window.child=Table(2,1)
		window.topleft=pos
		window.depth=1

		def brightness_changed(scale,label):
			self.settings.brightness=scale.value
			label.text='%3.2f'%self.settings.brightness
		def brightness_toggle_changed(toggle):
			self.settings.brightness_enable=not toggle.active
		def contrast_changed(scale,label):
			self.settings.contrast=scale.value
			label.text='%3.2f'%self.settings.contrast
		def contrast_toggle_changed(toggle):
			self.settings.contrast_enable=not toggle.active
		def threshold_changed(scale,label):
			self.settings.threshold=scale.value
			label.text='%d'%self.settings.threshold
		def threshold_toggle_changed(toggle):
			self.settings.threshold_enable=not toggle.active
		def points_toggle_changed(toggle):
			self.settings.points_enable=not toggle.active

		#Setup the slider table
		slider_table=Table(4,4)
		window.child.add_child(0,0,slider_table)

		brightness_label=Label('Brightness:')
		brightness_toggle=ToggleButton('')
		brightness_value_label=Label('')
		brightness_scale=HScale(0,2,0.1)
		brightness_scale.connect_signal(SIG_VALCHANGED,brightness_changed,brightness_scale,brightness_value_label)
		brightness_toggle.connect_signal(SIG_CLICKED,brightness_toggle_changed,brightness_toggle)

		slider_table.add_child(0,0,brightness_label)
		slider_table.add_child(0,1,brightness_toggle)
		slider_table.add_child(0,2,brightness_scale)
		slider_table.add_child(0,3,brightness_value_label)

		brightness_toggle.active=True
		brightness_scale.value=self.settings.brightness

		contrast_label=Label('Contrast:')
		contrast_toggle=ToggleButton('')
		contrast_value_label=Label('')
		contrast_scale=HScale(0,2,0.1)
		contrast_scale.connect_signal(SIG_VALCHANGED,contrast_changed,contrast_scale,contrast_value_label)
		contrast_toggle.connect_signal(SIG_CLICKED,contrast_toggle_changed,contrast_toggle)

		slider_table.add_child(1,0,contrast_label)
		slider_table.add_child(1,1,contrast_toggle)
		slider_table.add_child(1,2,contrast_scale)
		slider_table.add_child(1,3,contrast_value_label)

		contrast_toggle.active=True
		contrast_scale.value=self.settings.contrast

		threshold_label=Label('Threshold:')
		threshold_toggle=ToggleButton('')
		threshold_value_label=Label('')
		threshold_scale=HScale(0,255,1)
		threshold_scale.connect_signal(SIG_VALCHANGED,threshold_changed,threshold_scale,threshold_value_label)
		threshold_toggle.connect_signal(SIG_CLICKED,threshold_toggle_changed,threshold_toggle)

		slider_table.add_child(2,0,threshold_label)
		slider_table.add_child(2,1,threshold_toggle)
		slider_table.add_child(2,2,threshold_scale)
		slider_table.add_child(2,3,threshold_value_label)

		threshold_toggle.active=True
		threshold_scale.value=self.settings.threshold

		points_label=Label('Transform:')
		points_toggle=ToggleButton('')
		points_toggle.connect_signal(SIG_CLICKED,points_toggle_changed,points_toggle)

		slider_table.add_child(3,0,points_label)
		slider_table.add_child(3,1,points_toggle)

		points_toggle.active=True
		points_toggle.active=True

		def reset_settings(brightness_scale,brightness_toggle,contrast_scale,contrast_toggle,threshold_scale,threshold_toggle,points_toggle,settings):
			settings.brightness=1.0
			settings.brightness_enable=True
			settings.contrast=1.0
			settings.contrast_enable=True
			settings.threshold=100
			settings.threshold_enable=True
			settings.points.clear()
			settings.points_enable=True

			brightness_scale.value=settings.brightness
			contrast_scale.value=settings.contrast
			threshold_scale.value=settings.threshold

			brightness_toggle.active=settings.brightness_enable
			contrast_toggle.active=settings.contrast_enable
			threshold_toggle.active=settings.threshold_enable
			points_toggle.active=settings.points_enable

		reset_button=Button('Reset')
		reset_button.connect_signal(SIG_CLICKED,reset_settings,brightness_scale,brightness_toggle,contrast_scale,contrast_toggle,threshold_scale,threshold_toggle,points_toggle,self.settings)

		window.child.add_child(1,0,reset_button)

		reset_settings(brightness_scale,brightness_toggle,contrast_scale,contrast_toggle,threshold_scale,threshold_toggle,points_toggle,self.settings)

		return window
Exemplo n.º 2
0
	def get_surface_window(self,title,pos,surface):
		window=Window(title)
		window.child=ImageMap(surface)
		window.topleft=pos
		window.depth=1
		return window