Skip to content

↑↓ to moveEnter to goEsc to close

← All posts Guide

Python autocomplete online: Pygame suggestions as you type

Open a Python file in Striqr and start typing: the editor suggests names, shows a function's parameters as you call it, and says what a name is when you point at it.

Python autocomplete online: Pygame suggestions as you type

For Python autocomplete online, Striqr's editor uses Pyright, the engine behind VS Code's Python support. It runs in your browser tab, on your own device, and starts as soon as a Python file opens, so it's ready by your first key.

It knows pygame as well as Python itself. Here's how it looks in a fresh Pygame project, and what it does and doesn't know.

An online Python editor with autocomplete, step by step

1. Start a Pygame project

On your dashboard, press New project and choose Pygame game. The menu also offers Blank project, Python and Website.

The New project menu open on the dashboard, with Pygame game among four ways to start

2. Open main.py

The project opens in the editor with main.py. It already holds a small Pygame program, a square you move with the arrow keys, and the preview sits beside your code.

The editor with main.py open, showing a short Pygame program, and the preview beside it

3. Type pygame and a dot

On a new line, type pygame. and a list of pygame's names appears, each marked with what it is, such as a module or a function. The first, Clock, is described beside the list.

Up and Down move through the list, Enter or Tab puts the name in, and Esc closes it. The list opens by itself after a letter or a dot, and Ctrl+Space opens it whenever you want it.

A suggestions list under the typed text pygame., listing Clock, display, draw, event and init, with a note about Clock beside it

4. Call a function to see its parameters

Carry on so the line reads pygame.draw.circle(. Once you type the opening bracket, a box above the line lists its parameters: surface, color, center, radius and width. The one you're typing is in bold, and the box moves on to the next one at each comma.

A box above the line pygame.draw.circle( listing its parameters: surface, color, center, radius and width

5. Find your own names

Delete that line and type clo. The starter program has its own variable called clock, and it comes first, marked as a variable. Your file's own names always come before Python's built-in ones.

We think this is the bit you'll use most once your game grows and you can't remember what you called something.

A suggestions list after typing clo, with the program's own variable clock at the top

6. Point at a name to see what it is

Rest the pointer on a name for half a second. We used screen, and a small box reads (variable) screen: Surface. Pyright worked that out from screen = pygame.display.set_mode(...), which is also why typing screen. lists a Surface's methods, such as fill.

A small box over the word screen reading (variable) screen: Surface

What pygame autocomplete knows

It knows Python's standard library and pygame-ce 2.5.7, the version Pygame games run on in the browser. Other packages get nothing: import numpy gives no suggestions.

It knows the open file and every Python file you've opened since the page loaded. Open helpers.py once, and then import helpers followed by helpers. lists its functions. A file you haven't opened yet isn't known.

There's no list inside a comment or a string. It never adds an import for you, and it doesn't check your code for errors.

Who gets suggestions

Everyone who can edit a project gets them, on a computer or a tablet. Someone who's only looking at your project gets what a name is when they point at it, but no list.

Suggestions are off on phones, where a list over the keyboard gets in the way. The editor has its own phone layout, so you can still open and edit your project there.

There's more on the online code editor page. To start a game straight away, try the Pygame online compiler. We also wrote up the release in Python autocomplete in Striqr, plus editor themes.

Common questions

Is Python autocomplete free in Striqr?
Yes. Everyone who can edit a project gets suggestions, on a computer or a tablet, and you don't need an account to start a project.
Which libraries does it know?
Python's standard library and pygame-ce 2.5.7, plus your own Python files once you've opened them. Other packages, such as numpy, get no suggestions.
How do I open the suggestions list?
It opens by itself after a letter or a dot. Press Ctrl+Space to open it at any time, Enter or Tab to put a name in, and Esc to close it.
Does it show errors in my code?
No. It suggests names, shows a function's parameters and says what a name is, but it doesn't check your code for errors or add imports.
Why are there no suggestions on my phone?
They're off on phones, where a list over the keyboard gets in the way. You can still open and edit your project there, and suggestions work on a tablet.

Written by

Striqr Team

The people building Striqr, the browser workspace where code runs and shares as one link. We write about the product and how people use it.