Learn to Code via Tutorials on Repl.it!

← Back to all posts
How to use Kivy
h
PaoloAmoroso (139)

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.

Commentshotnewtop
Saibot84 (19)

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.
https://repl.it/@Saibot84/Kivy-Showcase-Polygott-PreInstalled

PaoloAmoroso (139)

@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.

PDanielY (979)

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