Free AI web copilot to create summaries, insights and extended knowledge, download it at here
2619
Abstract
ps://pywebio.readthedocs.io/en/latest/input.html#functions-list">list of input functions available</a> here.</p><figure id="f3ab"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*zzR2LwTtR71DIHMN2iNpCA.png"><figcaption>Input functions list.</figcaption></figure><p id="1223">You have seen several examples of these input functions in the preceding example. However, we often tend to group different inputs, and that is what <code>input_group</code> does.</p><p id="f094">Let us revisit our first example and use the <code>input_group</code> function for packaging together different inputs. Note here that we have a name parameter in all inputs. We will later use the name parameter for each input.</p>
<figure id="275f">
<div>
<div>
<iframe class="gist-iframe" src="/gist/shakurgds/15fdf5da342e96a7a835e1a3bbfe88d5.js" allowfullscreen="" frameborder="0" height="undefined" width="undefined">
</div>
</div>
</figure></iframe></div></div></figure><p id="6058">You might have realized that we did not have any output from the preceding example because we have not created any output function yet. PyWebIO has a rich <a href="https://pywebio.readthedocs.io/en/latest/output.html#functions-list">list of output functions</a> that you can refer to.</p><p id="5625">Feel free to explore them but here in this example, I will use only two output functions: <code>put_text</code>and <code>put_table</code>. Note here that we are using the input group with the name of each input to put them into a table.</p>
<figure id="5a88">
<div>
<div>
<iframe class="gist-iframe" src="/gist/shakurgds/29d28fa877d0c4f278812d6965516398.js" allowfullscreen="" frameborder="0" height="undefined" width="undefined">
</div>
</div>
</figure></iframe></div></div></figure><p id="96da">Here is a GIF showing the grouped inputs and output of the preceding example.</p><figure id="9e6e"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*qXcH0TCdqLnqdik8j3YiDA.gif"><figcaption>Input_group and Output with Pywebio.</figcaption></figure><p id="7904">One final example here to show you that you can extend your python code into Pywebio applications easily without changing too much. This example shows a simple function that formats coordinates into a friendly format.</p>
<figure id="0d74">
<div>
<div>
<iframe class="gist-iframe" src="/gist/shakurgds
Options
/a13382012c856da6e3d33e450a4e8f00.js" allowfullscreen="" frameborder="0" height="undefined" width="undefined">
</div>
</div>
</figure></iframe></div></div></figure><p id="48a5">Here is a GIF showing the simple coordinate formatted application with PyWebIO.</p><figure id="e6d6"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*BkgafnMhVhi9YD2nl0lLNQ.gif"><figcaption>Coordinate Formatter with Pywebio</figcaption></figure><h2 id="3a55">Data Visualization</h2><p id="4170">PyWebIO is integrated with <a href="https://pywebio.readthedocs.io/en/latest/libraries_support.html#data-visualization">several data visualization libraries</a>, including Plotly. The following example creates a Plotly map and serves it with PyWebIO.</p>
<figure id="c860">
<div>
<div>
<iframe class="gist-iframe" src="/gist/shakurgds/9a2a30cc174aab7c9d45698b7ceacd93.js" allowfullscreen="" frameborder="0" height="undefined" width="undefined">
</div>
</div>
</figure></iframe></div></div></figure><p id="335c">We transform the Plotly Figure into HTML and then pass it to <code>put_html</code> function from PyWebIO. Make sure also to use <code>.send()</code> if you are using Jupyter Notebook.</p><figure id="524f"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*-FsbKMSiHPea7Fkdd0HR4A.png"><figcaption>Pywebio with Plotly visualization</figcaption></figure><h2 id="1d2f">Conclusion</h2><p id="d858">I loved the simplicity of the PyWebIO functionality and concept. You get input and output functions that enable you to transform your python code into a simple web application on your browser. There are many more to explore in this package, especially that it allows styling your application and serving it.</p><p id="c892">Please refer to the documentation of PyWebIO for further exploration of this beautiful package.</p><div id="036a" class="link-block">
<a href="https://pywebio.readthedocs.io/en/latest/index.html">
<div>
<div>
<h2>PyWebIO - PyWebIO 1.2.3 documentation</h2>
<div><h3>PyWebIO provides a series of imperative functions to obtain user input and output on the browser, turning the browser…</h3></div>
<div><p>pywebio.readthedocs.io</p></div>
</div>
<div>
<div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/)"></div>
</div>
</div>
</a>
</div></article></body>