This article covers how to get started with enaml-native and create your first app.
The process is:
miniconda
enaml-native-cli
Instructions for each step is described below.
enaml-native uses the conda
package manager.
Download and run the installer from conda.io/miniconda.html.
Once installed you should be able to run conda --version
from the command line to see which version you have and make sure it was installed correctly.
Next the Android and iOS SDK's need installed.
Tools->Android->SDK Manager
from the menuSDK Platforms
tab, select the latestSDK Tools
tab, select Android SDK Build-Tools <version>
, Android Emulator
, Android SDK Platform-Tools
, and Android SDK Tools
(they should be selected by default)iOS apps can only be built with a mac or macbook running OSX.
You must install xcode
from the App Store before continuing.
The enaml-native-cli is installed with pip
pip install enaml-native-cli
After installing, run enaml-native --help
to see the available commands.
Note: You can install the latest dev version using
pip install git+https://github.com/codelv/enaml-native-cli.git
To create a new project use the cli to init a new project.
# Within the folder of choice
enaml-native create app
Now cd to the destination folder, activate the virtual env, and build the python and ndk libraries.
#: Go into project folder
cd HelloWorld
#: Activate the venv
source activate HelloWorld
Now either start the emulator or plug in a phone and we can run with
enaml-native run-android
If all went well the app should start and display your apps name. If you run into issues, you can ask for help on gitter.
Note: If you get errors, try installing the latest dev version by cloning
git clone https://github.com/codelv/enaml-native.git
and building withconda build enam-native
then installing it withconda install -c local enaml-native
.
You can now make changes to your source code or continue to learn the basics.
Your app's code resides in the src
directory. Any files here get installed on the app.
The view.enaml
contains the UI that is shown, and main.py
is the startup script.
To use 3rd-party python packages in your app they must first be built for
Android or iOS using conda-mobile.
Once built, they can simply be installed into your apps environment:
environment.yml
file under the dependencies sectionenaml-native install
Note: The
enaml-native install
command is just a wrapper forconda install
, you can also useconda install
directly.
Once installed you can rebuild the app and your new packages should be available on the app!
Since rebuilding the app every time you need to make a change is very slow,
enaml-native includes a few dev tools to help speed things up.
Update src/main.py
and change the dev=
line to say dev=server
like
def main():
with enaml.imports():
from activity import MainActivity
Application = get_application()
app = Application(
debug=False, # Uncomment to debug the bridge
dev='server', # Set to 'server', 'remote', an IP address
activity=MainActivity(),
)
app.start()
Now rebuild the app with enaml-native run-android
. Find the IP of your device (over wifi) and go to that ip in your browser at port http://192.168.x.y:8888
and it'll show an editor just like the playground app.
Note: You can also debug using port forwarding over adb with
adb forward tcp:8888 tcp:8888
For other development modes, see Debugging