17:31:06 #startmeeting 17:31:06 Meeting started Sun Aug 11 17:31:06 2013 UTC. The chair is mizmo. Information about MeetBot at http://wiki.debian.org/MeetBot. 17:31:06 Useful Commands: #action #agreed #halp #info #idea #link #topic. 17:31:22 Graduating to GUI: A PyGTK/PyGObject Workshop for Beginners 17:31:27 Presented by Paul Frields 17:31:28 Slides: http://flocktofedora.org/wp-content/uploads/2013/08/flock-2013-PyGObject-workshop1.pdf 17:31:36 Schedule Description: http://flock2013.sched.org/event/2c1b90de8c79a909b22a52cc35cd7416?iframe=no 17:31:44 Video stream: http://www.youtube.com/watch?v=CWcy3sgOWDQ&feature=youtu.be 17:31:48 * stickster now on IRC 17:32:06 stickster, ive got the slides open here in another window so if they cant be synched into g+ it's all good 17:33:36 (just let me know if you change the slide 17:34:09 We're going to give people a few more minutes to show up because there are 20 RSVPs and 3 people in the room. I'd like to have at least 6 people in here because of the way the workshop is structured. 17:34:10 mizmo: working fine? 17:34:16 ianweller, yep!! 17:34:23 woop woop 17:34:28 thx stickster 17:34:35 and mizmo of course :) 17:34:38 OF course! 17:34:57 should we post hangout url then? 17:35:03 * mizmo has never tried that with hangout but is willing to try 17:36:10 Yes, we probably should 17:36:20 I didn't plan well on how to do remote collaboration for the exercises 17:36:23 :-\ 17:36:31 I haven't either! It will be an adventure! 17:37:11 i found this https://plus.google.com/116045043409715285264/posts/9XnGzPvAUjL 17:37:32 grr not working now 17:38:10 stickster, can you grab the hangout url from the laptop? 17:38:26 it's not findable if you're not logged into the fedora admin account and the url i snagged from then isnt working 17:39:15 halp! 17:40:10 * mizmo still needs google hangout link 17:40:11 halp? 17:40:16 langdon, ^ ? :) 17:40:20 asking 17:40:24 thanks 17:40:34 that link you posted worked for me 17:40:43 it doesn't work for me 17:40:43 If you have G+ it should work 17:40:50 when im logged in as me instead of fedora 17:40:56 Oh 17:40:59 but i cant do it logged in as fedora it'll mess u up 17:41:12 it should be in the admin page 17:41:17 thanks 17:41:34 it only works if you're logged in as fedora 17:41:44 sorry :( 17:42:01 thanks!! 17:42:47 still borked 17:42:47 Will you be OK? 17:43:08 mairin@gmail.com ? 17:43:09 * mizmo shrugs 17:43:16 i can just watch the stream and not hangout 17:43:23 dont want to mess everything up 17:43:32 it's all good 17:43:47 yeh g+ has privacy setting issues with their UI 17:43:54 well 17:43:59 maybe ill try the hangout as fedora and hope it doesnt mess u up 17:44:22 okay 17:44:23 x-ing fingers :) 17:44:25 #topic Slides 17:44:39 * mizmo will just go off of stream for now, try hangout later 17:44:47 I've been working on variations of this talk fo ra couple of years now 17:44:57 The workshop format tends to work well, bc you tend to learn skills like this thru hands on 17:45:08 I'm going to spend 30 minutes on the slides and go quickly 17:45:19 I want to take a temperature on people's skill in here to now where I shuld spend more time 17:45:45 * mizmo occasional python script writer/reader 17:45:51 * mizmo read dive into python a long time ago 17:46:00 seems most people in the room have some familiarity 17:46:07 Paul recommends rading chapters 2-5 of diveintopython.org 17:46:12 it's a very quick read, very well-written 17:46:17 shows you elementary programming concepts in python 17:46:27 go through conditionals and loops and how they work in python 17:46:34 talks about object oriented programming and python as well 17:46:47 17:47:42 yum install glade pygobject3 gtk3-devel-docs diveintopython 17:47:50 diveintopython available in many formats via yum too 17:47:58 consider ubying paper book to support author 17:48:05 don't have to be a super skilled programmer to do what we'll do today 17:48:22 if you're like matthias - he's a world renowed expert in the toolkit 17:48:27 dont need to be him :) 17:48:35 for hands on here, you'll need a few things installed - 17:48:49 yum groupinstall gnome-software-development 17:48:54 (i think i got the collection name wrong) 17:49:15 first we'll cover some concepts 17:49:21 "GNOME Software Development" 17:49:26 thanks kilted1 17:49:31 first i recommend you design your UI 17:49:33 design the flow 17:49:37 what are they supposed to see 17:49:42 what task are they trying to accomplish 17:49:48 draw on paper first if you need to 17:49:51 i have an app i wrote 17:49:55 hi :) 17:50:09 it didn't exist until i sat down at a conference, we talked about what i wanted to accomplish, and she helped sketch it out and simplify it - 17:50:32 i started implementing, then over time we figured out how to add in more features to the design 17:50:42 there's a tool that's helpful that will help design the bolts of the UI, it's called glade 17:51:01 spits out a UI file which is an xml definition 17:51:11 everything you draw glade can represent as an xml tree 17:51:17 in python you load that XML file 17:51:28 so anything you want user to interact with 17:51:34 you can reference using the name you gave that widget in glade 17:51:48 17:52:03 python treats them as objects 17:52:28 and then you'll assign functions to happen when the user interacts with an element in the UI 17:52:39 next slide is a picture of the glade UI 17:52:40 on the left 17:52:43 there's collections of widgets 17:52:49 those are basically drawing elements that you can stick into the UI 17:52:56 if you hover over each one it has a tooltip to tell you what it is 17:53:06 there's a picture here on the right, a tree when you have an object selected 17:53:11 it's a semi-graphical representation of the XML tree 17:53:29 at the bottom-right is a useful area that gives you options for each widget - help control appearance, scale, borders, etc 17:53:54 really clever, very easy button will give you a help section in developre help docs that referes to the object you're working with 17:54:06 review concept: 17:54:10 1) create interface in glade 17:54:14 2) save as XML file 17:54:15 17:54:26 we'll cover key / high level GTK info 17:54:27 objects/widgets 17:54:29 signals 17:54:30 mainloop 17:54:49 there's a lot more to GTK and GObject but I'm keeping it simple for this workshop 17:55:11 gtk object model based on abstract classes 17:55:17 each object may have any number of properties 17:55:18 for example 17:55:25 a property of a checkbox is whether or not it's checked 17:55:28 btw 17:55:39 it also inherits methods and properties from the class it's subclassed from 17:55:50 so they go pretty far back - a huge rich hierarchy of properties that each object has 17:55:53 stupid real life example 17:55:57 think of definition of a Chair object 17:56:01 chairs have many properties 17:56:08 coordinates in space 17:56:19 does it have legs 17:56:20 a back 17:56:24 you can subclass a chair 17:56:30 FoldingChair adds a fold() function 17:56:36 SwivelChair adds a rotate() function 17:56:50 this is just a little bit of the object oriented programming philosophy 17:56:58 Chair itself may be a subclass of sometihng else - Furniture 17:57:01 17:57:08 run devhelp 17:57:12 provides hierarchical listing of inheritance 17:57:19 17:57:26 here's an example of how the hierarchy works 17:57:32 look up the tree from GtkButton 17:57:46 GtkButton is subclasses from GtkBin so it gets methods and props from that 17:57:50 GtkBin inherits from GtkContainer 17:57:52 so on and so forth 17:57:59 anything you can do with GtkContainer, you can do with GtkButton 17:58:02 it's additive as you go down the tree 17:58:08 17:58:12 your application can be an object 17:58:21 typically the UI is an object that you create an instance of a class that you define 17:58:25 that's how the application actually starts 17:58:34 so you might define your UI as a subclass of the Gtk.Application object 17:58:45 then you inherit things that the Application obejct has, like set the icon for the app 17:59:12 subclass so you can get the things an helpers and things already written for the parent class you're subclassing from 17:59:19 that's just a python feature / OOP feature 17:59:22 17:59:28 how do you get from this XML file to a working application 17:59:29 ? 17:59:37 again, use glade, build your UI, you saved it as an XML file 17:59:43 how do you get that file as something to work in python? 17:59:53 first you load the GIR / Gobject introspection repository 17:59:58 the following line in your python: 18:00:02 from gi.repository import Gtk 18:00:13 then youcreate a GtkBuilder object and use it to add from the UI file 18:00:29 Gtk.Builder.add_from_file('') 18:00:40 now any of the elements in your ui are in the python and you can work with them! 18:00:45 will demo this in a bit 18:00:50 18:00:58 now how to you make the objects react to things the user does? 18:01:01 it doesn't come for free 18:01:16 just because you created a window with a button in it, doesn't mean it'll do anything if the user presses it unless you connect a signal to that element 18:01:22 for example with a button, you'd connect the 'click' signa 18:01:23 l 18:01:31 the way something happens, connect your signal to a callback function 18:01:45 the reaosn that things are interactive is because there's a main loop running 18:01:54 it picks up things that happen 18:01:54 if the user moves the mouse 18:01:57 clicks the mouse 18:01:59 hits the keyboard 18:02:01 it listens 18:02:14 if you have a dialog up you dont normally care if the users mouse is in the dialog or outside 18:02:20 you mostly care whether or not they clicked the button 18:02:30 but note there's a realy rich set of activites you can listen for using signals / the main loop 18:02:34 so the interaction generates a signal 18:02:39 which can be caught and used to trigger a function 18:02:51 the signals are emitted by widgets... but where do we get the widgets? 18:02:52 remember when we used the GtkBuilder? 18:02:58 that gives us access to the objects 18:03:05 there's a get_object() function that'll grab the objects for us 18:03:10 18:03:11 eg 18:03:22 Gtk.Builder.get_object() retrurns an object based on its name 18:03:25 eg self.close_button = self.builder.get_object('close') 18:03:36 now you can reference that GUI element in Python and do things with it 18:03:50 if you did a nice job naming the objectsin your glade file, this part will be easier :) 18:04:03 18:04:13 just about anything in the toolkit can use the connect() function to map a signal to a callback function 18:04:22 the callback is where you write the code the user interacts with 18:04:29 ex. self.close_button.connect(‘clicked’, self.hide_dialog) 18:04:41 i'm getting the signal that the user clicked the close button, so i'm connecting that signal to the hide_dialog() function 18:04:46 so if the user clicks close, the dialog will hide 18:04:56 thi sis not just limited to clicks! 18:04:56 theres a rich set of things 18:05:02 interface element can react if pointer drifts over it or away from it 18:05:07 18:05:10 writing callback function 18:05:23 the callback functoin can receive additoinal argments 18:05:40 if you dont care about the args... im not following 18:06:13 eg 18:06:18 this function set three arguments, you're only providing one 18:06:24 if you dont care about them what do you do? <== question 18:06:36 18:06:38 gtk main loop 18:06:45 allows your app to accept input from user 18:07:23 main_quit() function 18:07:26 cleans up screen when app exits 18:07:28 important to use 18:08:10 i sometimes forget to connect the simplest signals, that the app actually quits when they click close button... without running main_quit() <= symptom of tihs is that the term it was running in hangs 18:08:23 18:08:24 another hint 18:08:26 show_all() 18:08:35 show widgets before the main loop runs using show_all() 18:08:47 choose what to show and hide for mult. window or paned apps using hide/show methods or visible properties 18:09:00 * mizmo wonders what is diff between hide and not visibile 18:09:23 if app has help, about, main window, you dont want to show all three windows at same time when app first runs 18:09:30 visibility is not automatic 18:09:33 you actually control that 18:10:16 18:10:20 how do i know what widgets i need? 18:10:24 dont need to memorize whole toolkit 18:10:32 use glade, use devhelp to investigate widgets as you use them in glade 18:10:37 as you use it you'll get more familiar with them 18:10:46 there are heavy duty ones you use all the time - button and click signal 18:11:00 keep in mind widgets inherit things from their parnets 18:11:26 so when you look at widget in devhelp - understand it can do things its parent can too, devhelp only displays functions/properties specific to the object you're looking at 18:11:33 so go up the hierarchy to look for other props/funcs 18:11:44 anything you can do in glade, you can do directly in python via GTK 18:11:48 so you can change your interface as you run 18:11:51 mizmo: should we omve hte camera to point "more" at paul? 18:11:58 yeh if you dont mind 18:12:08 also i had some q's 18:12:12 shoot 18:12:25 you are laggy so tough to see result 18:12:31 q1: if a callback function give syou 3 args but you only care about one of them... what do you do? 18:12:49 q2: is there a difference between hiding a window and marking it as not visible? 18:12:54 ignore the other args 18:12:54 he is answering someone else right this sec 18:13:02 summary/review 18:13:14 q: do you always want to do outside of... ? 18:13:31 a: not a good person to answer that but i always do in main... i might want to use that UI as a class somewhere else 18:13:41 i think question about where do you use GtkBuilder to pull in objects 18:14:04 q: show_all also show. why use on eor the other? 18:14:08 a: diff between show and show 18:14:10 _all 18:14:27 show_all guarantees that any of widgets contained inside widget itself (eg window with buttons in it) - show_all will gaurantee all contents will show 18:15:17 if you have an app that has a pane in it or a box that things change as user does stuff - you'll want to use show, not show_all so user will only get the one thing you're doing at that time 18:15:29 q: python take advantage of... raising dot classes? 18:15:40 a: ive been using python for a while but im not sure how .. that it necessarily does all the same 18:16:08 q: is there a difference between hiding a window and marking it as not visible? 18:16:13 a: no dont think there is any real difference? 18:16:26 a: gtk widget hide... end effect is same but difference has to do with signal? 18:16:31 * mizmo not following completely but its ok 18:16:40 matthias is hard to hear on mic 18:17:02 mizmo: if you set the property no "event" is fired.. so ifyou want to chaing things based on the hide... it won't "work" 18:17:04 18:17:16 langdon, ohhhhhhh okay 18:17:17 makes sense 18:17:23 we'll split into teams to build a UI 18:17:57 mizmo: in other words, sometimes you want other parts of your app to know you hide something and sometimes you don't want to trigger the "normal result" .. but as far as the UI is concerned (like for the user) the result is the same 18:18:19 mizmo: i was 1/2 way through when you said you got it.. but i was COMMITTED ;) 18:18:24 lol 18:18:44 whoever is on matthias' team has an unfair advantage 18:18:57 all of these are simple one window apps 18:19:09 for team 1 18:19:46 for team 2 18:20:42 for team 3 18:22:03 hopefully the video is better.. and not just someone's back.. but the video may not be much use any which way soon.. 18:22:08 oh much better 18:22:11 yeh its all good tho 18:22:43 slides: http://flocktofedora.org/wp-content/uploads/2013/08/flock-2013-PyGObject-workshop1.pdf 18:23:14 question about exercise 3... you're printing the output to the dialog and to standard output? 18:23:20 standard output as on the term? 18:24:26 Just as standard out on the terminal... so in other words, you'll launch the app from the terminal, and you'll see 'yes' or 'no' pop out there as well 18:24:37 okay cool 18:25:05 is it hard to make answer appear in gui? 18:25:38 mizmo: Not at all -- you could make a Gtk.Label and use Gtk.Label.set_text('...') to put the answer there 18:25:41 mizmo: i can doa g+ hangout with you 18:25:48 my gmail is d.crossland@gmail.com 18:25:49 any suggestions for naming in the hierarchy? eg i know what to name the window, but then i have a grid and i dont know what to name the grid 18:25:49 davelab6: That would be awesome! 18:25:54 okay cool 18:26:11 mizmo: I often won't worry about setting specific names for widgets I don't care about 18:26:14 Like boxes or grids 18:26:21 That may be crappy programming practice, though :-) 18:26:23 you wont need to access in py so it doesnt matter the name 18:27:12 davelab6, it says its dialing 18:27:29 says youre not available 18:27:33 its all good tho 18:27:42 oh there is goes i think 18:29:09 for sharing https://github.com/davelab6/flock-gobject-exercise.git ? 18:29:11 http://pfrields.fedorapeople.org/presentations/Flock2013/ 18:29:21 ^^ you can find a trivial little app example there 18:29:35 spin-me.py is the app, spin-me.ui is the Glade (GtkBuilder) UI file 18:29:48 I have that on screen here in the room 18:31:28 the face in the ui is so sad 18:31:29 in spin-me 18:31:48 mizmo: if you click the on button he smiles! 18:32:30 mizmo: or maybe etherpad woud be better? 18:32:35 hrm 18:32:43 yeh im not getting much out of the hangout maybe etherpad better 18:32:44 sec 18:32:53 the audio is kinda garbled 18:33:05 g+ can do screen sharing 18:33:12 2 way vnc style 18:33:15 http://piratepad.net/pygobject-flock 18:33:19 oh i closed it lol 18:33:28 should i do the call again? 18:33:35 ok 18:34:15 ok back 18:34:29 are you turning screenshare on? 18:37:48 mizmo: How is this working for you? I haven't tried hangouts for this before but I hear the GNOME guys use it a lot 18:37:58 so far it's confusing but i only have one screen here 18:38:03 Oh 18:38:03 i think if i had dual monitor it'd be a lot easier 18:38:12 Maybe someone can invite me, so I can see what it looks like 19:01:42 stickster: hangouts screensharing is not ideal compared to a genuine shared desktop... it has VNC style remote input but we didnt use that.... 19:02:27 really we were using piratepad as the main collaboration point 19:24:55 davelab6: Aha 19:25:35 I will really need to play around with it and see how to do remote better with this. It would be fun to offer additional "courses" 19:36:45 mizmo: Thank you for transcribing! Hope I wasn't too hard on you 19:38:46 * stickster heads over to auditorium 19:48:51 Hi, is there still a talk going on here? 19:49:11 I do not think so 19:49:15 .listmeetings 19:49:15 nb: ('#fedora-flock-auditorium', 'freenode'), ('#fedora-flock-ectr101', 'freenode') 19:49:19 #endmeeting 19:49:29 puiterwijk, you will have to .addchair yourself 19:49:31 .misc help addchair 19:49:31 nb: (addchair ) -- Add a nick as a chair to the meeting. 19:49:32 nb: I don't think so either 19:49:48 .addchair #fedora-flock-ectr101 freenode puiterwijk 19:49:48 puiterwijk: Chair added: puiterwijk on (#fedora-flock-ectr101, freenode). 19:49:53 #endmeeting