def draw_planet(self, planet): # global main_nav, main_canvas, label, planet_images, main_window new_x = self.convert_coordinates_x(planet.loc.x) new_y = self.convert_coordinates_y(planet.loc.y) name_y = self.convert_coordinates_name(planet.loc.y, planet.loc.size) color = self.get_terrain_color(planet.terrain) size = planet.loc.size, planet.loc.size planet_image = Image.open(self.get_terrain_image(planet.terrain)) planet_image.thumbnail(size, Image.ANTIALIAS) planet_image_res = ImageTk.PhotoImage(planet_image) new_planet_image = planet_image_res self.planet_images.append(new_planet_image) label = Label(self.main_canvas) label.config(image=planet_image_res) label.config(background='black') label.grid() label.planet_image_res = planet_image_res # keep a reference! label.place(anchor=CENTER, x=new_x, y=new_y) label.bind("<Button-1>", lambda event, arg=planet: self.controller.select_planet(event, arg)) label_name = Label(self.main_canvas, text=planet.name, fg=self.app.conf.main_text_color, bg='black' , borderwidth=1 , highlightthickness=0) label_name.place(anchor=CENTER, x=new_x, y=name_y) if self.app.conf.debug == 1: print "Drawing planet: [", planet.name, ",", new_x, ",", new_y, ",", planet.loc.size, ",", color, "]"
def draw_planet_highlighted(self, planet): # global main_nav, main_canvas, label, planet_images, main_window new_x = self.convert_coordinates_x(planet.loc.x) new_y = self.convert_coordinates_y(planet.loc.y) name_y = self.convert_coordinates_name(planet.loc.y, planet.loc.size) color = self.get_terrain_color(planet.terrain) size = planet.loc.size, planet.loc.size planet_image = Image.open(self.get_terrain_image(planet.terrain)) planet_image.thumbnail(size, Image.ANTIALIAS) planet_image_res = ImageTk.PhotoImage(planet_image) new_planet_image = planet_image_res self.planet_images.append(new_planet_image) label_planet = Label(self.main_canvas) label_planet.config(image=planet_image_res) label_planet.config(background='black') label_planet.planet_image_res = planet_image_res # keep a reference! label_planet.place(anchor=CENTER, x=new_x, y=new_y) label_planet.bind("<Button-1>", lambda event, arg=planet: self.controller.select_planet(event, arg)) label_name = Label(self.main_canvas, text=planet.name, fg='red', bg='black', borderwidth=1 , highlightthickness=0) label_name.place(anchor=CENTER, x=new_x, y=name_y) if self.app.conf.debug == 1: print "Drawing planet: [", planet.name, ",", new_x, ",", new_y, ",", planet.loc.size, ",", color, "]" # get nearest planet and draw a line if self.has_selected: nearest_planet = self.get_nearest_planet(planet) l = self.get_line_points((planet.loc.x, planet.loc.y) , (nearest_planet.loc.x, nearest_planet.loc.y) , planet.loc.size , nearest_planet.loc.size) self.main_canvas.create_line(l.x1, l.y1, l.x2, l.y2, fill='blue', dash=(4, 4)) self.main_canvas.pack() self.app.debug(("Drawing line:", l.x1, ',', l.y1, ',', l.x2, ',', l.y2)) else: self.app.debug("Line next time") self.has_selected = True