def Run(): print 'running the inserter' [width, height] = Template.getTemplateData() for sprite in custom_utils.get_working_sprites(): sprite.image = finalImage = Scaling.scale(sprite.image, width, height) sprite.image = finalImage = Bitify.bitify(sprite.image) SaveToPlayerFile.saveSprite(sprite) custom_utils.save_working_sprite(sprite) print 'save to player file' SaveToPlayerFile.savePlayerFile()
def canvasTemplate(self, action): [width, height] = Template.getTemplateData() filename = 'reference_images/player.png' grid_locations = action_grid_map[action] self.image_names = inverse_action_grid_map[action] images = [] #Gets all the images for each action for location in grid_locations: image_location = SaveToPlayerFile.getImagePosition(location[0], location[1]) box = (image_location[0], image_location[1], image_location[0] + width, image_location[1] + height) tempIm = Image.open(filename) tempIm = tempIm.crop(box) images.append(tempIm) #Puts all the possible pictures in a new folder and opens them [possibleIms, self.possible_names] = custom_utils.find_action_images(action) y = 0 #Puts a picture of each step in the action for the user to drag onto for i in range(len(self.image_names)): self.canvas.create_text(200, y, text = self.image_names[i]) y = y + 5 im = ImageTk.PhotoImage(images[i]) label = Tkinter.Label(image = im) label.image = im self.canvas.create_image(200, y, image = label.image, anchor = "nw") y = y + 100 y = 0 #Puts a picture for the possible images for i in range(len(self.possible_names)): self.canvas.create_text(0, y, text = self.possible_names[i]) y = height + 5 im = ImageTk.PhotoImage(possibleIms[i]) label = Tkinter.Label(image = im) label.image = im self.canvas.create_image(0, y, image = label.image, anchor = "nw") y = y + 100 #Updates the canvas self.canvas.resizescrollregion()