How to get started
We bet that you just can't stand still and want to make some science. Before you start a project with us, you have to learn some basic engineering skills like programming and technical drawing.
First you have to prepare yourself an environment for developing, so please install Linux. We advise you to install Ubuntu, because it's very easy in use and has a big community.
Lets make a speech synthesis GUI app!
You must get familiar with python programing language. Please make the first 10 subjects from this tutorial https://docs.python.org/2/tutorial/ .
When you finish this tutorial, you should learn how to use the PyQt library, to be able to develop apps with a GUI. Please install the QtDesigner software. On Linux just run
sudo apt-get install qt4-designer
We will prepare a simple text reader. Please prepare with QtDesigner the following GUI:
Now please use the pyuic4 converter to translate your .ui file to an executable python .py file. Just type in the terminal : You have to download and install the speech synthesis python library. Extract the library folder and run this command:
sudo python setup.py install
Now you have to prepare your main.py file. In the main.py file we will write a function that plays text using a speech synthesizer. Your main file should look like this:
from gui import *
from functools import partial
engine = pyttsx.init()
QtCore.QObject.connect(ui.pushButton,QtCore.SIGNAL('clicked()'), partial(readText, ui.textEdit.toPlainText()))
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
MainWindow = QtGui.QMainWindow()
ui = Ui_MainWindow()
When you click the Read Text button, you should hear the text.
Congratulations, you just wrote a speech synthesis GUI app!
You can download the tutorial python and .ui files
Programming an android app using python
Sometimes we need to have our app always near us, so it's a nice idea to make it mobile. Our research team members are crazy abour nice ideas, so we'll show you how to develop a mobile app using python.
We are going to see how to compile Python targeting Android with Ubuntu (tested on Ubuntu 14.04) and Buildozer. This process works with others Linux distros, but I’ll need to find the appropriate package. So, let’s start.
I – Installing buildozer
Buildozer itself doesn’t depend on any library, and works on Python 2.7 and >= 3.3. I recommend you to use Python 2.7.
First, we need to download PIP, a tool for installing and managing Python packages.
# apt-get install python-pip
Now, to install buildozer run:
1 pip install --upgrade buildozer
If everything works fine, you will see the output: Successfully installed buildozer
II – Targeting Android
If you target Android, you must install at least Cython, few build libs, and a Java SDK. Some binaries of the Android SDK are still in 32 bits, so you need few 32bits libraries available.
First, we need to install Cython:
1 # pip install --upgrade cython
Now, make the 32 bits lib available:
1 # dpkg --add-architecture i386
After it, you can update and install the necessary packages:
123 # apt-get update# apt-get install build-essential ccache git lib32z1 libncurses5:i386 libstdc++6:i386# apt-get install python2.7 python2.7-dev openjdk-7-jdk unzip zlib1g-dev zlib1g:i386
Ok, now we have everything to start with Python development for Android!! Let’s try it!
III – Simple example
Let’s create a hello world to test if everything is working. In this hello world, I’m going to use kivy. If you don’t have Kivy installed, run the following command:
# apt-get install python-kivy
Now, create a new file with the name main.py, and make sure to add the line __version__ = '1.0' in your file, because buildozer will try to find this line to determine the app version.
To test it, write this simple hello world:
__version__ = '1.0'
from kivy.app import App
from kivy.uix.button import Button
btn = Button(text='Hello World')
1 buildozer init
You can open the buildzoer.spec file and change your app settings, as the name, developer, and this kind of stuff.
To build your project, run:
1 buildozer -v android debug
This command will download python-for-android, Android SDK and Android NDK for you. If it’s the first time that you are building, you can go and drink some coffee, because it need to download a big chain of libs and build it, so if your computer/internet is slow, it can take a long time.
After it, you everything works fine, you will see the message:
# Android packaging done!
# APK MyApplication-1.2.0-debug.apk available in the bin directory
Now, you can get the APK in the bin folder and install it in your device! If your device is connected in the USB, just run:
adb install bin/MyApplication-1.2.0-debug.apk
To install it!
Technical drawing with FreeCAD