def __init__(self, pxwidth: int, pxheight: int, ncols: int, v_min: int, v_max: int, autoflush=True, title="Chart", background=graphics.color_rgb(255, 255, 255)): self.width = pxwidth self.height = pxheight self.ncols = ncols self.win = graphics.GraphWin("Chart", pxwidth, pxheight, autoflush=autoflush) bkgrnd = graphics.Rectangle(graphics.Point(0, 0), graphics.Point(pxwidth, pxheight)) bkgrnd.setFill(background) self.col_width = pxwidth / ncols self.unit_height = pxheight / (v_max - v_min) self._last_update = time.time()
points = [] for line in csv_file: fields = line.split(",") if len(fields) < 2: continue easting = fields[0] northing = fields[1] if not easting.isdecimal(): continue points.append(geometry.Point(int(easting), int(northing))) return points if __name__ == "__main__": args = cli() pts = read_points(args.csv) win = graphics.GraphWin("Sample", args.width, args.height) path = geometry.PolyLine() for pt in pts: path.append(pt) log.debug("Will plot in area 0..{}, 0..{}".format(args.width, args.height)) view = view_simplify.View(win, path) view.plot("blue") input("Press enter to simplify") simpler = path.approximate(args.tolerance) simple_view = view_simplify.View(win, simpler) simple_view.plot("green") print("Simplified from {} points to {} points".format( len(path._points), len(simpler._points))) input("Press enter to dismiss")
def __init__(self, height=WIN_HEIGHT, width=WIN_WIDTH): """The GameView is associated with a GraphWin""" self.height = height self.width = width self.win = graphics.GraphWin(WIN_TITLE, width, height)
def __init__(self, h_w): self.h_w = h_w self.win = g.GraphWin(title, h_w, h_w)
def __init__(self): self.size = (1000, 1000) self.window = graphics.GraphWin("Map", self.size[0], self.size[1]) self.window.setCoords(0, 0, 500, 500) self.regions = []
from graphics import graphics from shapely import geometry from nation import Nation size = (1000, 1000) window = graphics.GraphWin("Map", size[0], size[1]) window.setCoords(0, 0, 500, 500) nations = [] points = [] graphics_points = [] rect = graphics.Rectangle(graphics.Point(0, 400), graphics.Point(200, 500)) rect.setFill("grey") rect.draw(window) previous_point = None name_box = graphics.Entry(rect.getCenter(), 10) name_box.draw(window) color_box = graphics.Entry(rect.getCenter(), 10) color_box.move(0, -30) color_box.draw(window) while True: clickedPoint = window.getMouse() if 0 < clickedPoint.getX() < 200 and 400 < clickedPoint.getY() < 500: tempNation = Nation(name_box.getText(), color_box.getText(), 1000, points)