<?xml version="1.0" encoding="windows-1252"?>
<node id="992851" title="Re: Perl Gtk3 Tutorial" created="2012-09-10 17:16:57" updated="2012-09-10 17:16:57">
<type id="11">
note</type>
<author id="961">
Anonymous Monk</author>
<data>
<field name="doctext">
&lt;p&gt;I have previous Gtk2.pm experience, and skimmed through your tutorial. It actually looks exactly like Gtk2 except perhaps for a few new widgets.&lt;/p&gt;

&lt;p&gt;The code examples have perhaps a bit too much boilerplate; I'd remove &lt;c&gt;use diagnostics&lt;/c&gt; and &lt;c&gt;use feature ':5.14'&lt;/c&gt; when not needed (you appear to be using only &lt;c&gt;say&lt;/c&gt; anyway so &lt;c&gt;use 5.010;&lt;/c&gt; should work as well.) Maybe even remove the ~6 lines you use for window creation from the later examples in the document (of course, they should stay intact in the .pl files).&lt;/p&gt;

&lt;p&gt;I'd perhaps visualise how packing with containers works a bit more thoroughly early on. (Such as drawing the containers' outlines and variable names over the UI.) It's one of the most important points to understand about Gtk. (I notice you've got a pack-style visualisation later on in the document; that one's at a good spot.)&lt;/p&gt;

&lt;p&gt;I have a little bit of an issue with how you use the same callback to do three different things depending on &lt;c&gt;$userdata&lt;/c&gt; in examples 5 and 6a, but I'll let that slide since it's not a bad way to demonstrate the use of that variable.&lt;/p&gt;

&lt;p&gt;You are missing one important example about &lt;c&gt;$userdata&lt;/c&gt;: How to pass multiple values. (either pass an arrayref or use a closure/anon sub to wrap around it)&lt;/p&gt;

&lt;p&gt;The progress bar example seems to be missing how to stop it. (returning FALSE from the idle callback, or deleting the callback) (not to mention that proper utilisation of a progress bar is quite a bit more difficult. perhaps a note somewhere that your callbacks shouldn't take much time or the UI will freeze?)&lt;/p&gt;

&lt;p&gt;There's one more thing I'd like to see, but it may not be for the level of Perl user you aim your tutorial for. You keep all the UI variables as global. Let's take example 6d. Instead of &lt;c&gt;sub update&lt;/c&gt; accessing the global variable &lt;c&gt;$label&lt;/c&gt; to do its thing. It would be nicer if you passed &lt;c&gt;$label&lt;/c&gt; as an argument to your function. This allows you to compartmentalise your UI code and let variables you don't use fall out of scope. (I generally set up the whole UI in a single sub.)&lt;/p&gt;</field>
<field name="root_node">
990973</field>
<field name="parent_node">
990973</field>
<field name="reputation">
4</field>
</data>
</node>
