#Render import Tkinter import Tkconstants from time import sleep WIDTH = 600 HEIGHT = 600 def render(map): global root, canvas, WIDTH, HEIGHT canvas.delete(all) d,m = {},{} for k in map.keys(): register(d, len(map[k]), k) c = d.keys() c.sort() c.reverse() y = 0 dy = HEIGHT/(len(c) + 1) for k in c: cities = d[k] x = 0 dx = WIDTH/(len(cities) + 1) y += dy for city in cities: x += dx m[city] = (x,y) canvas.create_text(x, y, text=city) for k in m.keys(): for c in map[k]: canvas.create_line(m[c[0]], m[k]) root.update() while True: root.update() return #End render def register(d, key, val): if key in d.keys(): d[key].append(val) else: d[key] = [val] root = Tkinter.Tk() canvas = Tkinter.Canvas(root, { 'width' : WIDTH, 'height' : HEIGHT, 'background' : 'white' }) canvas.pack()