Learn to Code via Tutorials on Repl.it!

← Back to all posts
How to use Kivy
PaoloAmoroso (192)

I managed to make Kivy work in a GFX REPL.

Just create a Pygame REPL, which is among the Kivy dependencies, and install Kivy with the package manager or by adding kivy to requirements.txt. Starting such a REPL in a new session takes a while to download and build the required libraries, at least several minutes. So be patient.

The attached REPL runs the Kivy Showcase, a demo app that showcases some of Kivy’s features.

It works fine except for a few overlapping widgets in the top bar. And it has some latency issues, but this poor performance is a consequence of the experimental state of GFX. If you adjust the handles along the frames of the panes of the REPL to close all the panes except the app’s, you can use most of the page area. Here’s a screenshot of what it looks like. I look forward to GFX supporting running apps at the full screen size in a separate page, like it’s now possible with text REPLs.

The work of @Saibot84 put me on the right track. He experimented with various ways of running Kivy on Repl.it, for example with Polygott and Python REPLs.

Polygott REPLs get stuck when downloading libraries. So I found that the simplest way of running Kivy is to use a Pygame REPL. Unlike @Saibot84’s Pygame REPLs, however, it’s not necessary to directly add the Kivy dependencies to requirements.txt, only kivy.

Saibot84 (49)

That's awesome, @PaoloAmoroso!

Unfortunately, building Kivy takes quite a while. Running your PyGame repl, it took about 15 minutes to build Kivy. When I ran mine, it crashed countless times. Re-running the code started the whole build from scratch, and it never finished before crashing.

I agree that polygott can be a bit buggy, but here's the same Kivy Showcase, but running on a polygott container where the Kivy wheel is stored (as well as those of its dependencies). This cuts the time to interactive (after clicking run) down from 15 minutes to about 1 minute.

PaoloAmoroso (192)

@Saibot84 You're welcome, thanks to you for the very useful information.

Although I can have a fresh Pygame REPL start the Kivy Showcase demo in around 6 minutes, this is still too much. And my time is shorter likely because of the Hacker plan I have.

Your solution is much better, but not just for the performance improvement. The Kivy project deprecated Pygame, which is eventually going away.

Saibot84 (49)

@PaoloAmoroso I've recently found that the polygott and python containers are now using python 3.8 ... which is not supported by Kivy 1.11.1 and this is preventing the repls from running.

But there is a Kivy version 2.0.0rc3 that works with python 3.8. Here, for example, is a Python3.8 repl (including a local copy of Kivy 2.0.0rc3) that can run the Kivy showcase Kivy-Showcase-Python38-PreInstalled

And to make the python repl run, backing up the wheels isn't necessary, if we use Kivy = "^2.0.0rc3" in pyproject.toml together with

url = "https://kivy.org/downloads/ci/linux/kivy/Kivy-2.0.0rc3-cp38-cp38-manylinux2010_x86_64.whl"

as seen here: Python38-Kivy-200rc3

What I can't figure out is why graphics have stopped working on polygott repls.

PaoloAmoroso (192)

@Saibot84 Thanks for sharing your experience.

ilikeeggz (1)

how the hell.....

HackermonDev (2076)

Moved to Learn since share is for you to share your projects.