Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

I have previous Gtk2.pm experience, and skimmed through your tutorial. It actually looks exactly like Gtk2 except perhaps for a few new widgets.

The code examples have perhaps a bit too much boilerplate; I'd remove use diagnostics and use feature ':5.14' when not needed (you appear to be using only say anyway so use 5.010; 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).

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.)

I have a little bit of an issue with how you use the same callback to do three different things depending on $userdata 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.

You are missing one important example about $userdata: How to pass multiple values. (either pass an arrayref or use a closure/anon sub to wrap around it)

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?)

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 sub update accessing the global variable $label to do its thing. It would be nicer if you passed $label 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.)


In reply to Re: Perl Gtk3 Tutorial by Anonymous Monk
in thread Perl Gtk3 Tutorial by kevinp

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others romping around the Monastery: (12)
    As of 2014-10-20 22:49 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      For retirement, I am banking on:










      Results (92 votes), past polls