Linux Tutorial 0 - Hello, world!¶
In this tutorial, you’ll take a really simple “Hello, world!” program written in Python, convert it into a working Linux project.
This tutorial assumes you’ve read and followed the instructions in
Getting Started. This Tutorial is for Linux Users!
* An activated Python 3 virtual environment,
* Briefcase installed in that virtual environment,
Start a new project¶
Let’s get started by using the handy template
$ pip install cookiecutter briefcase $ cookiecutter https://github.com/pybee/briefcase-template
This will ask a bunch of questions of you. We’ll use an app_name of “tutorial_0”, and a formal_name of “Tutorial 0”. Set the other values as you like
You’ll now have a few files in this folder, including
Check out what the provided
tutorial_0/app.py file contains:
(BeeWare)user$ cd tutorial_0 (BeeWare)user$ cat tutorial_0/app.py
def main(): # This needs to return an object that has a main_loop() method. return None
This won’t do much as it is, but we can make it useful.
Add this into the
app.py to make it useful:
class MyApp: def main_loop(self): print("Hello world") def main(): return MyApp()
Create an Linux project¶
It is all ready for using
briefcase. You can invoke it, using:
$ python setup.py linux
to create the Linux app.
Open the project¶
There is a new folder in your project called ‘linux’, which contains the project (tutorial_0). You can open the application by running:
The app should run like this! .. code-block:: bash
- $ ./linux/tutorial_0
- Hello World!
And that is all, you created your first Linux python app!