== App Developer Week -- Rapid App Development with Quickly -- mterry -- Thu, Apr 14th, 2011 == {{{#!irc [18:59] 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! [18:59] yay [18:59] Just real quick: I have notes here if you're interested: https://wiki.ubuntu.com/Quickly/AppDeveloperWeek11.04 [18:59] I'll add a link to the meeting logs there after the fact too [19:00] So, I'm Michael Terry, a maintainer of Quickly [19:00] https://wiki.ubuntu.com/Quickly [19:00] Quickly is a template-based system for writing applications [19:00] quickly, easily, and hopefully fun [19:01] At it's heart, it's just a system of templates with boilerplate code and a few commands [19:01] But all the templates are currently Ubuntu-focused, so that's where it gets the most attention [19:01] Each template makes opinionated choices for you, so the app author can just focus on writing their app === 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 [19:02] We try to give him/her the recommended technologies by default [19:02] Logs for this session will be available at http://irclogs.ubuntu.com/2011/04/14/%23ubuntu-classroom.html following the conclusion of the session. [19:02] oh, whoops [19:02] well, the logs might not have that starting part [19:03] Quickly in Ubuntu 10.10 has three templates: ubuntu-application, ubuntu-cli, and ubuntu-pygame [19:03] In Ubuntu 11.04, we're adding a new template, ubuntu-flash-game [19:03] A new command "submitubuntu" which helps get your app into the Software Center [19:03] And we've redesigned the project layouts a bit [19:04] I'll note when I'm talking if something applies only to the 11.04 version or not [19:04] If anyone has any questions as I go through this, please let me know in the classroom [19:04] classroom-chat that is [19:04] So today, I'm just going to give a bit of an overview for how to use Quickly [19:04] And what it can do [19:05] It's simple enough to get started. Just "sudo apt-get install quickly" [19:05] This will install a bunch of packages, which are development tools and documentation [19:05] But most importantly, it will install Quickly :) [19:06] Now I'll show you how to create a little throw-away app we can practice on here [19:06] "quickly create ubuntu-application test-project" [19:06] This will create a new directory "test-project", put a lot of boilerplate in there, and open your new project [19:06] You'll see that a window and some widgets and dialogs have been created for you [19:07] That's part of the boilerplate I mentioned before [19:07] You can customize this as much as you want, but Quickly gives you something to hit the ground running with [19:07] Now you want to enter your project directory: "cd test-project" [19:08] 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 [19:08] That's a good command to note for later [19:08] But I'm going to move on and explain some of that myself [19:08] Though the tutorial is valuable, and you should consider running through it later [19:08] So the first thing you're likely to want to change is how the app looks [19:09] In your project directory, you can type "quickly design" [19:09] And Glade will open up [19:09] Glade is a tool that lets you edit GTK interfaces by clicking around [19:09] Kinda like Visual Basic, but without any of the code elements [19:09] Glade by itself doesn't integrate with code [19:10] But Quickly matches them up for you [19:10] * mterry pauses for a sec, any questions? [19:11] OK, so let's talk a bit about Glade. If you're not familiar with it, it can be a bit intimidating [19:11] You've got your "tool palette" of widgets on the left [19:11] The middle is where you see what you're building [19:11] And the right is where you can select widgets from the widget tree or edit the currently selected widget [19:11] If you just click directly in the middle on the widget you want, it will be selected [19:11] Or if you find it in the widget tree in the upper right [19:12] In GTK, widgets are layed out in boxes, either horizontal (HBox) or vertical (VBox) [19:12] So you first create a box, then add widgets to it. And you can next boxes for more complicated layouts [19:13] 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 [19:13] There you'll also be able to change how any widget is given space [19:13] You can see the Expand and Fill properties [19:13] Most things start taking up all the space they can, but that's not always the effect you want [19:14] Those are common properties to adjust to get the layout you want === AndrewMC is now known as Guest80546 [19:14] 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 === Guest80546 is now known as AndrewMC [19:15] 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) [19:15] OK, enough Glade [19:16] 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 :) [19:16] So remember, "quickly design" to edit your UI [19:16] 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 [19:17] 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) [19:17] After you do this, you should probably close Glade and re-open it with "quickly design" [19:17] Now Glade will see your new dialog and you can edit it as you like [19:18] Specifics and code examples of adding dialogs are also in the "quickly tutorial" tutorial [19:18] But I'll be brief here [19:18] From your main window, you need to import the new code module that Quickly made: "from project_name.DialogName import DialogName" [19:19] So for this project, that would actually be "from test_project.SaveDialog import SaveDialog" [19:19] Then you use normal GTK code to run it and check the result: [19:19] d = DialogName() [19:19] response = d.run() [19:19] if response == gtk.RESPONSE_OK: [19:20] #do your stuff [19:20] d.destroy() [19:20] And that's it! [19:20] Pretty simple to make a dialog [19:21] Now, if you want to respond to what the user does, you're going to need to listen to GTK signals [19:21] Real briefly, when the user does something like click a button, GTK emits a signal that you can respond to, like "clicked" [19:22] Important signals that you may care about are that buttons emit the "clicked" signal, menu items emit the "activated" signal [19:22] It's really easy to handle these signals [19:22] Let's say you want to handle a menu item press in your main window [19:22] You first note what the menu item is called in Glade [19:22] You can check this from the widget tree in the upper right [19:22] Remember that name [19:23] Now in the code, you can add a new function named like: [19:23] def on_menuitem1_activated(self, widget, data=None): [19:23] and inside that function, add the code that should happen when the menu item is pressed [19:24] Quickly already provides some code for common menu items like Quit and About, but not all of the default menu items have code already [19:24] In Ubuntu 10.10, you'll also need to go into Glade and point it at your new function [19:24] There is a "Signals" tab in the bottom right [19:24] And go there and enter the name of the function you just created next to the "clicked" signal [19:25] In Ubuntu 11.04, Quickly can do this for you, as long as you name it like above: on_WIDGET_SIGNAL [19:25] So a "clicked" signal on "button1" would be on_button1_clicked [19:25] * mterry pauses for a sec. Any questions? [19:26] hobbsc asked: Is quickly generating gtk2 or 3? [19:26] hobbsc, GTK 2 for now. I'd like to move it to 3 next cycle [19:27] But in keeping with using the recommended tools, GTK 2 is still the default toolkit for Ubuntu 11.04 [19:27] I believe Ubuntu will be ported to 3 next cycle, so Quickly should move along with it [19:27] OK. So if you want to edit the code that Quickly makes [19:28] incorrect, asked about PyGI vs PyGTK [19:28] PyGTK won't support GTK 3, so we'd have to move to PyGI at the same time. Quickly doesn't currently use PyGI [19:29] 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" [19:30] 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 [19:30] 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 [19:31] So let me talk about debugging real briefly [19:31] The usual recommended method is just adding print statements and seeing what effect that has. :) [19:31] It's quick, dirty, and easy [19:32] 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 [19:32] The sample code Quickly makes does that, so you can see code examples [19:32] It by default won't spit out messages unless you're running your app in verbose mode [19:32] Or if you're debugging something very complicated, you can use pdb, which is a python debugger [19:33] It's a bit difficult to use, so I just recommend using print statements [19:33] Oh, I forgot! If you want to run your app after you close it, use "quickly run" [19:33] And "quickly help" should give you a list of commands [19:34] So now we come to the exciting stuff. So far, Quickly has just been a jump-start to your app development [19:34] But it also integrates with Launchpad to help you publish, share, and maintain your software [19:35] For example, it keeps your code in bzr and you can save your changes with "quickly save" [19:35] Or if you have a Launchpad project, it can upload tarballs and make announcements [19:35] 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 [19:36] 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 [19:36] I would recommend logging [19:37] I think print statements are most useful just for yourself when you're hunting down some problem [19:37] So that is, your app should probably ship with just logging lines [19:37] But when I'm futzing with it, I like to add print lines to find where the problem is [19:38] So let's talk a bit about packaging [19:38] This is something that is normally difficult to do, but Quickly tries to make easy [19:39] 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 [19:39] Let's start simple [19:39] "quickly package" will package up your current code and create a .deb file for you [19:40] But before you do that, actually, it's probably a good idea to set up some metadata [19:40] You can open the setup.py file that Quickly made for you: "gedit setup.py" [19:40] Near the bottom are some fields like author name, etc [19:40] You also probably want to edit the AUTHORS file and put your name and email there [19:41] And if you had a particular license in mind besides GPL-3, you can run "quickly license BSD" or whatever license you like [19:41] GPL-3 is the default though [19:41] 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 [19:41] You can see a list of the correct categories here: http://standards.freedesktop.org/menu-spec/latest/apa.html [19:42] OK, now that we did all that bookkeeping, you can make your package [19:42] You could have made it before too, Quickly will just fill in bogus info for you [19:42] But it's better to have it all nice and correct :) [19:42] So now after a "quickly package" you'll have a .deb file [19:42] You can double click on this in the file manager and install it into your system for testing [19:43] And you can share that .deb via email or a web site for a small number of people [19:43] But if you want wider testing [19:43] You may want to consider creating a PPA [19:43] 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 [19:44] So Launchpad has some good documentation on what you need to do here, https://help.launchpad.net/Packaging/PPA [19:44] But you'll need an SSH key and a GPG key [19:44] https://help.launchpad.net/YourAccount/CreatingAnSSHKeyPair [19:44] https://help.launchpad.net/YourAccount/ImportingYourPGPKey [19:44] Those are a couple more Launchpad help pages for how to make those [19:45] Once Launchpad knows about you and you've created the PPA, you're ready to tell Quickly [19:45] 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 [19:45] So set them like: [19:45] export DEBEMAIL="oliver.twist@example.com" [19:46] export DEBFULLNAME="Oliver Twist" [19:46] If you put those lines in your ~/.bashrc file, they will be set up for you every time you log in [19:46] OK, now you're all set [19:47] 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 [19:47] So if you have a testing PPA, which is recommended, you can easily get feedback by sharing a new package every now and then [19:48] 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 [19:48] Just like the share command [19:48] By default, Quickly will pick YEAR.MONTH versioning [19:48] But you can specify the version you want to the release command [19:48] Run "quickly help release" for details [19:49] 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 [19:49] "quickly submitubuntu" [19:50] This creates and publishes a package to a PPA just as quickly release does [19:50] So you can pass --ppa and such [19:50] The package will have files installed into /opt as required [19:50] The package will also have special metadata that is used by the Software Center (like where the screenshot lives and such) [19:50] (See https://wiki.ubuntu.com/AppReviews for how to get approved) [19:51] You can create the same kind of package without uploading it by using "quickly package --extras" [19:51] This will generate the /opt packaging and such for you to test with [19:51] There are 10 minutes remaining in the current session. [19:51] incorrect mentioned integration with Eclipse [19:52] That is something I'd like to see happen too, but we haven't focused on that yet [19:52] Also integration with Anjuta and any other IDEs out there [19:52] We'd like to make it easy for that to happen [19:52] But we figured most programmers are familiar with the command line so we haven't rushed to IDE interaction [19:53] Again, the current set of templates (ubuntu-application, ubuntu-cli, ubuntu-pygame, and ubuntu-flash-game) are just what we've done [19:53] But it's hopefully easy to make a template of your own [19:53] See "quickly quickly" [19:53] And we'd love any help! :) [19:54] I also recommend trying out the ubuntu-pygame template: "quickly create ubuntu-pygame test-game" [19:54] It's very neat [19:54] crazedpsyc asked: wouldn't that (IDE integration) be something for the IDE developers themselves to do? They could just run os.popen("quickly [...]") right? [19:54] crazedpsyc, yes, ideally. There's nothing quite stopping them from doing it. [19:55] crazedpsyc, but since we care more than the Eclipse developers probably do about it, it likely won't happen until we make it happen :) [19:55] And since we haven't actually done the work for even one IDE yet, there may be hidden gotchas in adding support [19:55] 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 [19:56] But we'd definitely work with any IDE developers that were intereste [19:56] d [19:56] There are 5 minutes remaining in the current session. [19:56] That's all I had. Hopefully Quickly is fun and easy to mess around with [19:56] We hang out in #quickly and #ubuntu-app-devel channels on Freenode [19:57] If there are any questions you have after this, feel free to poke me there [20:00] Oh, and if I'm not around in the channel, rickspencer3 and didrocks are experts too [20:00] And the original Quickly devs [20:00] (they are the originals I meant) }}}