one-time blog

less is more. more or less

QPython - How To Start

| Comments

You wanna stop programming and start living start programming on Android but hate Java have no Java skills? It's easy!

Just go to Google Play Market and install QPython on your device. QPython is Python implementation for Android. It is based on Scripting Layer for Android (SL4A), but as for me, it is a bit more comfortable.

If you hate Python as well, you can install SL4A itself along with Perl, JRuby, Lua, BeanShell, JavaScript, Tcl, or shell instead. Go to that page and follow instructions.

After you installed QPython, start it in the usual way by tapping its icon in the menu. Screenshot on the top of this post shows what you should see when QPython just started.

By tapping the big button with Python logo in the center of the screen you can (1) launch any local script or project, (2) get script from QR code (funny brand new way to share and distribute your code).

If you swipe to the left instead of tapping, you will see another (second) main screen of QPython. As for me, it is much more useful and comfortable for developer.

Tools available here:

  • Console — yes, it's regular Python console, feel free to comunicate with interpreter directly
  • Editor — QPython has a nice text editor integrated with the rest, you can write code and run it without leaving the application
  • My QPython — here you can find your scripts and projects
  • System — maintain libraries and components: install and uninstall them
  • Package Index opens the page QPyPI in browser allowing to install packages listed there
  • Community leads to QPython Questions page. Signup and feel free to ask and answer questions in the community.

Next, let's see the console and the editor.

As I said before, there is an ordinary Python console. Many people usually use it to explore objects' properties, consult about syntax and test their ideas. You can type your commands directly and Python interpreter will execute them. You can open additional consoles by tapping the plus button (1) and use drop-down list on the upper left corner to switch between consoles (2). To close the console just tap the close button (3).

Please note, there will be notification in the notification bar unless you explicitly close the console and you always can reach the open console by tapping the notification.

The editor allows you obviously (hello Cap!) enter and modify text. Here you can develop your scripts, save them and execute. The editor supports Python syntax highlighting and shows line numbers (there is no ability to go to the line by number though).

When typing, you can easily control indentation level (which is critical for Python code) using two buttons on the toolbar (1). Next buttons on the toolbar are Save and Save As (2), then goes Run (3), Undo, Search, Recent Files and Settings buttons. Also there are two buttons on the top: Open and New (5).

When saving, don't forget to add .py estension to the file name since the editor don't do it for you.

That's it for now. Next time we'll try to write a short "helloworld" program and test it using QPython.

Comments

comments powered by Disqus