Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PoC PyScript Interactive Interpreter #355

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions _sources/index_en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Contents:
challenges/Reto03_en.rst
challenges/Reto04_en.rst
challenges/Reto05_en.rst
poc/poc_en.rst



26 changes: 26 additions & 0 deletions _sources/poc/_static/component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<div>
<iframe
height="500px"
width="100%"
srcdoc='
<html>
<head>
<title>PyFront - Simple</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css" />
<script defer src="https://pyscript.net/latest/pyscript.js"></script>
<style>
.py-repl-run-button{opacity: 1;}
</style>
</head>
<body>
<py-config>
packages = ["numpy", "pandas", "matplotlib"]
terminal = true
</py-config>

<py-repl> </py-repl>
</body>
</html>'
></iframe>
</div>
52 changes: 52 additions & 0 deletions _sources/poc/poc_en.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
========================================
PyScript - Running Python in the Browser
========================================

Introduction to PyScript
-------------------------
PyScript is a Python interpreter that runs in the browser. It is based on Piodide and supports all the modules that are available in Piodide.
PyScript is a great tool for learning Python, experimenting with Python code, and sharing Python code with others.
PyScript is open source and can be used for free.

Getting Started
---------------
To get started with PyScript, you can simply start typing Python code in the code editor below.
You can run the code by pressing ``Shift + Enter`` on your keyboard. I plan to add a run button later.

PyScript provides an interactive Python shell that you can use to run Python code.
It is Provided by ``py-repl`` tag, this has been changed to ``script type="py-editor"`` in the latest release.
I plan to use the latest stable release but for this POC we'll stick to ``py-repl`` tag.

Feel free to interact with the Python shell and run Python code in the code editor below.
Happy coding!

Useful Information
------------------
Try Running the code below to see a simple example of Python code running in the browser.
This uses the ``matplotlib``, ``numpy``, and ``pandas`` library to plot a graph.
A Brython environment can not run this code, but PyScript can.

.. code:: python

import pandas as pd
import matplotlib.pyplot as plt

# Sample data
data = {
'Year': [2010, 2011, 2012, 2013, 2014],
'Sales': [1000, 1500, 1800, 2000, 2100]
}

# Create DataFrame
df = pd.DataFrame(data)

# Plotting using Pandas and Matplotlib
df.plot(x='Year', y='Sales', kind='line', marker='o', color='skyblue')
plt.title('Sales Over Years')
plt.xlabel('Year')
plt.ylabel('Sales ($)')
plt.grid(True)
display(plt)

.. raw:: html
:file: ./_static/component.html
Loading