from World import *

class MyWorld(TurtleWorld):
    def setup(self):
        self.ca_width = 400
        self.ca_height = 400

        # left frame
        self.fr(LEFT)
        self.canvas = self.ca(width=self.ca_width, height=self.ca_height,
                              bg='white')
        self.endfr()

        # right frame
        self.fr(LEFT, fill=BOTH, expand=1)

        self.fr()
        self.bu(LEFT, text='Print canvas', command=self.canvas.dump)
        self.bu(LEFT, text='Quit', command=self.quit)
        self.endfr()

class MyTurtle(Turtle):
    pass

class MyTurtleControl(TurtleControl):
    def setup(self):
        w = self.turtle.world

        w.fr(bd=3, relief=SUNKEN)
        w.la(text='Turtle Control')

        # ROW 1
        w.fr(fill=X, expand=1)
        w.bu(LEFT, text=' fd ', command=self.fd)
        self.en_r = w.en(LEFT, fill=X, expand=1, width=5, text='10')
        w.bu(LEFT, text='lt', command=self.turtle.lt)
        w.bu(LEFT, text='rt', command=self.turtle.rt)
        w.endfr()

        # ROW 2
        w.fr(fill=X, expand=1)
        w.bu(LEFT, text='pu', command=self.turtle.pu)
        w.bu(LEFT, text='pd', command=self.turtle.pd)

        colors = 'red', 'orange', 'yellow', 'green', 'blue', 'violet'
        self.mb = w.mb(text=colors[0], fill=X, relief=SUNKEN)
        self.mb.pack(pady=1)
        for color in colors:
            w.mi(self.mb, color, command=Callable(self.color, color))

        w.endfr()

        w.endfr()


world = MyWorld()
bob = MyTurtle(world)
control = MyTurtleControl(bob)

world.mainloop()
