"Writing your first Ubuntu app" session at the Ubuntu Open Week

David Planella david.planella at ubuntu.com
Mon Oct 24 11:56:52 UTC 2011

Hi all,

Last week was Ubuntu Open Week [1], and we had some app development
content with a session I ran on writing a very simple "Ubuntu rocks!"

People who attended and wrote the code seemed to be quite excited about
how easy is to get started writing an app in Ubuntu. I just thought I'd
share the session transcript with the list (here [2] and inline).


[1] https://wiki.ubuntu.com/UbuntuOpenWeek/
[2] http://irclogs.ubuntu.com/2011/10/19/%23ubuntu-classroom.html#t16:01

Hello all
Welcome to this introductory session on writing an app for Ubuntu
aka the first step to becoming a full-blown Ubuntu App Developer :)
For those of you who've been to my earlier session a couple of hours ago,
you'll probably know me already and the session was good enough for you
to stick for the second one
so thanks! :)
For anyone joining now, my name is David Planella, and while I generally
work as the Ubuntu Translations Coordinator in the Community team at
this last cycle I've been more and more involved in the app development
It's a new and exciting territory, and I hope you enjoy it as much as I do
What we are going to see today is a very gentle but fast introduction to
writing an app for Ubuntu, with a real and simple example you can play
with on your own time, explore and expand upon
The idea is not to concentrate on the example itself, but rather to get
you familiar with the tools and processes to use and to follow
throughout your app's lifecycle, which hopefully will whet your appetite
for more :)
And also to direct you to the right places to ask for help
The way the session will be structured will be a bit like the developer
journey on the app developer site at developer.ubuntu.com,
so it will be similar to a tour through the site, which is the place
you'll generally go to whenever you need more information or whenever
you submit an app to ultimately be published in the Software Centre.

So something like:

1. Get started
2. Resources
3. Publish
4. Community

Oh, and the developer site is, of course, at http://developer.ubuntu.com
The time is limited, so we'll go into more detail into the more
practical step of getting started, which is more fun, and we'll just say
a few words on the other steps.
If you've got questions during the session, feel free to ask!
just do it on #ubuntu-classroom-chat and prepend them with QUESTION:
let's roll

The tools
Throughout the session we'll be talking about Quickly.
This is what we'll use to create Ubuntu apps. Quickly is nothing else
than a command-line utility which acts as a wrapper around the tools we
chose to be part of the Ubuntu SDK, if you will.
(people seem to like the SDK word)
It provides a set of commands to act as shortcuts to the key actions a
developer most usually needs while writing a piece of software. They are
quite handy, and they really make life easier for you.
Here are some examples of such commands:
$ quickly edit - to open your code files in an editor of your choice
$ quickly debug - to start debugging graphically your application
$ quickly package - to automatically package your app for you
Note that you don't have to use quickly commands if you are already
familiar with the tools. Quickly just provides the glue and a few
shortcuts. So for example using 'quickly save' is the same thing as 'bzr
commit' (the Bazaar command).
You can see a nice overview of the underlying tools and the commands to
activate them here:
The ones you'll see today are Python, Glade and a bit of Bazaar and
Debian packaging, although those two will rather be working in the
The other nice thing about quickly is that it installs all the packages
you'll need to get started hacking on Ubuntu.
(as in hacking a new app)
So if you want to follow along and create your first app, go ahead and:
* Install quickly by opening http://apt.ubuntu.com/p/quickly on your browser
I'm assuming you are using Ubuntu 11.10, but the example app should also
work with Ubuntu 11.04
We'll be writing some code in Python, and while you don't have to be a
Python pro, I'm assuming some familiarity with the language or at least
with another programming language.
(I'll wait for a minute to let you install quickly)
oh, btw, in principle, you can use any combination of tools and
programming languages for Ubuntu apps. It's just that we simply cannot
support every single combination under the sun, so we made a set of
oppinionated choices on the tools we think are best and are best
supported in Ubuntu
and put them together with quickly
So if you create apps with quickly, they'll be easier to create, review
and publish in the Software Centre
ok, let's move on to the fun part :)

Step 1: Get started
So here we are, ready to write our first app, already excited?
This is the stage we get straight to business and put on our developer
hats for some hacking fun. At this point we generally have an idea of
the type of app we want to write and go for the implementation.
In this case, we'll be writing a very very simple 'Hello world!' type of
app, but with a twist: ours will be an 'Ubuntu rocks!' app.
You'll find the code available here for reference:
But we'll write it together
I'm adding the link here, as I say, for reference, and in case you get
lost at some point.
What you see here is the version-controlled version of the app, safely
hosted in Launchpad, the online collaboration tool for developing open
source projects, another of our recommended toolset choices.
I'll be pointing to particular revisions in there to show you the
changes throughout the app creation stage, but you can also download it
to explore it.
You can do that by running the following command on a terminal:
$ bzr branch lp:~dpm/+junk/ubuntu-rocks
(don't type the leading "$", it's just to mark that it's a command)
This will use Bazaar to fetch the code. Don't worry about the amount of
lines of code there: most of it is boilerplate created by quickly.
This corresponds to the first stop in the journey of an Ubuntu App
Developer, of which you can get a taste here:
You can watch the video later, it's short and gets quickly to the point,
but for now, and given that we've already installed the tools, we'll
start writing some code.
Enough talk, now let's get onto it for real!
1. Open a terminal (press the Ctrl+Alt+t key combination)
2. Run the following command (again, don't type the leading "$", it's
just to mark that it's a command):
   $ quickly create ubuntu-application ubuntu-rocks
   -- This will create the boilerplate code for your app, and a first
saved revision, so you can concentrate on other more important things :)
3. Enter the folder where the code lives now, by running:
   $ cd ubuntu-rocks
   -- You'll see all the files Quickly created there. Don't worry too
much about them for now, but you can examine them with the file browser
later on (e.g. typing 'nautilus .' to fire up the file browser in the
4. Next up, we'll modify the AUTHOURS file to indicate we're the authors
of the code. This is needed by some commands later on. Now type the
   $ gedit AUTHORS
5. On the text editor window, add your name and e-mail, then you can
save and close the file
6. In order to keep our work, it is good practice to save revisions from
time to time. Now it's as good a time as ever. You can do that now by
   $ quickly save "Updated authors file"
   -- Now there is a revision identified by a number and the message you
passed quickly saved under revision control. You can always come back to
it if you like.
   -- This corresponds to
   -- What you're looking at there is the state of the files at the
stage I saved my work, which should be similar to yours, apart from a
different e-mail and name, of course :)
7. Now let's add some real code, fire up the text editor to open all the
project files:
   $ quickly edit
Btw, is everyone fine so far? Any questions?
they tell me all fine on #ubuntu-classroom-chat. Cool, let's move on,
then :)
8. Modify the file focused on the editor (__init__.py), as follows:
   * Add an 'import appindicator' statement at the top of the file, so
that we can use the appindicator module
   * Add the following piece of code after the '# Run the application.'
line (use the same indentation!): http://pastebin.ubuntu.com/713330/
   * This corresponds to revision
Compare that revision with your code to ensure they match before saving
So once you've done that:
9. Now try to see if everything went well, run the application:
*drum roll*
   $ quickly run
   * If you didn't get any errors, hooray and congrats! Check out the
new indicator at the top right-hand corner :)
   * If you did get errors, I'd recommend downloading the original app
