Skip to content

Using AREPL with GUI's

Almenon edited this page Oct 18, 2018 · 18 revisions

You can use arepl for working with gui's like turtle or many others. Each time you edit the code the gui restarts, so to make it less annoying the typing debounce is automatically increased for a longer delay before execution. Or you can switch to execute on save/keybinding.

I also suggest coding it so the gui appears on the side (not blocking your view of your code), like so:

import turtle

turtle.setup(width=500, height=500, startx=-1, starty=0)

turtle.forward(100)
turtle.left(90)

Note that the GUI will steal focus from vscode, so if you do not already know it I highly suggest memorizing the shortcut to switch focus back to the previous application. (alt-tab on windows, command-tab on mac)

Or with PySimpleGui you can use the location paramater:

import PySimpleGUI as sg

# 0,0 is top left
startx = 1000 # A higher value will make the window appear more on the right side of the screen
starty = 0

# window layout - see PySimpleGui documentation for more info
layout = [[sg.Text('Input:')], [sg.Input()], [sg.OK(), sg.Cancel()]]

# spawn the window
event, (input,) = sg.Window('Title', location=(startx,starty)).Layout(layout).Read()

Note on p5: There are some outstanding bugs that will cause p5 animation library to fail. See https://github.com/Almenon/AREPL-backend/issues/31 and https://github.com/Almenon/AREPL-backend/issues/32