Quantcast
Channel: Planet Python
Viewing all articles
Browse latest Browse all 22466

Python Bytes: #295 Flutter + Python GUI Apps?

$
0
0
<p><strong>Watch the live stream:</strong></p> <a href='https://www.youtube.com/watch?v=rJLLixCrFxI' style='font-weight: bold;'>Watch on YouTube</a><br> <br> <p><strong>About the show</strong></p> <p>Sponsored by <a href="http://pythonbytes.fm/foundershub2022"><strong>Microsoft for Startups Founders Hub</strong></a>.</p> <p><strong>Michael #1:</strong> <a href="https://pgjones.dev/blog/faster-routing-2022/"><strong>Faster routing for Flask &amp; Quart</strong></a></p> <ul> <li>Flask and Quart both utilise Werkzeug's HTTP route</li> <li>With the upcoming 2.2 release of Werkzeug this router will be significantly faster, with up to a factor of 5.</li> <li>Better for large sets of routes</li> <li>Micro-benchmarks are unaffected and are unlikely to show a speedup.</li> <li>Started with tree-based radix algorithm</li> <li>Moved to state machine algorithm because of wild cards</li> </ul> <p><strong>Brian #2:</strong> <a href="https://quarto.org/"><strong>Quarto: an open-source scientific and technical publishing system built on Pandoc</strong></a></p> <ul> <li>suggested by Paul Mackenzie</li> <li>Power of Pandoc and Jupyter</li> <li>Build <ul> <li>documents - html, pdf, word</li> <li>presentations - Revealjs, PowerPoint, Beemer</li> <li>websites </li> <li>books - html, pdf, word, epub</li> <li>journal articles - acm, plos, elsevier, acs, jss</li> </ul></li> <li>Publish <ul> <li>GitHub pages, Netlify, …</li> </ul></li> <li>kinda related - <a href="https://ebookfriendly.com/epub-kindle-things-to-know/">Kindle to support ePub</a></li> </ul> <p><strong>Michael #3:</strong> <a href="https://flet.dev"><strong>Fl</strong></a><a href="https://flet.dev"><strong>e</strong></a><a href="https://flet.dev"><strong>t UI</strong></a></p> <ul> <li>via Mikael Honkala</li> <li>New and upcoming UI framework by Feodor Fitzner: <strong>flet</strong>.</li> <li>It has a very interesting stack - a Python client driving a Flutter front-end via a Go server.</li> <li>That sounds complicated, but the developer experience is incredibly simple. Installation is just pip install flet.</li> <li>Here's a quick and stupid but working sample: <pre><code>import time import flet from flet import Column, ElevatedButton, Page, Row, TextField def main(page: Page): text_field = TextField() def clear_field(event): text_field.value = "CLEARING" page.update() time.sleep(1) text_field.value = "" page.update() clear_button = ElevatedButton("Clear the field", on_click=clear_field) page.add(Row([Column([text_field, clear_button])], alignment="center")) page.update() flet.app(target=main) # If you run this, you get a native app window on Mac, Windows or Linux, looking something like this: </code></pre></li> </ul> <p><img src="https://paper-attachments.dropbox.com/s_C04B586155456E4F9A6DBBC0E3C98BB673F4D79145882E8AD80B47B15A25DBCA_1659560371560_flet-example.jpg" alt="" /></p> <ul> <li>While the example is simple, it shows the handling of an event, updating the UI, and even doing a little sleeping between the updates, without having to worry about threads and such.</li> <li><p>What's more important, if you change the last line to:</p> <pre><code> flet.app(target=main, view=WEB_BROWSER) </code></pre></li> <li><p>You get the exact same functionality, but as a web application in a browser, with support for multiple users and deep linking to different parts of the app. All without leaving the comfortable Python world, with its access to all Python libraries, and without having to learn 3 extra, completely different languages (yes, HTML, CSS and JavaScript).</p></li> <li>As this is Flutter, mobile support is in the works, after the basic UI functionality is all there.</li> <li>Check the project front page here: <a href="https://flet.dev">flet.dev</a></li> <li>Jump directly to the currently available controls: <a href="https://flet.dev/docs/controls">flet.dev/docs/controls</a></li> <li>Check couple of tutorials here: <a href="https://flet.dev/docs/tutorials">flet.dev/docs/tutorials</a></li> <li>Or read the plans for the mobile support here: <a href="https://flet.dev/blog/flet-mobile-strategy">flet.dev/blog/flet-mobile-strategy</a></li> </ul> <p><strong>Brian #4:</strong> <a href="https://www.notia.ai/articles/building-an-authenticated-python-cli"><strong>Building an authenticated Python CLI</strong></a></p> <ul> <li>Project that uses click, rich, and OAth for using Twitter API</li> <li>Persistent authentication <ul> <li>requests secret information from user using <code>getpass</code> and <code>input</code> <ul> <li>Client ID, Client Secret, App name</li> </ul></li> <li>fetches bearer token from Twitter API</li> <li>stores token in <code>netrc</code> file</li> </ul></li> <li>I’m not familiar with netrc, so I don’t know if this is a good idea or not. <ul> <li>So I figured I’d ask Michael</li> </ul></li> </ul> <p><strong>Extras</strong> </p> <p>Michael:</p> <ul> <li>New course: <a href="https://training.talkpython.fm/courses/getting-started-with-django"><strong>Django - Getting Started</strong></a></li> </ul> <p><strong>Joke:</strong> <a href="https://twitter.com/pr0grammerhum0r/status/1543972967205556225?s=12&amp;t=9gGvVIDpqOfv22I40TQUzw"><strong>Light touches kingdom</strong></a></p>

Viewing all articles
Browse latest Browse all 22466

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>