def drawState(win, state, color=None): retval = [] for list in states[state]: polygon = Polygon(*[ll2xy(pair[0], pair[1]) for pair in list]) if color is not None: state_colors[state] = Color(color) elif state not in state_colors: state_colors[state] = Color(Myro.pickOne(Myro.getColorNames())) polygon.fill = state_colors[state] polygon.draw(win) retval.append(polygon) return retval
def animate(): while bc.win.isRealized(): bc.animate([Myro.pickOne(*range(4)) for x in range(100)])
x1 = self.left + (count * col_width) + col_off/2 + col_width * .45 y1 = self.height - self.bottom * .75 text = Text((x1, y1), str(bin)) text.fontSize = 12 text.rotate(self.rotate) text.color = Color("black") text.draw(self.win) count += 1 # Draw ticks: for percent in range(0, int(110 + (1.0 - self.use_height) * 200), 10): x = self.left y = self.height - self.bottom - (percent/100 * (self.height - self.top - self.bottom) * self.use_height) tick = Line((x - 10, y), (x, y)) tick.draw(self.win) text = Text((x - 25, y), str(percent/100 * self.max_count)) text.fontSize = 8 text.color = Color("black") text.draw(self.win) text.tag = "rescale" if __name__ == "<module>": #BarChart("test 2", 800, 600, ["1", "2"]) #BarChart("test 3", 640, 480, range(10)) bc = BarChart("Barchart Test #1", 800, 600, [Myro.pickOne(*range(4)) for x in range(100)], x_label="Choice") def animate(): while bc.win.isRealized(): bc.animate([Myro.pickOne(*range(4)) for x in range(100)]) animate()