def update(self): results = urllib.request.urlopen(self.url).read().decode() amt_raised = int(self.find_value("Raised", results)[0]) goal = int(self.find_value("Goal", results)[0]) y_bars = amt_raised*335//goal count = 350 while (count > (350-y_bars) and count > 15): pos = (26, count) points = graphics.rectangle_points(pos, 4, 1) self.image.draw_polygon(points, self.color, self.color) count -= 1 if y_bars > 335: y_bars = 335 self.image.draw_image((0, 0), 'burst.gif') self.image.draw_text(amt_raised, (60, 350-y_bars)) self.image.draw_text(goal, (5, 405)) wait = input("PRESS ENTER TO CONTINUE.")
def draw(self, canvas): # x, y are the top left coordinates self.height = max(len(self.inputs), len(self.outputs)) * 15 self.width = 100 canvas.draw_polygon(graphics.rectangle_points((self.x, self.y), self.width, self.height), fill_color = None, filled = 0) canvas.draw_text(self.name, (self.x + 20, self.y)) for i in range(len(self.inputs)): canvas.draw_text('i'+str(i), (self.x + 5, self.y + 15*i)) for j in range(len(self.outputs)): canvas.draw_text('o' + str(j), (self.x + self.width - 20 , self.y + 15*j))
def update(self): results = urllib.request.urlopen(self.url).read().decode() amt_raised = int(self.find_value("Raised", results)[0]) goal = int(self.find_value("Goal", results)[0]) y_bars = amt_raised * 335 // goal count = 350 while (count > (350 - y_bars) and count > 15): pos = (26, count) points = graphics.rectangle_points(pos, 4, 1) self.image.draw_polygon(points, self.color, self.color) count -= 1 if y_bars > 335: y_bars = 335 self.image.draw_image((0, 0), 'burst.gif') self.image.draw_text(amt_raised, (60, 350 - y_bars)) self.image.draw_text(goal, (5, 405)) wait = input("PRESS ENTER TO CONTINUE.")
def add_click_rect(self, pos, width, height, on_click, color='White'): """Construct a rectangle that can be clicked.""" frame_points = graphics.rectangle_points(pos, width, height) frame = self.canvas.draw_polygon(frame_points, fill_color=color) self._click_rectangles.append((pos, width, height, frame, on_click)) return frame