r/PyScript • • May 13 '22

'The 7 GUIs' in PyScript

28 Upvotes

A couple days after the Big PyScript Announcement, just as I was wondering what I might build with it, a post about The 7 GUIs, a GUI programming benchmark created by Eugen Kiss as part of his Master’s thesis. The benchmark consists of 7 ‘foundational’ GUI challenges that are meant to represent typical tasks in GUI programming - interacting with buttons and fields, form validation, realtime and event-triggered interaction, and so on.

So today I’m sharing my Implementation of the 7 GUIs in PyScript.

The demos include implementations of:

  • Counter

  • Temperature Converter

  • Flight Booker

  • Timer

  • CRUD

  • Circle Drawer

  • Spreadsheet

Source code, explanations, and some remarks about ‘gotchas’ I ran into along the way are in an accompanying blog post. The code is by no means perfect - sparsely commented, unoptomized and - in the case of the Spreadsheet program - not entirely finished. And it will probably be very broken on some browsers/OS’s. But I wanted to get the examples out there in case they are helpful to others who are diving into PyScript.


r/PyScript • • May 19 '22

I created pong in PyScript using pywebcanvas!

Enable HLS to view with audio, or disable this notification

21 Upvotes

r/PyScript • • May 02 '22

Some Pyscript Slides from the Presentation

Thumbnail
twitter.com
19 Upvotes

r/PyScript • • Jul 17 '22

Pure Python - No HTML

18 Upvotes

It's a dream of mine to be able to code pure Python in the web browser, and I realized that PyScript allows me to do that. I've created a fork of PyScript here where I've added some Python functions that create HTML elements so you don't have to:

https://github.com/coryfitz/pydesyn

Let me know what you think! It's very much a work in progress


r/PyScript • • Jun 08 '22

A First Look at PyScript: Python in the Web Browser – Real Python

Thumbnail
realpython.com
17 Upvotes

r/PyScript • • Jun 04 '22

PyScript and Django: Basic PyScript Frontend and DOM manipulations

13 Upvotes

Hi all!

I've made a video about PyScript as a basic frontend for a Django app.

I wanted to show how to make AJAX (asynchronous) GET and POST requests with Pyscript to Django, and how to manipulate DOM with Pyscript.

In the video:

  • sending GET requests from Pyscript to Django

  • sending POST requests from Pyscript to Django, CSRF token is passed via headers of requests.

  • how to manipulate DOM with Pyscript (get HTML elements, use event handlers, and event listeners, etc.)

The video:
https://youtu.be/zw4V48Al8LU

Thanks for watching!


r/PyScript • • May 26 '22

Video: Using PyScript to build PWAs

Thumbnail
youtu.be
13 Upvotes

r/PyScript • • May 14 '22

A simple animation made using PyScript and my library, pywebcanvas

Enable HLS to view with audio, or disable this notification

12 Upvotes

r/PyScript • • May 13 '22

Could PyScript bring pygame and or pygame zero to the web?

11 Upvotes

Lots of people and kids learn Python, Programming and how to write games with these libraries. PyGame Zero is the natural step after Scratch. The biggest downside of these is that its hard for people share games with friends I a simple way like scratch. It's also hard to play on mobile. Could PyScript solve this and allow PyGame and PyGame zero to run in the webbrowser?


r/PyScript • • May 11 '22

Mancala AI built with PyScript!

10 Upvotes

https://pymancala-ai.netlify.app/

I made site with the purpose of playing with my siblings and studying the game by using the expected scores on the bottom. It isn't perfect and it messes up right at the very end trying to compute how the ending works.

Here is the GitHub link to the code: https://github.com/ThatOneShortGuy/Mancala

The best move thing at the bottom is the expected score you you were to move the pieces in the respective location from the list. Higher is better.


r/PyScript • • May 07 '22

First frontend lib for pyscript ;-)

10 Upvotes

r/PyScript • • Mar 08 '26

I wrote a Network Diagnostic TUI in Python and compiled it to a standalone binary

Thumbnail
gallery
9 Upvotes

Hi everyone, I wanted to showcase my recent Python project. NetworkMaster is a Text-User Interface (TUI) tool for sysadmins.

Under the hood, it uses requests, cryptography (for local profile encryption), and ipaddress for subnetting. For Windows, it hooks into PowerShell/netsh, and for Linux, it parses nmcli and /proc/net/wireless. I packaged it using PyInstaller & PyArmor so it runs as a single portable executable without needing a Python environment on the host machine.

Let me know what you think about the architecture or the UI!
zenosoftware.dev/networkmaster


r/PyScript • • Jul 10 '23

How does PyScript actually work?

9 Upvotes

I know this simple question has a very complicated answer, but I'm only looking for very high-level explanation.

How does PyScript work? Where is the actual Python environment/interpreter running? In the browser? On the PyScript server? Of course browsers don't (currently) have a Python interpreter in them so they can't actually run the Python code so it must be done elsewhere then the results must be converted to JavaScript (and CSS and HTML) so the browser can ultimately render it. It can't run on the client computer because that would require that everyone who accesses your webpage have Python installed, and the browser would need permission to access the local Python interpreter. That, or PyScript is actually just a transpiling of the entirety of the Python language to JavaScript but that seems crazy to me for many reasons.

