Let's play Hangman!

Guess the fruit.


I am currently learning to use pyscript. The aim of this exercise was to bypass flask/javascript and just use pure pyscript, python, and html/css.

This proved fine until loading images. Somethings are hard without javascript, but was a worthy exercise to see how far I could push python within pyscript for now. It is impossible to use images as pyscript has limited libraries available, it's main libraries in pyodide are NumPy, Pandas, SciPy, Matplotlib and Scikit-learn. Requiring asyncio for installation as of 2023. Trying to use matplotlib, scikit-image, pillow, os, micropip, urlopen, io, base64, requests, etc were all unable to yeild the result of having the image load in pyscript due to the limitations of its libraries.

Running a base code like:

def display_image():
img_url = 'https://python-hangman.pages.dev/images/hangman1.png'
img_tag = f''
pyscript.write('image-container', img_tag)
# Call the function to display the image
display_image()

Will have the image load, but fails to have it embed, instead just printing it as a string.

< img src="https://python-hangman.pages.dev/images/hangman1.png">

The above being it's printout on a html page.

So I have abandoned this until later.