as explained earlier, or double checking that your code corresponds to
the revision I mentioned on the last step (unfortunately we're tight on
time on this session and can't provide much support)
Any success stories on #ubuntu-classroom-chat?
Yes! We've got a success story!
What you see there is your first ever Ubuntu app with indicator support! \o/
The code is relatively simple, and we just added indicator support
through the indicator API, a menu and a few entries to populate the
indicator. There are comments in the code that explain each bit in more
(3 success stories on #ubuntu-classroom-chat so far!)
10. Now save your app by running:
    $ quickly save "Added an indicator with some entries"
11. Let's modify the UI a bit, to direct people to the indicator and
give you a taste of UI design. Fire up glade, the GUI designer:
    $ quickly design
12. What you see are the widgets that are part of your app's main
window. You can modify them visually with Glade. Go to the widget tree
on the top right-hand side, expand the ubuntu_rocks_window until you
find 'label1' and select it.
13. Now go to the properties dialog below the widget tree and find the
'Label:' property. Change it to something like:
14. Check out that the app runs with your UI changes:
    $ quickly run
Everything allright until here?
I'll have to go a bit faster as we're running out of time, but we're
nearly done anyway
I hear 'like delphi but with python. love it :)' from
#ubuntu-classroom-chat :-)
15. Save the final version of your app:
    $ quickly save "Modified the GUI with a note"
So you're done!
Well done to everyone who made it this far: your first Ubuntu app in
just a few minutes, which is pretty cool
Let's go quickly through the next steps after this

Step 2: Resources
Once you've created your first app, you'll hopefully want to know more,
to see where you can take your newly acquired and shiny app developer
The answer is near: the resources section on developer.ubuntu.com:
There you'll find all the documentation and links to external
documentation you need, including API reference, the platform overview
diagram and tutorials.
This is a very new and growing section, and we need your help. In true
open source style, you can also contribute your tutorials to be featured
in developer.ubuntu.com!
Check out http://developer.ubuntu.com/resources/tutorials/all/

Step 3: Publish
Ultimately, the last step to ensure wide adoption of your app is to
publish it to the Software Centre.
There it can be exposed to our million-wide user base so that they can
enjoy what you've created.
In order to make this easy for you, we're also providing you some tools
to make this incredibly simple for you. Enter My Apps:
An online tool to submit your apps to be published to the Software Center
You'll find more info on the publishing process here:
If you're using quickly, you can use the 'quickly package' or 'quickly
submitubuntu' commands to create packages ready tu upload to My Apps and
be reviewed by the App Review Board, who will check the quality of the
package and applications before being accepted into Ubuntu
You can try the 'quickly package' command with your app already to
produce a working Debian package
You can then click on the resulting package to get Software Centre to
install it on your system
But of course the real deal is when your package ends up in the Software
Centre and gets exposed to all Ubuntu users

Step 4: Community
As I've got not much time left, let me point you to
There you'll find all the info you need to get support, and if you like
to get involved in the app developer community

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 554 bytes
Desc: OpenPGP digital signature
URL: <https://lists.ubuntu.com/archives/ubuntu-app-devel/attachments/20111024/ab9100ae/attachment.pgp>

More information about the Ubuntu-app-devel mailing list