Пример #1
0
	def __init__(self, parent, frames_dirpath, clickfnc, msgfnc=None, filter_tupe=(None, None), reqret="pixel"):
		self.parent = parent
		self.frames_dirpath = frames_dirpath
		self.reqret = reqret

		self.image_index = 0


		self.image = WrappedImage(imgpath=path_by_dir_index(frames_dirpath, self.image_index))
		self.frame = Tkinter.Frame(self.parent)
		self.clickfnc = clickfnc
		self.msgfnc = msgfnc



		width, height = self.image.pil_image.size

		self.filtered_status = False
		self.filter_tupe = filter_tupe#filter for each different iso layer
		
		"""
		Tuple(
			1:Filter object with method get_filtered(w_image=WrappedImage(), args).
				This method is used to get filtered version of given wrappedimage.,
			2:Dict of arguments for get_filtered
		)
		"""


		self.canvas = Tkinter.Canvas(self.frame, width=width, height=height)
		self.canvas.bind("<Button-1>", self._get_click)
		self.canvas.create_image(0, 0, image=self.image.tk_image, anchor = "nw")

		self.img_ctrl_bar = Tkinter.Frame(self.frame)
		self.show_last_img_button = Tkinter.Button(self.img_ctrl_bar,
													text="Show Previous Image",
													command=self.show_last_img_cmd)
		self.show_next_img_button = Tkinter.Button(self.img_ctrl_bar,
													text="Show Next Image",
													command=self.show_next_img_cmd)
		self.toggle_filtered_img_button = Tkinter.Button(self.img_ctrl_bar,
													text="Toggle Filter",
													command=self.toggle_filtered_img_cmd)
		self.img_number_entry = Pmw.EntryField(parent=self.img_ctrl_bar,
												command=self.img_number_entry_cmd,
												value=self.image_index)
		
		self.show_last_img_button.grid(row=0,column=0)
		self.show_next_img_button.grid(row=0,column=4)
		self.toggle_filtered_img_button.grid(row=0,column=3)
		self.img_number_entry.grid(row=0,column=1)

		self.img_ctrl_bar.pack()
		self.canvas.pack()
Пример #2
0
	def set_img_by_index(self, new_index):
		try:
			#store old image just in case this fails...
			self.old_image = copy(self.image)

			self.image = WrappedImage(imgpath=path_by_dir_index(self.frames_dirpath, self.image_index))
			self.canvas.create_image(0, 0, image=self.image.tk_image, anchor = "nw")
			self.image_index = new_index
			self.img_number_entry.setvalue(self.image_index)
			if self.filtered_status == True:
				self.set_filter(True)
		except IndexError as e:
			self.msgfnc(str(e))
			self.image = self.old_image