(self)
Sets up a GUI interface within a PyGame Surface
		
		arguments
		None
		
		keyword arguments
		None
		
		returns
		None			--	returns nothing, but draws on self.disp and
						sets self.guisurface
Sets up a GUI interface within a PyGame Surface
		
		arguments
		None
		
		keyword arguments
		None
		
		returns
		None			--	returns nothing, but draws on self.disp and
						sets self.guisurface
Sets up a GUI interface within a PyGame Surface arguments None keyword arguments None returns None -- returns nothing but draws on self . disp and sets self . guisurface
def setup_GUI(self):
		
		"""Sets up a GUI interface within a PyGame Surface
		
		arguments
		None
		
		keyword arguments
		None
		
		returns
		None			--	returns nothing, but draws on self.disp and
						sets self.guisurface
		"""
		
		# directory
		resdir = os.path.join(os.path.split(os.path.abspath(__file__))[0],'resources')
		if not os.path.exists(resdir):
			raise Exception("Error in camtracker.Setup.setup_GUI: could not find 'resources' directory to access button images; was it relocated or renamed, or is the installation of camtracker incorrect?")
		
		# find image paths
		imgpaths = {}
		buttnames = ['1','2','3','up','down','t','space','r','escape']
		buttstates = ['active','inactive']
		for bn in buttnames:
			imgpaths[bn] = {}
			for bs in buttstates:
				filename = "%s_%s.png" % (bn,bs)
				imgpaths[bn][bs] = os.path.join(resdir,filename)
				if not os.path.isfile(imgpaths[bn][bs]):
					print("WARNING: image file '%s' was not found in resources!" % filename)
					imgpaths[bn][bs] = os.path.join(resdir,"blank_%s.png" % bs)
		
		# image positions (image CENTERS!)
		buttsize = (50,50)
		camres = self.tracker.get_size()
		buttpos = {}
		y = self.dispsize[1]/2 + int(camres[1]*0.6)
		buttpos['1'] = int(self.dispsize[0]*(2/6.0) - buttsize[0]/2), y
		buttpos['2'] = int(self.dispsize[0]*(3/6.0) - buttsize[0]/2), y
		buttpos['3'] = int(self.dispsize[0]*(4/6.0) - buttsize[0]/2), y
		buttpos['space'] = int(self.dispsize[0]*(5/6.0) - buttsize[0]/2), y
		
		leftx = self.dispsize[0]/2 - (camres[0]/2 + buttsize[0]) # center of the buttons on the right
		rightx = self.dispsize[0]/2 + camres[0]/2 + buttsize[0] # center of the buttons on the left
		buttpos['up'] = rightx, self.dispsize[1]/2-buttsize[1] # above snapshot half, to the right
		buttpos['down'] = rightx, self.dispsize[1]/2+buttsize[1] # below snapshot half, to the right
		buttpos['t'] = leftx, self.dispsize[1]/2+camres[1]/2-buttsize[1]/2 # same level as snapshot bottom, to the left
		buttpos['r'] = leftx, self.dispsize[1]/2 # halfway snapshot (==halfway display), to the left
		buttpos['escape'] = buttsize[0], buttsize[1] # top left
		
		# new dict for button properties (image, position, and rect)
		self.buttons = {}
		# loop through button names
		for bn in imgpaths.keys():
			# new dict for this button name
			self.buttons[bn] = {}
			# recalculate position
			buttpos[bn] = buttpos[bn][0]-buttsize[0]/2, buttpos[bn][1]-buttsize[1]/2
			# loop through button states
			for bs in imgpaths[bn].keys():
				# new dict for this button name and this button state
				self.buttons[bn][bs] = {}
				# load button image
				self.buttons[bn][bs]['img'] = pygame.image.load(imgpaths[bn][bs])
				# save position and rect
				self.buttons[bn][bs]['pos'] = buttpos[bn]
				self.buttons[bn][bs]['rect'] = buttpos[bn][0], buttpos[bn][1], buttsize[0], buttsize[1]
		
		# save buttsize
		self.buttsize = buttsize
