Today, we are going to see an example for how to use python as back-end in TideSDK. As we have already learnt to create a basic application in TideSDK in a previous post. We will be using the same application to continue here.
First we need to create an app. As soon as we create it, we have a directory called resources, in the directory where we created the app.
In that resources directory, we need following files, some of them will already be there:
Now you need to modify the index.html
In the index file, we are having two input boxes for username and password. And one login button.
Here, we have called another function log_in
logged = window.log_in(username, password)
This is defined in the python script:
In the python script part, we have used
This is the way to include, a python script. The documentation stated way of using Titanium.include() does not work now, you can see the 1.3.1 beta release notes.
For using python script’s functions or classes, we need to declare them in the window object, as the Documentation says,
The following line does this for us,
window.log_in = login.main
For using python in Tide, we have three ways.
We are using the external script. so now you need to create a file named login.py