Composer

From IPRE Wiki
Jump to: navigation, search
from myro import *
def main():
    win = GraphWin("Myro Composer", 500, 375)
    win.setCoords(0.0, 0.0, 3.75, 5.0)
    
    # Draw the interface
    bg = Rectangle(Point(0.0,0.0), Point(3.75,5.0))
    bg.setFill('white')

    quitbutton = Rectangle(Point(3,.45), Point(3.73,.05))
    quitbutton.setFill('gray')

    quittext = Text(Point(3.35,.25), "Quit")

    eline = Line(Point (0,.5), Point(3.75,.5))
    gline = Line(Point (0,1.5), Point(3.75,1.5))
    bline = Line(Point (0,2.5), Point(3.75,2.5))
    dline = Line(Point (0,3.5), Point(3.75,3.5))
    fline = Line(Point (0,4.5), Point(3.75,4.5))

    etext = Text(Point(.3,.52), "E")
    ftext = Text(Point(.7,1), "F")
    gtext = Text(Point(1.1,1.52), "G")
    atext = Text(Point(1.5,2), "A")
    btext = Text(Point(1.9,2.5), "B")
    ctext = Text(Point(2.3,3), "C")
    dtext = Text(Point(2.7,3.5), "D")
    e2text = Text(Point(3.1,4), "E")
    f2text = Text(Point(3.5,4.52), "F")
    
    bg.draw(win)
    
    eline.draw(win)
    gline.draw(win)
    bline.draw(win)
    dline.draw(win)
    fline.draw(win)
    
    etext.draw(win)
    ftext.draw(win)
    gtext.draw(win)
    atext.draw(win)
    btext.draw(win)
    ctext.draw(win)
    dtext.draw(win)
    e2text.draw(win)
    f2text.draw(win)

    quitbutton.draw(win)
    quittext.draw(win)

    # find out where user has clicked
    while True:
        mouseclick = win.getMouse()
        my = mouseclick.getY()
        mx = mouseclick.getX()
        if mx > 3 and mx < 3.73 and my > .05 and my < .45:
            win.close()
        if my >= .4 and my <= 4.8:
            center = Point(mx,my)
            note = Circle(center, .1)
            note.setFill("black")
            linex = mx + .1
            liney = my
            liney2 = my + 1
            line = Line(Point(linex,liney), Point(linex,liney2))
            line.draw(win)
            note.draw(win)
        if my >= 4.3 and my <= 4.8:
            f2 = makeSong("f6 1/2;")
            robot.playSong(f2)
            wait(.25)
            line.undraw()
            note.undraw()
        elif my >= 3.6 and my <= 4.8:
            e2 = makeSong("e6 1/2;")
            robot.playSong(e2)
            wait(.25)
            line.undraw()
            note.undraw()
        elif my >= 3.4 and my <= 4.8:
            d = makeSong("d6 1/2;")
            robot.playSong(d)
            wait(.25)
            line.undraw()
            note.undraw()
        elif my >= 2.55 and my <= 4.8:
            c = makeSong("c6 1/2;")
            robot.playSong(c)
            wait(.25)
            line.undraw()
            note.undraw()
        elif my >= 2.4 and my <= 4.8:
            b = makeSong("b 1/2;")
            robot.playSong(b)
            wait(.25)
            line.undraw()
            note.undraw()
        elif my >= 1.55 and my <= 4.8:
            a = makeSong("a 1/2;")
            robot.playSong(a)
            wait(.25)
            line.undraw()
            note.undraw()
        elif my >= 1.4 and my <= 4.8:
            g = makeSong("g 1/2;")
            robot.playSong(g)
            wait(.25)
            line.undraw()
            note.undraw()
        elif my >= .55 and my <= 4.8:
            f = makeSong("f 1/2;")
            robot.playSong(f)
            wait(.25)
            line.undraw()
            note.undraw()
        elif my >= .4 and my <= 4.8:
            e = makeSong("e 1/2;")
            robot.playSong(e)
            wait(.25)
            line.undraw()
            note.undraw()
main()