Beeware First Application
In this article, you will be guided through the process of creating beeware first application.
Before you start creating Beeware first application, you need to have Python 3.6 or later installed on your machine.
You’ll also need to install the Beeware toolchain, which includes the following tools:
Tools | Overview |
Briefcase | A command-line tool that helps create and manage native mobile and desktop applications. |
Toga | A cross-platform native GUI toolkit that enables developers to create user interfaces using Python. |
Once you have installed Python and the Beeware toolchain, you’re ready to create your first Beeware application.
Install BeeWare Tools
To begin, you should install Briefcase. It is a tool provided by BeeWare that can not only package your application for distribution to end users but also be used to initiate a new project.
To ensure that you are in the beeware-mrx_tutorial directory you created in Beeware first article with the beeware-mrxenv virtual environment activated, execute the following command:
MacOS
(beeware-mrxenv) $ python -m pip install briefcase
Linux
(beeware-mrxenv) $ python -m pip install briefcase
Windows
(beeware-mrxenv)C:\...>python -m pip install briefcase
BeeWare provides a tool called Briefcase, which serves a dual purpose.
You can use Briefcase to package your application for distribution to end-users, and it can also be utilized to bootstrap a new project.
Bootstrap A New Project
To start your first BeeWare project, you can use the Briefcase new command to create an application.
For instance, you can create an application named “Welcome to Beeware” by running the following command from your command prompt:
MacOS
(beeware-mrxenv) $ briefcase new
Linux
(beeware-mrxenv) $ briefcase new
Windows
(beeware-mrxenv)C:\...>briefcase new
Briefcase will prompt you to provide some information about your new application.
For this tutorial, you can use the following details:
- Formal Name: You can keep the default value, which is “Hello World”.
- App Name: You can also keep the default value, which is “helloworld”.
- Bundle: If you have your own domain, you should enter that domain in reversed order. For instance, if you own “cupcakes.com”, you need to enter “com.cupcakes” as the bundle. If you don’t have your own domain, you can accept the default bundle, which is “com.example”.
- Project Name: You can keep the default value, which is “Hello World”.
- Description: You can keep the default value or come up with your own description if you want to be more creative.
- Author: You need to enter your name in this field.
- Author’s email: You need to enter your email address in this field. This email will be used in the configuration file, help text, and other places where an email address is required when submitting the app to an app store.
- URL: If you have your own domain, you should enter a URL that includes the https:// prefix. If you don’t have your own domain, you can accept the default URL, which is “https://example.com/helloworld”. Note that this URL doesn’t need to exist at this point and will only be used if you publish your app to an app store.
License: You can accept the default license, which is BSD. However, if you have strong feelings about the license choice, you can choose another one. - GUI framework: You can accept the default option, which is Toga (BeeWare’s own GUI toolkit).
Once you’ve followed the tutorial and accepted the default settings, Briefcase will create a project structure for you to utilize. Your file system will resemble something similar to what was described.
beeware-mrx_tutorial/ beeware-mrxenv/ ... helloworld/ CHANGELOG LICENSE README.rst pyproject.toml src/ helloworld/ resources/ helloworld.icns helloworld.ico helloworld.png __init__.py __main__.py app.py tests/ __init__.py helloworld.py test_app.py
You now have a complete application with just the skeleton provided.
Inside the src folder, you’ll find all the necessary code for the application, while the tests folder has an initial test suite.
Additionally, the pyproject.toml file describes how to package the application for distribution.
You can view the configuration details you provided to Briefcase by opening pyproject.toml in an editor.
With the stub application in place, you can now use Briefcase to run the application.
Test App In Dev Mode
Navigate to the helloworld project directory and instruct Briefcase to initiate the project in Developer (or dev) mode.
MacOS
(beeware-mrxenv) $ cd helloworld (beeware-mrxenv) $ briefcase dev [hello-world] Installing requirements... ... [helloworld] Starting in dev mode... ======================================================================
Linux
(beeware-mrxenv) $ cd helloworld (beeware-mrxenv) $ briefcase dev [hello-world] Installing requirements... ... [helloworld] Starting in dev mode... ======================================================================
Windows
(beeware-mrxenv) C:\...> cd helloworld (beeware-mrxenv) C:\...>briefcase dev [hello-world] Installing requirements... ... [helloworld] Starting in dev mode... ======================================================================
The above procedure provides the following GUI windows:
macOS
Linux
Windows
Importance
- The Beeware first app tutorial is aimed at developers interested in using the Beeware toolchain.
- It teaches you how to create, test, and package cross-platform native applications.
- The tutorial walks you through using Beeware’s Briefcase command-line tool.
- You’ll gain experience using tools such as Toga, Beeware’s cross-platform native GUI toolkit, and the Python programming language.
- The tutorial is a great starting point for developing complex applications that can be deployed to multiple platforms, including Windows, macOS, iOS, and Android.
Conclusion
If you’re interested in creating cross-platform native applications using Python, Beeware first app tutorial is an essential resource for you. By following the tutorial’s step-by-step guide and gaining experience with Beeware’s tools such as Toga and Briefcase, you’ll be able to create complex applications that can be deployed to multiple platforms. The tutorial provides a solid foundation for developers looking to create real-world applications and is an excellent starting point for anyone interested in using Beeware’s toolchain. With its user-friendly interface and powerful capabilities, Beeware is a valuable tool for developers who want to create high-quality cross-platform applications with ease.