Hey everyone, I wanted to start a new series in dev.to with name can python do that
.
This series aims to cover python libraries which are amazing and beginner friendly. As a part of this series I will include 3 libraries every week. If this seems less in number please feel free to comment the frequency of the articles to be posted. I would love to catch up with the speed.
TLDR;
Libraries we will be glancing today are
- Kivy
- Toga
- Dash
For all those JS fans out there you know you can develop application in Javascript for Mobile (iOS and Android), Desktop(macOS, Linux and Windows) using technologies like Electron, React Native.
Spoiler Alert: React Native for macOS and Windows. Microsoft blog post
Would you be amazed if I say we can do same native application development using Python π€ ππ»
Kivy
Kivy - Open source Python library for rapid development of applications that make use of innovative user interfaces, such as multi-touch apps.
There is an application which was used in Pycon India 2018 which is built entirely on Kivy.
pythonindia / PyCon-Mobile-App
PyCon India App developed with Kivy
PyCon India 2018 Application
Mobile App for PyConIndia
Requirements:
Kivy Installation:
Dependencies-
Install from pip
pip install -r requirements.txt
WIP
To test install kivy and run the following::
$ python eventsapp/main.py -m screen:droid2,portrait -m inspector
$ python3 eventsapp/main.py -m screen:droid2,portrait -m inspector
Help on screens
To change images in app
- Paste/change the image in PyCon-Mobile-App/tools/theming
- Change your directory to PyCon-Mobile-App
- Run command
make theming
This command will aggregate all the png images in your file to one atlas from which the images are loaded.
to make apk prefer linux
- Install buildozer: pip install buildozer
- Edit the buildozer.spec to specify if you have android ndk and sdk, if not they will be automatically be downloaded by the next step.
- Connect your mobile, enable usb debugging, Then goto PyConIndia
folder and type
make apk
Link to a existing vm that can be re-used will be added for convenience.
to make
β¦Toga
Toga uses native system widgets, not themes. When you see a Toga app running, it doesnβt just look like a native app - it is a native app. Applying an operating system-inspired theme over the top of a generic widget set is an easy way for a developer to achieve a cross-platform goal, but it leaves the end user with the mess.
Fun Fact
So, why is it called "Toga"?
When in Rome, do as the Romans do. And what does a Roman wear? A Toga!
Dash
Dash is a Python framework for building analytical web applications. No JavaScript required.Built on top of Plotly.js, React and Flask, Dash ties modern UI elements like dropdowns, sliders, and graphs directly to the python code.
The Dash platform empowers Data Science teams to focus on the data and models, while producing and sharing enterprise-ready analytic apps that sit on top of Python and R models. What would typically require a team of back-end developers, front-end developers, and IT can all be done with Dash.
Follow me so that you won't miss new posts under this series.
Spoiler Alert: Next week we will see a framework with which building data apps would be like eating a pie π₯§
Peace βπ»,
Rohith Gilla
Top comments (9)
Just FYI, if you're hoping to deploy a Kivy application to Linux, you're in for a world of pain. Learned that from personal experience. The problem is that you cannot
pip install
Kivy and its Cython depedency in the same command, breaking nearly every known packaging tool and pattern.PyInstaller
works, but only if you ignore good packaging practice and allow it to bundle nearly everything, wherein it cannot be packaged on Linux portably at all. You'll even notice their official packaging guide does not talk about how to package for Linux.In case anyone is wondering, this wasn't "me". I got help from one of Kivy's core developers (tshirtman), from a primary Snapcraft developer (Alan Pope), one of the core AppImage developers (TheAssassin), and a Debian packaging mentor (pabs) in turn. After months of this, the end conclusion was simple: NOPEnopenopenopenopeNOPEnopenope. (I believe that incident is why the Kivy documentation now fully acknowledges that the Linux wheels are "experimental".) The bug is known, isolated, and documented. It's just harder to fix than anyone anticipated.
Long story short, while Kivy is "compatible" with Linux, it isn't packagable with Linux. Stick with PySide2 for portable desktop UIs.
Oh thanks for the note.
Will keep that in mind.
Btw were you able to deploy the Linux app finally?
Nope! When I have the time, I have to rebuild it in PySide2. Three years wasted.
Ouch π
Thanks for the review, it will help others who are reading the post.
Hello Jason,
Thanks a lot for the life-saving information. I am currently trying to package a Kivy app I developed on my Linux machine and the target machine for the app is windows. How do I go about it?
Thanks once again.
PyInstaller, and lots of prayer.
Why a week consists of 7 days, not less? Waiting for next week's post.
Wow thatβs so nice. Iβm happy that you liked my post.
Iβll make sure my next post is worth all the wait.
Cool Roof Paint - Thanks for sharing the post. I was also looking for the same. You have mentioned and clear all my doubts.