Quickly

Ubuntu Opportunistic Developers Week March 2010 - Creating an application from scratch with Quickly - Rick Spencer - Mar 1 2010

(01:01:11 PM) rickspencer3: aquarius, that was awesome!
(01:01:39 PM) rickspencer3: since desktopcouch has come on the scene, I hardly persist anything anywhere else
(01:01:52 PM) rickspencer3: it's so easy to use the records api
(01:01:57 PM) rickspencer3: anywho, quickly time
(01:01:59 PM) rickspencer3: ?
(01:02:39 PM) rickspencer3: I have my class notes here:
(01:02:40 PM) rickspencer3: https://wiki.ubuntu.com/UbuntuOpportunisticDeveloperWeek/Quickly/Intro
(01:02:47 PM) rickspencer3: just in case it makes it easier to follow
(01:02:59 PM) rickspencer3: Shall I begin?
(01:03:12 PM) rickspencer3: let's roll
(01:03:19 PM) rickspencer3: so what is Quickly?
(01:03:32 PM) rickspencer3: first, Quickly is a community project that I started in my spare time
(01:03:42 PM) rickspencer3: however, didrocks is the true author
(01:04:05 PM) carlos is now known as Guest88447
(01:04:28 PM) rickspencer3: I call Quickly, among other things, an "Application Templating System"
(01:04:47 PM) rickspencer3: the essence of the project is to provide you boiler plate for the kind of program you want to write
(01:05:10 PM) rickspencer3: so the code that you would have to write for every program of a certain type gets generated for you
(01:05:20 PM) rickspencer3: that part, I call the "boiler plate"
(01:05:25 PM) rickspencer3: but Quickly is also a set of commands
(01:05:49 PM) rickspencer3: the boiler plate is designed to integrate with the Ubuntu Application infrastructure
(01:05:57 PM) rickspencer3: thinks like bzr, launchpad, PPAs, etc...
(01:06:03 PM) rickspencer3: and the commands are what make all that work
(01:06:26 PM) rickspencer3: The moto of Quickly is "Easy and Fun"
(01:06:32 PM) rickspencer3: to install it, go:
(01:06:41 PM) rickspencer3: $sudo apt-get install quickly
(01:07:10 PM) rickspencer3: this may take a while, as there are lots of tools and dependencies that get installed for you
(01:07:32 PM) rickspencer3: Note that the current version is 0.2.5
(01:07:48 PM) rickspencer3: this is the first iteration of quickly and comes with 1 template
(01:08:13 PM) rickspencer3: it has support for PPAs and everything, but the launchpad integration is a bit brittle
(01:08:27 PM) rickspencer3: the next version is 0.4, and didrocks will deliver that very very soon
(01:08:35 PM) rickspencer3: it will be the version of Lucid
(01:08:49 PM) rickspencer3: and it will have at least 2 templates, but maybe 3
(01:09:05 PM) rickspencer3: the rest of the class will be in 4 parts:
(01:09:06 PM) rickspencer3: Creating your app
(01:09:07 PM) rickspencer3: Editing the UI
(01:09:07 PM) rickspencer3: Writing Code
(01:09:07 PM) rickspencer3: Packaging and PPAs
(01:09:13 PM) rickspencer3: before we go, any questions?
(01:09:42 PM) ClassBot: lamalex_2 asked: Is quickly always glade/python/etc., or is that template dependant
(01:10:02 PM) rickspencer3: that is template dependant
(01:10:25 PM) rickspencer3: since Ubuntu is a gnome based distro, the ubuntu-project template uses that
(01:10:27 PM) ClassBot: stefodestructo asked: how hard is it to integrate an existing project into quickly?
(01:11:02 PM) rickspencer3: there is no intrinsic importing system
(01:11:22 PM) rickspencer3: I "ported' bughugger to quickly so I could get PPA support and such
(01:11:51 PM) rickspencer3: since bughugger is python, I was able to generate a new quickly app, and then just start copying code over
(01:11:59 PM) rickspencer3: it took about 30 minutes, I guess
(01:12:22 PM) rickspencer3: there was a question about the new templates
(01:12:48 PM) rickspencer3: didrocks added a command line app template (ubuntu-cli), and I am working on a pygame template
(01:13:19 PM) rickspencer3: QUESTION: how much work would it be to create a kubuntu-project template?
(01:13:23 PM) rickspencer3: probably not much
(01:13:38 PM) rickspencer3: just write the boiler plate code
(01:13:56 PM) ClassBot: brunogirin asked: are there plans to merge PPA/bzr integration with what ground contolr does?
(01:14:01 PM) rickspencer3: all the launchpad commands and such could just inherit from the ubuntu-applcation template
(01:14:11 PM) rickspencer3: I am very interested in pursuing that
(01:14:33 PM) rickspencer3: I hope we have lots of productive sessions at UDS around the relationship between Quickly and Ground Control
(01:14:42 PM) rickspencer3: let's move on to creating a project
(01:15:08 PM) rickspencer3: in Karmic, to create an app, you do this:
(01:15:09 PM) rickspencer3: quickly create ubuntu-project appname
(01:15:16 PM) rickspencer3: where appname is a name you choose
(01:15:36 PM) rickspencer3: note that in 0.2.5 ubuntu-project template only support one word application names :(
(01:15:47 PM) rickspencer3: when you issue this command, an app will be generated for you
(01:16:11 PM) rickspencer3: after you create it and test it out, there will be a new directory named after your app
(01:16:15 PM) rickspencer3: so
(01:16:18 PM) rickspencer3: cd appname
(01:16:24 PM) rickspencer3: now you can run the app:
(01:16:26 PM) rickspencer3: quickly run
(01:16:31 PM) rickspencer3: or you can edit the code:
(01:16:33 PM) rickspencer3: quickly edit
(01:16:43 PM) rickspencer3: use tab completion to see all the commands you can do
(01:16:48 PM) rickspencer3: or try
(01:16:50 PM) rickspencer3: quickly help'
(01:16:51 PM) rickspencer3: or
(01:16:56 PM) rickspencer3: quickly tutorial
(01:17:04 PM) rickspencer3: on 0.4, it will be slightly different
(01:17:19 PM) rickspencer3: we changed the template name, so go:
(01:17:20 PM) rickspencer3: quickly create ubuntu-application appname
(01:17:33 PM) rickspencer3: also note that in .4 you'll be able to do multi-word names
(01:17:36 PM) rickspencer3: like app-name
(01:17:53 PM) rickspencer3: any questions about creating an app with quickly?
(01:18:03 PM) rickspencer3: QUESTION: can you rename a quickly project once you've created it?
(01:18:06 PM) ClassBot: danielbell asked: what are the other templates that might be in 0.4?
(01:18:06 PM) rickspencer3: this is hard to do
(01:18:34 PM) rickspencer3: sorry, I was very meant to cjohnston there :/
(01:18:56 PM) rickspencer3: so, if you've created a project, there is all kinds of string replacement that goes on, so renaming is a hard manual process
(01:19:03 PM) rickspencer3: maybe we should add a rename command
(01:19:22 PM) rickspencer3: for the other templates, I mentioned ubuntu-cli, and maybe ubuntu-pygame or something
(01:19:51 PM) rickspencer3: move on to editing the UI?
(01:20:08 PM) rickspencer3: so, for the ubuntu-project, you'll use glade to edit the UI
(01:20:32 PM) rickspencer3: Glade is a UI editing tool, that creates the XML you need to describe your windows and widgets
(01:20:48 PM) rickspencer3: don't worry because the quickly template totally handles keeping the code and the XML hooked up
(01:21:04 PM) rickspencer3: to start editing the UI in 0.2.5, use:
(01:21:08 PM) rickspencer3: quickly glade
(01:21:15 PM) rickspencer3: note that you MUST start glade this way
(01:21:31 PM) rickspencer3: otherwise the correct files won't be loaded into glade and it won't work
(01:21:41 PM) rickspencer3: in 0.4 we changed teh name of the command to:
(01:21:44 PM) rickspencer3: quickly design
(01:21:55 PM) rickspencer3: this is because perhaps other templates won't use glade
(01:22:04 PM) rickspencer3: like I assume Kubuntu would not use Glade, for example
(01:22:35 PM) rickspencer3: so here are some tips for using Glade if you are new to Glade
(01:22:45 PM) rickspencer3: first, adding widgets works like a fill tool
(01:23:01 PM) rickspencer3: you click the widget you want in the toolbox, and then click where you want it to be on the window
(01:23:18 PM) rickspencer3: the widgets will then fill the space alloted to it
(01:23:35 PM) rickspencer3: to layout the form, you use HBoxes and VBoxes
(01:23:56 PM) rickspencer3: an HBox handles Horizontal layout, and a VBox handles veritical
(01:24:13 PM) rickspencer3: so you will find yourself putting lots of boxes within boxes
(01:24:39 PM) rickspencer3: when you add a widget to a window, you can select it in the "inspector" tree if it is hard to select in the window itself'
(01:24:46 PM) rickspencer3: boxes can be hard to select in the window, for example
(01:25:10 PM) rickspencer3: if a widget is in a box, use the position property in the "Property editor" window in the "packing" tab to change the order
(01:25:21 PM) rickspencer3: you can also set the pack type to start or end to change the order
(01:25:38 PM) rickspencer3: Fill and Expand control sizing
(01:25:50 PM) rickspencer3: while Border and Padding control spacing
(01:26:04 PM) rickspencer3: whenever possible, you should use "Stock" widgets
(01:26:17 PM) rickspencer3: they get translated, the right icons, etc... automatically
(01:26:26 PM) rickspencer3: finally, if you want to add a dialog to your project
(01:26:30 PM) rickspencer3: you should:
(01:26:32 PM) rickspencer3: 1. close glade
(01:26:35 PM) rickspencer3: 2. go:
(01:26:43 PM) rickspencer3: $quickly dialog dialogname
(01:26:48 PM) rickspencer3: 3. quickly glade
(01:26:55 PM) rickspencer3: that's for 0.2.5 in karmic
(01:27:03 PM) rickspencer3: for 0.4 go
(01:27:07 PM) rickspencer3: 1. close glade
(01:27:22 PM) rickspencer3: 2. $quickly add dialog dialogname
(01:27:31 PM) rickspencer3: 3. $quickly design
(01:27:39 PM) rickspencer3: ok, that's the power trip through glade
(01:27:43 PM) rickspencer3: and using it with quickly
(01:27:45 PM) rickspencer3: any questions?
(01:28:46 PM) ClassBot: astyguy asked: is there a front end for quickly for use with launchpad
(01:29:11 PM) rickspencer3: quickly quite integrates with launchpad
(01:29:17 PM) rickspencer3: I'll cover that int eh PPA section soon
(01:29:27 PM) ClassBot: brunogirin asked: how much work would it be to create a kubuntu-project template?
(01:29:47 PM) rickspencer3: I thik I answered that one
(01:29:49 PM) rickspencer3: not too hard
(01:29:52 PM) rickspencer3: how about this one:
(01:29:53 PM) rickspencer3: QUESTION: do you have to use glade, or does quickly work with pygtk apps that don't use glade filez?
(01:30:07 PM) rickspencer3: so, you do have to use the generated glade files
(01:30:31 PM) rickspencer3: but if you want, you can just use good old python code to manipulate the contents
(01:30:36 PM) rickspencer3: I do this all the time
(01:30:44 PM) rickspencer3: so using Glade per say, is not required
(01:31:05 PM) rickspencer3: every window or dialog created with the ubuntu-project template has a builder object built in
(01:31:09 PM) rickspencer3: so you can easily go:
(01:31:23 PM) rickspencer3: self.builder.get_object("vbox1")
(01:31:33 PM) rickspencer3: and you have the main vbox for the window
(01:31:42 PM) rickspencer3: you can start packing and removing children like that
(01:32:11 PM) rickspencer3: let's talk coding a little
(01:32:14 PM) rickspencer3: I have a couple of points here
(01:32:19 PM) rickspencer3: oops
(01:32:23 PM) rickspencer3: I forgot to discuss signals
(01:32:57 PM) rickspencer3: signals are messages that your widgets send to your code
(01:33:03 PM) rickspencer3: they get hooked up automatically for you
(01:33:20 PM) rickspencer3: in glade, for an item in the editor, go to the signals tab of the editor for the widget
(01:33:33 PM) rickspencer3: choose the "event" in teh widget that you want to create a signal for
(01:33:54 PM) rickspencer3: then in the "handler" column, type the name for the handler that you want to use
(01:34:04 PM) rickspencer3: a handler is just a function in your code file
(01:34:18 PM) rickspencer3: it's a function that "handles" the signal
(01:34:45 PM) rickspencer3: for running a function when the user selects a certain menu item, for example
(01:35:04 PM) rickspencer3: create a handler in teh glade file for the "activated" signal
(01:35:25 PM) rickspencer3: then create a function of that same name in the code file for that window or dialog
(01:35:40 PM) rickspencer3: the handler signal should like this:
(01:35:41 PM) rickspencer3: def handlername(self, widget, data=None):
(01:36:12 PM) rickspencer3: so, some launchpad integration questions
(01:36:29 PM) rickspencer3: we'll get to that in a few minutes, but it is MUCH improved in 0.4
(01:36:45 PM) rickspencer3: anyway, a couple of notes about writing quickly code
(01:36:57 PM) rickspencer3: but first, questions about signal handlers?
(01:37:21 PM) rickspencer3: ok
(01:37:33 PM) rickspencer3: so a quick tip or two
(01:37:45 PM) rickspencer3: first, for Windows and Dialogs in the quickly template
(01:37:54 PM) rickspencer3: don't write code in the __init__ function
(01:38:14 PM) rickspencer3: rather, add your initialization code to the finish_initializing function
(01:38:34 PM) rickspencer3: similarly, don't create instances of windows or dialogs directly
(01:38:37 PM) rickspencer3: so, don't go
(01:38:50 PM) rickspencer3: window = MyNamedWindow()
(01:38:53 PM) rickspencer3: this will blow up
(01:38:59 PM) Jan is now known as Guest57338
(01:39:17 PM) rickspencer3: rather use the New*Window() or New*Dialog() functions that come with each window or dialog
(01:40:08 PM) rickspencer3: for debugging, most people still just sprinkle print statements in their code
(01:40:25 PM) rickspencer3: we added logging code to the quickly template
(01:40:40 PM) rickspencer3: the idea being that you could use logging.debug(message) instead
(01:40:48 PM) rickspencer3: but this is busted atm
(01:40:53 PM) rickspencer3: we'll fix it before Lucid
(01:41:06 PM) rickspencer3: there is also a debugger called pdb (for python debugger)
(01:41:12 PM) rickspencer3: it works well, but is a bit complex
(01:41:20 PM) rickspencer3: note that $quickly edit
(01:41:30 PM) rickspencer3: will respect your default editor choices
(01:42:01 PM) rickspencer3: QUESTION: And what's the benefit of using logger instead of print?
(01:42:20 PM) rickspencer3: the advantage of logger is that you can cause it to only turn on using a command line switch
(01:42:26 PM) rickspencer3: so you can run your app like:
(01:42:31 PM) rickspencer3: $myapp -v
(01:42:42 PM) rickspencer3: and only with the "-v" will it print debug statements
(01:43:02 PM) rickspencer3: if you just use "print" and forget to delete them, whenever anyone runs the app they'll see your debug statements
(01:43:23 PM) rickspencer3: QUESTION: New* even for default dialogs like a simple message?
(01:43:44 PM) rickspencer3: use New* for Windows and Dialogs created by the ubuntu-project template
(01:44:04 PM) rickspencer3: this is necessary in order properly instantiate the window or dialog and cause it to use the UI definition from Glade
(01:44:29 PM) rickspencer3: this is a workaround for the way uibuilder works in pygtk atm
(01:44:49 PM) rickspencer3: any more questions about coding before we talk packaging and PPAs?
(01:45:35 PM) rickspencer3: QUESTION: any plans to include tasks for unit tests?
(01:45:39 PM) rickspencer3: yes, this would be sweet
(01:45:52 PM) rickspencer3: seems an easy matter to integrate trial into the templates
(01:45:59 PM) rickspencer3: would love to see that soon
(01:46:10 PM) rickspencer3: QUESTION so ground control is worth using with quickly ????
(01:46:15 PM) rickspencer3: atm the projects are not coordinated
(01:46:25 PM) rickspencer3: GC is really for the scenario of contributing to an existing project
(01:46:37 PM) rickspencer3: where as quickly is currently about you creating and sharing your own project'
(01:46:48 PM) rickspencer3: so for now, I would not mentally link them
(01:47:01 PM) rickspencer3: however, they both have a lot of Launchpad integration code
(01:47:20 PM) rickspencer3: and of course you would want folks to contribute to your project, right?
(01:47:30 PM) rickspencer3: so I think some convergence is in store for Lucid + 1
(01:47:40 PM) rickspencer3: also note that GC is very early stage development
(01:47:51 PM) rickspencer3: I don't know that it will even be in universe for Lucid
(01:48:08 PM) rickspencer3: but it's a very important project, so I would watch it closely
(01:48:24 PM) rickspencer3: but in the meantime, if you are trying to get started with development, I would not conflate it with quickly
(01:48:26 PM) rickspencer3: hth
(01:48:37 PM) rickspencer3: ok
(01:48:37 PM) rickspencer3: let'
(01:48:41 PM) rickspencer3: s talk packaging
(01:48:51 PM) rickspencer3: there is a command that goes:
(01:48:54 PM) rickspencer3: $quickly package
(01:49:00 PM) rickspencer3: it is very forgiving
(01:49:18 PM) rickspencer3: it will create a deb for you without anyu configuration or mucking with Launchpad
(01:49:38 PM) rickspencer3: a deb is suitable for testing on other computers and such
(01:49:46 PM) rickspencer3: but let's talk about getting set up for packaging real quick
(01:50:02 PM) rickspencer3: there are a few items to take care of first
(01:50:11 PM) rickspencer3: 1. add your name and email to the copyright file
(01:50:19 PM) rickspencer3: 2. $quickly license
(01:50:30 PM) rickspencer3: this will add GPLv3 liscense to your code'
(01:50:50 PM) rickspencer3: by default, your application is in the Applications -> Accessories category
(01:51:01 PM) rickspencer3: you can change this in your appname.desktop.in file
(01:51:31 PM) rickspencer3: finally, edit setup.py to add your name, email, a description, a long descriptions, etc...
(01:51:38 PM) rickspencer3: this will make your deb a little nicer
(01:51:40 PM) rickspencer3: then do
(01:51:43 PM) rickspencer3: $quickly package
(01:51:51 PM) rickspencer3: and you'll get a nice deb
(01:52:07 PM) rickspencer3: QUESTION: Is the license always gplv3 or can you chose any foss license?
(01:52:18 PM) rickspencer3: you can choose among a set of FOSS liscenses
(01:52:50 PM) rickspencer3: I don't recall which are supported, but I bet that tab completion would show you
(01:53:14 PM) rickspencer3: once you have a deb, you can double click on it, and it will install your app in your desktop
(01:53:35 PM) rickspencer3: but then if you want to update your app, folks who installed it will have to find your deb and reinstall it
(01:53:37 PM) rickspencer3: sux, right?
(01:53:41 PM) rickspencer3: that's where PPAs come in
(01:53:54 PM) rickspencer3: there are a couple of problematic areas here
(01:54:19 PM) rickspencer3: first, PPAs are supposed to be secure, so they use encryption
(01:54:29 PM) rickspencer3: encryption means "close is not close enough"
(01:54:45 PM) rickspencer3: you have to be very precise in your setup
(01:55:01 PM) rickspencer3: here is a quick set of steps:
(01:55:17 PM) rickspencer3: 1. create ssh keys as per launchpad instructions
(01:55:27 PM) rickspencer3: 2. create pgp keys as per launchpad instructions
(01:55:29 PM) rickspencer3: BUT
(01:55:32 PM) rickspencer3: be careful here
(01:55:38 PM) rickspencer3: Don't use a comment!
(01:55:58 PM) rickspencer3: after you have your keys set up, you want to tell your environment what it needs to know to use these keys
(01:56:13 PM) rickspencer3: set DEBEMAIL and DEBFULLNAME in .bashrc, the same as what was in your gpg key
(01:56:24 PM) rickspencer3: this should match what is in
(01:56:24 PM) rickspencer3: match gpg --list-secret-keys
(01:56:29 PM) rickspencer3: oops:
(01:56:34 PM) rickspencer3: $gpg --list-secret-keys
(01:56:52 PM) rickspencer3: so I add this to the end of my ~/.bashrc files:
(01:57:01 PM) rickspencer3: export DEBEMAIL=rick.spencer@canonical.com
(01:57:08 PM) rickspencer3: export DEBFULLNAME=Rick Spencer
(01:57:14 PM) rickspencer3: of course, you need to create a PPA
(01:57:31 PM) rickspencer3: if you are using karmic/quickly 0.2.5, name your PPA "ppa"
(01:57:36 PM) rickspencer3: any other name won't work
(01:57:48 PM) rickspencer3: with 0.4 you can choose the ppa to target
(01:57:53 PM) rickspencer3: after you have that set up:
(01:58:00 PM) rickspencer3: $quickly share
(01:58:06 PM) rickspencer3: that puts your latest code into your PPA
(01:58:07 PM) rickspencer3: or
(01:58:10 PM) rickspencer3: $quickly release
(01:58:17 PM) rickspencer3: does the same but also increments version and makes an announcement
(01:58:22 PM) rickspencer3: then folks can subscribe to your PPA
(01:58:40 PM) rickspencer3: also, don't forget to use:
(01:58:44 PM) rickspencer3: $quickly tutorial
(01:59:01 PM) rickspencer3: there is a good walkthrough there for getting an app going, and also some good links
(01:59:08 PM) rickspencer3: note that the tutorial is not updated yet for 0.4
(01:59:40 PM) rickspencer3: QUESTION: Why we shouldn't use comment when generating our gpg key?
(01:59:50 PM) rickspencer3: because the template is not smart enough
(01:59:59 PM) rickspencer3: it guesses what key to use based on your name and email
(02:00:07 PM) rickspencer3: and the comment confuses it :/
(02:00:13 PM) rickspencer3: ok, I guess that's my time
(02:00:15 PM) rickspencer3: thanks
(02:00:24 PM) rickspencer3: and head to #quickly for more questions!

MeetingLogs/OpWeek1003/Quickly (last edited 2010-03-01 19:01:17 by pool-71-182-100-128)