Exemplo n.º 1
0
Arquivo: ui.py Projeto: Alligator/evo
def update_on_cr(input):
    global midifocus
    global dnafocus
    if input in ('q', 'Q'):
        raise urwid.ExitMainLoop()
    if input in ('j', 'J'):
        generation.step()
        update()
        pass
    if input in ('r', 'R'):
        restart()
    if input in ('m', 'M'):
        #midi
        midifocus = True
        edit.set_caption('Enter the piece ID: ')
        leftframe.set_focus('footer')
    if input in ('e', 'E'):
        #dna
        dnafocus = True
        edit.set_caption('Enter the piece ID: ')
        leftframe.set_focus('footer')
    if input == 'enter':
        if midifocus:
            piece = edit.get_edit_text()
            try:
                utils.convertToMIDI(generation.get()[int(piece)])
                edit.set_caption('Success')
            except Exception as e:
                edit.set_caption('Invalid ID: ' + str(e))
            edit.set_edit_text('')
            leftframe.set_focus('body')
        if dnafocus:
            piece = edit.get_edit_text
            #utils.convertToMIDI(generation.get()[int(piece)])
            edit.set_caption('Success')
            edit.set_edit_text('')
            leftframe.set_focus('body')
Exemplo n.º 2
0
def newGeneration():
    generation.init()
    print utils.prettyPrint(generation.get(), generation.getScores())
    genMenu()
Exemplo n.º 3
0
def export():
    piece = raw_input("Enter piece ID > ")
    filename = raw_input("Enter a filename > ")
    utils.export(generation.get()[int(piece)], filename)
    print "File written"
Exemplo n.º 4
0
def midi():
    piece = raw_input("Enter piece ID > ")
    utils.convertToMIDI(generation.get()[int(piece)])
Exemplo n.º 5
0
Arquivo: ui.py Projeto: Alligator/evo
def update():
    movetolower()
    currentGen = utils.prettyPrint(generation.get(), generation.getScores())
    content.append(urwid.Text(currentGen))
    updateHeaders()
Exemplo n.º 6
0
Arquivo: ui.py Projeto: Alligator/evo
        ]

text_controls = [
        ('key', ' J'), ('controls', ' - Next Generation\n'),
        ('key', ' R'), ('controls', ' - Start Over\n'),
        '\n',
        ('key', ' M'), ('controls', ' - MIDI Output\n'),
        ('key', ' E'), ('controls', ' - DNA Export\n'),
        '\n',
        ('key', ' Q'), ('controls', ' - Quit')
        ]

midifocus = False
dnafocus = False
generation.init()
currentGen = utils.prettyPrint(generation.get(), generation.getScores())
prevGen = ""

def updateHeaders():
    current = generation.getAge()
    if current == 0:
        prev = 0
    else:
        prev = current-1
    leftheader.set_text([('title', 'Current Generation'), ('title', ' (' + str(current) + ')')])
    leftheader2.set_text([('title', 'Previous Generation'), ('title', ' (' + str(prev) + ')')])

content = [urwid.Text(currentGen)]
leftheader = urwid.Text('')
leftc = urwid.ListBox(content)
edit = urwid.Edit()