def setup_GUI ( self ) : # directory resdir = os . path . join ( os . path . split ( os . path . abspath ( __file__ ) ) [ 0 ] , 'resources' ) if not os . path . exists ( resdir ) : raise Exception ( "Error in camtracker.Setup.setup_GUI: could not find 'resources' directory to access button images; was it relocated or renamed, or is the installation of camtracker incorrect?" ) # find image paths imgpaths = { } buttnames = [ '1' , '2' , '3' , 'up' , 'down' , 't' , 'space' , 'r' , 'escape' ] buttstates = [ 'active' , 'inactive' ] for bn in buttnames : imgpaths [ bn ] = { } for bs in buttstates : filename = "%s_%s.png" % ( bn , bs ) imgpaths [ bn ] [ bs ] = os . path . join ( resdir , filename ) if not os . path . isfile ( imgpaths [ bn ] [ bs ] ) : print ( "WARNING: image file '%s' was not found in resources!" % filename ) imgpaths [ bn ] [ bs ] = os . path . join ( resdir , "blank_%s.png" % bs ) # image positions (image CENTERS!) buttsize = ( 50 , 50 ) camres = self . tracker . get_size ( ) buttpos = { } y = self . dispsize [ 1 ] / 2 + int ( camres [ 1 ] * 0.6 ) buttpos [ '1' ] = int ( self . dispsize [ 0 ] * ( 2 / 6.0 ) - buttsize [ 0 ] / 2 ) , y buttpos [ '2' ] = int ( self . dispsize [ 0 ] * ( 3 / 6.0 ) - buttsize [ 0 ] / 2 ) , y buttpos [ '3' ] = int ( self . dispsize [ 0 ] * ( 4 / 6.0 ) - buttsize [ 0 ] / 2 ) , y buttpos [ 'space' ] = int ( self . dispsize [ 0 ] * ( 5 / 6.0 ) - buttsize [ 0 ] / 2 ) , y leftx = self . dispsize [ 0 ] / 2 - ( camres [ 0 ] / 2 + buttsize [ 0 ] ) # center of the buttons on the right rightx = self . dispsize [ 0 ] / 2 + camres [ 0 ] / 2 + buttsize [ 0 ] # center of the buttons on the left buttpos [ 'up' ] = rightx , self . dispsize [ 1 ] / 2 - buttsize [ 1 ] # above snapshot half, to the right buttpos [ 'down' ] = rightx , self . dispsize [ 1 ] / 2 + buttsize [ 1 ] # below snapshot half, to the right buttpos [ 't' ] = leftx , self . dispsize [ 1 ] / 2 + camres [ 1 ] / 2 - buttsize [ 1 ] / 2 # same level as snapshot bottom, to the left buttpos [ 'r' ] = leftx , self . dispsize [ 1 ] / 2 # halfway snapshot (==halfway display), to the left buttpos [ 'escape' ] = buttsize [ 0 ] , buttsize [ 1 ] # top left # new dict for button properties (image, position, and rect) self . buttons = { } # loop through button names for bn in imgpaths . keys ( ) : # new dict for this button name self . buttons [ bn ] = { } # recalculate position buttpos [ bn ] = buttpos [ bn ] [ 0 ] - buttsize [ 0 ] / 2 , buttpos [ bn ] [ 1 ] - buttsize [ 1 ] / 2 # loop through button states for bs in imgpaths [ bn ] . keys ( ) : # new dict for this button name and this button state self . buttons [ bn ] [ bs ] = { } # load button image self . buttons [ bn ] [ bs ] [ 'img' ] = pygame . image . load ( imgpaths [ bn ] [ bs ] ) # save position and rect self . buttons [ bn ] [ bs ] [ 'pos' ] = buttpos [ bn ] self . buttons [ bn ] [ bs ] [ 'rect' ] = buttpos [ bn ] [ 0 ] , buttpos [ bn ] [ 1 ] , buttsize [ 0 ] , buttsize [ 1 ] # save buttsize self . buttsize = buttsize