Exemplo n.º 1
0
def option_handler(event):
    global is_running, start_button, choice

    is_running = False
    start_button.config(text='Start')

    option = choice.get()

    if option == 'random':
        model.randomize(model.grid_model, model.width, model.height)

    update()
Exemplo n.º 2
0
def option_handler(event):
    global is_running, start_button, choice

    is_running = False
    start_button.configure(text='Start')

    selection = choice.get()

    if selection == 'glider':
        model.load_pattern(model.glider_pattern, 10, 10)
    elif selection == 'glider gun':
        model.load_pattern(model.glider_gun_pattern, 10, 10)
    elif selection == 'random':
        model.randomize(model.grid_model, model.width, model.height)
    update()
Exemplo n.º 3
0
def option_handler(event):
    global is_running, start_button, choice

    is_running = False  #make the simulation stop
    start_button.configure(text='Start')  #then set the button to start

    selection = choice.get()  #assign the chosen option to selection

    if selection == 'glider':
        model.load_pattern(model.glider_pattern, 10, 10)

    elif selection == 'glider gun':
        model.load_pattern(model.glider_gun_pattern, 10, 10)

    elif selection == 'random':
        model.randomize(model.grid_model, model.width, model.height)

    update()
Exemplo n.º 4
0
    grid_view.delete(ALL)

    model.next_gen()
    for i in range(0, model.height):
        for j in range(0, model.width):
            if model.grid_model[i][j] == 1:
                draw_cell(i, j, 'black')


def draw_cell(row, col, color):
    global grid_view, cell_size

    if color == 'black':
        outline = 'grey'
    else:
        outline = 'white'

    grid_view.create_rectangle(row * cell_size,
                               col * cell_size,
                               row * cell_size + cell_size,
                               col * cell_size + cell_size,
                               fill=color,
                               outline=outline)


if __name__ == '__main__':
    setup()
    model.randomize(model.grid_model, model.width, model.height)
    update()
    mainloop()