Exemple #1
0
	def __init__(self, root):
		self.cur_imgs = [] # backup references against garbage coll.
		self.img_reg = {} # registry to avoid disk access
		self.thmb_reg = {} # thumbnail registry to avoid resize
		self.preview_reg = {} # preview registry to avoid resize
		self.mode = Browser.BROWSE
		self.redraw = False # set true to redraw gui
		self.changes = False # changes to be saved?
		self.new_votes = set() # keep track of new ratings
		self.pool=[]
		# TODO: selection: GUI indicator must be present for selection state,
		# selection must be viewable in its entirety in dedicated view mode,
		# selection should probably be of type set.
		self.selection=[] # selection for exports or queries
		# compare new pictures with favorites
		favs = picture.starred()[:10]
		newsies = [p for p in picture.pictures() if p.reviewed < 1]
		if len(newsies)>0 and len(favs)>0:
			print 'calculating similarities between {} new images and highest rated'.format(
				len(newsies))
			self.new_votes = set(favs)
			for n in newsies:
				for p in favs:
					if n != p:
						sim = p.similarity(n)
						if sim > .6:
							picture.connect(n, p, sim)
			print 'done doing that.'
		# merge candidates for currentlt selected image
		self.merge_candidates=[]
		# img clusters
		self.clusters=[]
		# init img tracking
		self.repool()
		#pics = sorted(pics, key=lambda p:p.rating)
		# repopulate history
		self.hist = []
		for p in picture.last_reviewed()[:50]:
			if util.days_since(p.reviewed)<1.5:
				self.hist.append(p)
				if p in self.pool:
					self.pool.remove(p)
		# choose image to displ
		if len(self.hist)<1 and len(self.pool)>0:
			self.choose(self.pool.pop()) # current image as Pict object
			self.hist = [self.img] # history of recent images
		elif len(self.hist)>0:
			self.img = self.hist[0]
		# self.trash
		# key: pict instance, value: (path, image)
		self.trash = {}
		# canvas
		self.cnv = tk.Canvas(root, bg="black")
		self.cnv.pack(side='top', fill='both', expand='yes')
		# put a button on the image panel to test it
		#self.button = tk.Button(self.cnv, text='button2')
		#self.button.pack(side='top')
		self.merge_candidates = self.merge_cand()
		self.display()
Exemple #2
0
	def page_up(self, key):
		if key in [81,112]:
			if self.img.rating < 6:
				self.img.rating += 1
				self.changes = True
				self.new_votes.add(self.img)
				if len(self.img.relates)<1:
					for p in picture.starred():
						if not p == self.img:
							sim = self.img.similarity(p)
							if sim > .5:
								picture.connect(self.img,p,sim)
				self.redraw=True