App Developer Week -- Rapid App Development with Quickly -- mterry -- Thu, Apr 14th, 2011

   1 [18:59] <dpm> Thanks jryannel for this Qt Quick marathon as a great starter for the day! Next up: mterry will tell us about Rapid Application Development with a tool you can never get enough of: Quickly!
   2 [18:59] <mterry> yay
   3 [18:59] <mterry> Just real quick: I have notes here if you're interested: https://wiki.ubuntu.com/Quickly/AppDeveloperWeek11.04
   4 [18:59] <mterry> I'll add a link to the meeting logs there after the fact too
   5 [19:00] <mterry> So, I'm Michael Terry, a maintainer of Quickly
   6 [19:00] <mterry> https://wiki.ubuntu.com/Quickly
   7 [19:00] <mterry> Quickly is a template-based system for writing applications
   8 [19:00] <mterry> quickly, easily, and hopefully fun
   9 [19:01] <mterry> At it's heart, it's just a system of templates with boilerplate code and a few commands
  10 [19:01] <mterry> But all the templates are currently Ubuntu-focused, so that's where it gets the most attention
  11 [19:01] <mterry> Each template makes opinionated choices for you, so the app author can just focus on writing their app
  12 === ChanServ changed the topic of #ubuntu-classroom to: Welcome to the Ubuntu Classroom - https://wiki.ubuntu.com/Classroom || Support in #ubuntu || Upcoming Schedule: http://is.gd/8rtIi || Questions in #ubuntu-classroom-chat || Event: Ubuntu App Developer Week - Current Session: Rapid App Development with Quickly - Instructors: mterry
  13 [19:02] <mterry> We try to give him/her the recommended technologies by default
  14 [19:02] <ClassBot> Logs for this session will be available at http://irclogs.ubuntu.com/2011/04/14/%23ubuntu-classroom.html following the conclusion of the session.
  15 [19:02] <mterry> oh, whoops
  16 [19:02] <mterry> well, the logs might not have that starting part
  17 [19:03] <mterry> Quickly in Ubuntu 10.10 has three templates: ubuntu-application, ubuntu-cli, and ubuntu-pygame
  18 [19:03] <mterry> In Ubuntu 11.04, we're adding a new template, ubuntu-flash-game
  19 [19:03] <mterry> A new command "submitubuntu" which helps get your app into the Software Center
  20 [19:03] <mterry> And we've redesigned the project layouts a bit
  21 [19:04] <mterry> I'll note when I'm talking if something applies only to the 11.04 version or not
  22 [19:04] <mterry> If anyone has any questions as I go through this, please let me know in the classroom
  23 [19:04] <mterry> classroom-chat that is
  24 [19:04] <mterry> So today, I'm just going to give a bit of an overview for how to use Quickly
  25 [19:04] <mterry> And what it can do
  26 [19:05] <mterry> It's simple enough to get started.  Just "sudo apt-get install quickly"
  27 [19:05] <mterry> This will install a bunch of packages, which are development tools and documentation
  28 [19:05] <mterry> But most importantly, it will install Quickly  :)
  29 [19:06] <mterry> Now I'll show you how to create a little throw-away app we can practice on here
  30 [19:06] <mterry> "quickly create ubuntu-application test-project"
  31 [19:06] <mterry> This will create a new directory "test-project", put a lot of boilerplate in there, and open your new project
  32 [19:06] <mterry> You'll see that a window and some widgets and dialogs have been created for you
  33 [19:07] <mterry> That's part of the boilerplate I mentioned before
  34 [19:07] <mterry> You can customize this as much as you want, but Quickly gives you something to hit the ground running with
  35 [19:07] <mterry> Now you want to enter your project directory: "cd test-project"
  36 [19:08] <mterry> And here, if you typed "quickly tutorial" you would get a nice tutorial about how to make changes in the project you've just created
  37 [19:08] <mterry> That's a good command to note for later
  38 [19:08] <mterry> But I'm going to move on and explain some of that myself
  39 [19:08] <mterry> Though the tutorial is valuable, and you should consider running through it later
  40 [19:08] <mterry> So the first thing you're likely to want to change is how the app looks
  41 [19:09] <mterry> In your project directory, you can type "quickly design"
  42 [19:09] <mterry> And Glade will open up
  43 [19:09] <mterry> Glade is a tool that lets you edit GTK interfaces by clicking around
  44 [19:09] <mterry> Kinda like Visual Basic, but without any of the code elements
  45 [19:09] <mterry> Glade by itself doesn't integrate with code
  46 [19:10] <mterry> But Quickly matches them up for you
  47 [19:10]  * mterry pauses for a sec, any questions?
  48 [19:11] <mterry> OK, so let's talk a bit about Glade.  If you're not familiar with it, it can be a bit intimidating
  49 [19:11] <mterry> You've got your "tool palette" of widgets on the left
  50 [19:11] <mterry> The middle is where you see what you're building
  51 [19:11] <mterry> And the right is where you can select widgets from the widget tree or edit the currently selected widget
  52 [19:11] <mterry> If you just click directly in the middle on the widget you want, it will be selected
  53 [19:11] <mterry> Or if you find it in the widget tree in the upper right
  54 [19:12] <mterry> In GTK, widgets are layed out in boxes, either horizontal (HBox) or vertical (VBox)
  55 [19:12] <mterry> So you first create a box, then add widgets to it.  And you can next boxes for more complicated layouts
  56 [19:13] <mterry> Once you add a widget to a box, you can change its position in the box by going to the Packing tab in its properties box in the bottom right
  57 [19:13] <mterry> There you'll also be able to change how any widget is given space
  58 [19:13] <mterry> You can see the Expand and Fill properties
  59 [19:13] <mterry> Most things start taking up all the space they can, but that's not always the effect you want
  60 [19:14] <mterry> Those are common properties to adjust to get the layout you want
  61 === AndrewMC is now known as Guest80546
  62 [19:14] <mterry> Another thing to note is that when adding icons or menu items, you often want to use stock items where possible.  That will use the correctly themed icon and automatically add translated text where appropriate
  63 === Guest80546 is now known as AndrewMC
  64 [19:15] <mterry> Speaking of translations, you can choose translation options for any label in the properties box (like whether it is translated or to leave comments for the translator)
  65 [19:15] <mterry> OK, enough Glade
  66 [19:16] <mterry> You can play with it as needed and just remember that you can always Undo any mistake you make or don't know how to correct  :)
  67 [19:16] <mterry> So remember, "quickly design" to edit your UI
  68 [19:16] <mterry> You can make new dialogs inside Glade, but it's better to let Quickly make them for you, so that they are hooked up correctly in code
  69 [19:17] <mterry> So let's say you want to add a cool new dialog.  You can type the following: "quickly add dialog save-dialog" (for a fictional Save dialog you wanted to add)
  70 [19:17] <mterry> After you do this, you should probably close Glade and re-open it with "quickly design"
  71 [19:17] <mterry> Now Glade will see your new dialog and you can edit it as you like
  72 [19:18] <mterry> Specifics and code examples of adding dialogs are also in the "quickly tutorial" tutorial
  73 [19:18] <mterry> But I'll be brief here
  74 [19:18] <mterry> From your main window, you need to import the new code module that Quickly made: "from project_name.DialogName import DialogName"
  75 [19:19] <mterry> So for this project, that would actually be "from test_project.SaveDialog import SaveDialog"
  76 [19:19] <mterry> Then you use normal GTK code to run it and check the result:
  77 [19:19] <mterry> d = DialogName()
  78 [19:19] <mterry> response = d.run()
  79 [19:19] <mterry> if response == gtk.RESPONSE_OK:
  80 [19:20] <mterry>   #do your stuff
  81 [19:20] <mterry> d.destroy()
  82 [19:20] <mterry> And that's it!
  83 [19:20] <mterry> Pretty simple to make a dialog
  84 [19:21] <mterry> Now, if you want to respond to what the user does, you're going to need to listen to GTK signals
  85 [19:21] <mterry> Real briefly, when the user does something like click a button, GTK emits a signal that you can respond to, like "clicked"
  86 [19:22] <mterry> Important signals that you may care about are that buttons emit the "clicked" signal, menu items emit the "activated" signal
  87 [19:22] <mterry> It's really easy to handle these signals
  88 [19:22] <mterry> Let's say you want to handle a menu item press in your main window
  89 [19:22] <mterry> You first note what the menu item is called in Glade
  90 [19:22] <mterry> You can check this from the widget tree in the upper right
  91 [19:22] <mterry> Remember that name
  92 [19:23] <mterry> Now in the code, you can add a new function named like:
  93 [19:23] <mterry> def on_menuitem1_activated(self, widget, data=None):
  94 [19:23] <mterry> and inside that function, add the code that should happen when the menu item is pressed
  95 [19:24] <mterry> Quickly already provides some code for common menu items like Quit and About, but not all of the default menu items have code already
  96 [19:24] <mterry> In Ubuntu 10.10, you'll also need to go into Glade and point it at your new function
  97 [19:24] <mterry> There is a "Signals" tab in the bottom right
  98 [19:24] <mterry> And go there and enter the name of the function you just created next to the "clicked" signal
  99 [19:25] <mterry> In Ubuntu 11.04, Quickly can do this for you, as long as you name it like above: on_WIDGET_SIGNAL
 100 [19:25] <mterry> So a "clicked" signal on "button1" would be on_button1_clicked
 101 [19:25]  * mterry pauses for a sec.  Any questions?
 102 [19:26] <ClassBot> hobbsc asked: Is quickly generating gtk2 or 3?
 103 [19:26] <mterry> hobbsc, GTK 2 for now.  I'd like to move it to 3 next cycle
 104 [19:27] <mterry> But in keeping with using the recommended tools, GTK 2 is still the default toolkit for Ubuntu 11.04
 105 [19:27] <mterry> I believe Ubuntu will be ported to 3 next cycle, so Quickly should move along with it
 106 [19:27] <mterry> OK.  So if you want to edit the code that Quickly makes
 107 [19:28] <mterry> incorrect, asked about PyGI vs PyGTK
 108 [19:28] <mterry> PyGTK won't support GTK 3, so we'd have to move to PyGI at the same time.  Quickly doesn't currently use PyGI
 109 [19:29] <mterry> So if you want to edit the code, you can just open up the test_project folder in your project and look at all the code.  Or run "quickly edit"
 110 [19:30] <mterry> You'll see for example that your main TestProjectWindow class has a function "finish_initializing".  This is the recommended hook for inserting your own startup code
 111 [19:30] <mterry> In Ubuntu 11.04, there will be a test_project_lib folder that contains code that Quickly "owns" and it isn't recommended you touch it.  But you can take or leave the code there yourself.  There will be one entry point in the main TestProjectWindow class that you control
 112 [19:31] <mterry> So let me talk about debugging real briefly
 113 [19:31] <mterry> The usual recommended method is just adding print statements and seeing what effect that has.  :)
 114 [19:31] <mterry> It's quick, dirty, and easy
 115 [19:32] <mterry> If you are interested in more comprehensive debugging, especially if you want to be able to ask your users for log files, you can use the logging framework
 116 [19:32] <mterry> The sample code Quickly makes does that, so you can see code examples
 117 [19:32] <mterry> It by default won't spit out messages unless you're running your app in verbose mode
 118 [19:32] <mterry> Or if you're debugging something very complicated, you can use pdb, which is a python debugger
 119 [19:33] <mterry> It's a bit difficult to use, so I just recommend using print statements
 120 [19:33] <mterry> Oh, I forgot!  If you want to run your app after you close it, use "quickly run"
 121 [19:33] <mterry> And "quickly help" should give you a list of commands
 122 [19:34] <mterry> So now we come to the exciting stuff.  So far, Quickly has just been a jump-start to your app development
 123 [19:34] <mterry> But it also integrates with Launchpad to help you publish, share, and maintain your software
 124 [19:35] <mterry> For example, it keeps your code in bzr and you can save your changes with "quickly save"
 125 [19:35] <mterry> Or if you have a Launchpad project, it can upload tarballs and make announcements
 126 [19:35] <ClassBot> crazedpsyc asked: When might logging be better than print statements? I think printing some error messages that identify the line of code that has the problem and what the problem is is much more useful, because users usually don't bother to find and read log files
 127 [19:36] <mterry> crazedpsyc, for errors that you "expect" to see in the field like a file that didn't open or an unexpected corner of your code
 128 [19:36] <mterry> I would recommend logging
 129 [19:37] <mterry> I think print statements are most useful just for yourself when you're hunting down some problem
 130 [19:37] <mterry> So that is, your app should probably ship with just logging lines
 131 [19:37] <mterry> But when I'm futzing with it, I like to add print lines to find where the problem is
 132 [19:38] <mterry> So let's talk a bit about packaging
 133 [19:38] <mterry> This is something that is normally difficult to do, but Quickly tries to make easy
 134 [19:39] <mterry> You have different "levels" of complexity here.  You can create a local Ubuntu package, you can share your package with testers, you can publish a new final version of your package, or you can even put your package in the Software Center
 135 [19:39] <mterry> Let's start simple
 136 [19:39] <mterry> "quickly package" will package up your current code and create a .deb file for you
 137 [19:40] <mterry> But before you do that, actually, it's probably a good idea to set up some metadata
 138 [19:40] <mterry> You can open the setup.py file that Quickly made for you: "gedit setup.py"
 139 [19:40] <mterry> Near the bottom are some fields like author name, etc
 140 [19:40] <mterry> You also probably want to edit the AUTHORS file and put your name and email there
 141 [19:41] <mterry> And if you had a particular license in mind besides GPL-3, you can run "quickly license BSD" or whatever license you like
 142 [19:41] <mterry> GPL-3 is the default though
 143 [19:41] <mterry> You may also want to edit test-project.desktop.in and change the application properties so it shows up in the right application category in the menus
 144 [19:41] <mterry> You can see a list of the correct categories here: http://standards.freedesktop.org/menu-spec/latest/apa.html
 145 [19:42] <mterry> OK, now that we did all that bookkeeping, you can make your package
 146 [19:42] <mterry> You could have made it before too, Quickly will just fill in bogus info for you
 147 [19:42] <mterry> But it's better to have it all nice and correct :)
 148 [19:42] <mterry> So now after a "quickly package" you'll have a .deb file
 149 [19:42] <mterry> You can double click on this in the file manager and install it into your system for testing
 150 [19:43] <mterry> And you can share that .deb via email or a web site for a small number of people
 151 [19:43] <mterry> But if you want wider testing
 152 [19:43] <mterry> You may want to consider creating a PPA
 153 [19:43] <mterry> PPAs are a little bit more involvement for you, but it makes it so much easier to test your app that it's probably worth it for you in order to have more testers
 154 [19:44] <mterry> So Launchpad has some good documentation on what you need to do here, https://help.launchpad.net/Packaging/PPA
 155 [19:44] <mterry> But you'll need an SSH key and a GPG key
 156 [19:44] <mterry> https://help.launchpad.net/YourAccount/CreatingAnSSHKeyPair
 157 [19:44] <mterry> https://help.launchpad.net/YourAccount/ImportingYourPGPKey
 158 [19:44] <mterry> Those are a couple more Launchpad help pages for how to make those
 159 [19:45] <mterry> Once Launchpad knows about you and you've created the PPA, you're ready to tell Quickly
 160 [19:45] <mterry> You should set DEBEMAIL and DEBFULLNAME environment variables for the benefit of "quickly package".  This will note that you were the one that created the package, otherwise Launchpad won't accept it
 161 [19:45] <mterry> So set them like:
 162 [19:45] <mterry> export DEBEMAIL="oliver.twist@example.com"
 163 [19:46] <mterry> export DEBFULLNAME="Oliver Twist"
 164 [19:46] <mterry> If you put those lines in your ~/.bashrc file, they will be set up for you every time you log in
 165 [19:46] <mterry> OK, now you're all set
 166 [19:47] <mterry> So if you enter "quickly share --ppa testing" it will create a new in-progress package with a version like 0.1~public1 and push it to the PPA you specify on the command line
 167 [19:47] <mterry> So if you have a testing PPA, which is recommended, you can easily get feedback by sharing a new package every now and then
 168 [19:48] <mterry> If you want to actually make a full release, you can do "quickly release --ppa release" and Quickly will increment the number for you and push it to the the PPA you specify
 169 [19:48] <mterry> Just like the share command
 170 [19:48] <mterry> By default, Quickly will pick YEAR.MONTH versioning
 171 [19:48] <mterry> But you can specify the version you want to the release command
 172 [19:48] <mterry> Run "quickly help release" for details
 173 [19:49] <mterry> And now finally, there is a new command in Ubuntu 11.04 that lets you prepare an upload for acceptance into the Ubuntu Software Center
 174 [19:49] <mterry> "quickly submitubuntu"
 175 [19:50] <mterry> This creates and publishes a package to a PPA just as quickly release does
 176 [19:50] <mterry> So you can pass --ppa and such
 177 [19:50] <mterry> The package will have files installed into /opt as required
 178 [19:50] <mterry> The package will also have special metadata that is used by the Software Center (like where the screenshot lives and such)
 179 [19:50] <mterry> (See https://wiki.ubuntu.com/AppReviews for how to get approved)
 180 [19:51] <mterry> You can create the same kind of package without uploading it by using "quickly package --extras"
 181 [19:51] <mterry> This will generate the /opt packaging and such for you to test with
 182 [19:51] <ClassBot> There are 10 minutes remaining in the current session.
 183 [19:51] <mterry> incorrect mentioned integration with Eclipse
 184 [19:52] <mterry> That is something I'd like to see happen too, but we haven't focused on that yet
 185 [19:52] <mterry> Also integration with Anjuta and any other IDEs out there
 186 [19:52] <mterry> We'd like to make it easy for that to happen
 187 [19:52] <mterry> But we figured most programmers are familiar with the command line so we haven't rushed to IDE interaction
 188 [19:53] <mterry> Again, the current set of templates (ubuntu-application, ubuntu-cli, ubuntu-pygame, and ubuntu-flash-game) are just what we've done
 189 [19:53] <mterry> But it's hopefully easy to make a template of your own
 190 [19:53] <mterry> See "quickly quickly"
 191 [19:53] <mterry> And we'd love any help!  :)
 192 [19:54] <mterry> I also recommend trying out the ubuntu-pygame template: "quickly create ubuntu-pygame test-game"
 193 [19:54] <mterry> It's very neat
 194 [19:54] <ClassBot> crazedpsyc asked: wouldn't that (IDE integration) be something for the IDE developers themselves to do? They could just run os.popen("quickly [...]") right?
 195 [19:54] <mterry> crazedpsyc, yes, ideally.  There's nothing quite stopping them from doing it.
 196 [19:55] <mterry> crazedpsyc, but since we care more than the Eclipse developers probably do about it, it likely won't happen until we make it happen  :)
 197 [19:55] <mterry> And since we haven't actually done the work for even one IDE yet, there may be hidden gotchas in adding support
 198 [19:55] <mterry> So it would be good for us to try making one ourselves, so we can make it super easy to do from the Quickly side
 199 [19:56] <mterry> But we'd definitely work with any IDE developers that were intereste
 200 [19:56] <mterry> d
 201 [19:56] <ClassBot> There are 5 minutes remaining in the current session.
 202 [19:56] <mterry> That's all I had.  Hopefully Quickly is fun and easy to mess around with
 203 [19:56] <mterry> We hang out in #quickly and #ubuntu-app-devel channels on Freenode
 204 [19:57] <mterry> If there are any questions you have after this, feel free to poke me there
 205 [20:00] <mterry> Oh, and if I'm not around in the channel, rickspencer3 and didrocks are experts too
 206 [20:00] <mterry> And the original Quickly devs
 207 [20:00] <mterry> (they are the originals I meant)

MeetingLogs/appdevweek1104/QuicklyRad (last edited 2011-04-15 08:53:16 by 178)