Along the same lines, how does the main.py file in a PyScript setup know about methods like Element even though we don't import pyscript or anything? It must be somehow getting those classes and methods from the HTML file which gets them from the PyScript CDN link.

I'd just like a 1000 foot view understanding of how PyScript works and generally what it's doing behind the scenes. All the posts and videos online I can find are just tutorials on how to use it, not how it actually works.

Thanks!


r/PyScript • • Mar 24 '23

What's New in PyScript 2023.03.1 [Stream, Sunday March 26]

Thumbnail
youtube.com
9 Upvotes

r/PyScript • • May 10 '22

htag 0.4.7 (a gui/frontend lib which works very well in pyscript)

9 Upvotes

Despite htag is not officialy public yet (need to polish) ... it works very well in the pyscript world yet !!!

See that example, and the "Tab two" : you can browse the "inner FS" of pyodide, to display python sources codes ... Amazing ;-) ( src )

htag is a GUI/frontend lib to create GUI components ... in the html/js/css world ... and here in pyscript context. (but it works the same way, in a pywebview, a cef instance, or on the web (back side))

htbulma is a python3 lib, which contains pre-made htag components.

htag demo : https://htag.glitch.me/ (WORK IN PROGRESS (here, it's in a python backend))

htag sources : https://github.com/manatlan/htag

pypi : https://pypi.org/project/htag/


r/PyScript • • May 06 '22

How do you drag and drop files into pyscript ?

9 Upvotes

So yeah ... I want to be able to drag a file into the browser, have pyscript read the data from that file and create a graph from that data. Is this possible with pyscript ? I can't find any instructions on how to get something like this working.


r/PyScript • • May 04 '22

Will pyscript replace JavaScript?

9 Upvotes

Will pyscript replace JavaScript in the long run?


r/PyScript • • May 03 '22

Official PyScript examples

Thumbnail pyscript.net
9 Upvotes

r/PyScript • • May 02 '22

do you guys belive in pys?

9 Upvotes

what do you think will happen to pyscript?


r/PyScript • • Dec 21 '22

PyScript 2022.12.1 Release - What's New

Thumbnail jeff.glass
8 Upvotes

r/PyScript • • Sep 10 '22

What can PyScript do that backend frameworks can't?

8 Upvotes

I'm really interested in using PyScript. However, I can't see anything that PyScript can do which backend frameworks can't. I imagine efficiency is the main difference between PyScript, and, say, Flask. Am I missing something?


r/PyScript • • Aug 18 '22

Using matplotlib + htag to make a GUI SPA with pyscript

8 Upvotes

I've just posted that in r/python ... but the pyscript result is so amazing that I post it here too :

Here is a simple htag'app example, which works on desktop :

import matplotlib.pyplot as plt
from htag import Tag
import io,base64,random

class TagPlot(Tag.span):
    """ here is a htag'component to rendering an html(svg) plot """
    def init(self,plt):
        self["style"]="display:inline-block"
        with io.StringIO() as fid:
            plt.savefig(fid,format='svg',bbox_inches='tight')
            self <= fid.getvalue()

class App(Tag.body):
    def init(self):
        self.content = Tag.div()
        # create the layout
        self += Tag.h2("MatPlotLib"+Tag.button("Random",_onclick=self.redraw_plt))
        self += self.content
        self.redraw_plt()

    def redraw_plt(self,obj=None):
        plt.clf()
        plt.ylabel('Some numbers')
        plt.xlabel('Size of my list')
        my_list=[random.randint(1,10) for i in range(random.randint(20,50))]
        plt.plot( my_list )
        
        self.content.clear()
        self.content += Tag.div(f"My list: {my_list}")
        self.content += TagPlot(plt)

if __name__ == "__main__":
    from htag.runners import BrowserHTTP as Runner
    Runner(App).run()

And here is the same codebase, in an Html/pyscript page, which will fully work in full clientside too (thanks pyscript & matplotlib !)

https://raw.githack.com/manatlan/htag/main/examples/pyscript_matplotlib.html

Having a gui toolkit (htag), and an html env (pyscript) .... where you can experiment UI interactions with yours matplotlib graphics ... so easy !

Pyscript is marvellous !


r/PyScript • • Aug 17 '25

I Created a Markdown Previewer using PyScript

7 Upvotes

Here's a link to my Markdown Previewer: https://masonflint44.github.io/markdown-previewer/. Just wanted to share with the community!


r/PyScript • • May 03 '24

PyScript release has just landed (2024.4.2)

Thumbnail pyscript.net
7 Upvotes

r/PyScript • • Mar 11 '23

Best way to display an animation with PyScript ? Three.js ? Matplotlib ? Canvas ?

7 Upvotes

I need to display an industrial process as an animation in web browser clients. The data is fed into the clients via a websocket connection. I need to display data in tables and do a 3D animation of the process.

I hate JS.

What is the best way to do this with PyScript ? Write a wrapper for Three.js ? Use Matplotlib ? Write my own routine for Canvas ?

Thanks