Flame has asked for the wisdom of the Perl Monks concerning the following question:

I've gone through the docs to no avail, I'm hopelessly lost.

Ok, summery: I'm a Win32::GUI user. I've been using it for about half a year now, but I want to learn to use Perl-Tk because it's more versitile (not limited to Win32 systems). Now, I'm completely lost on the vast majority of how Tk works, because I'm used to Win32::GUI.


A few questions:


Any other tips for someone trying to migrate from Win32::GUI to Tk would be appreciated. Thanks.



"Weird things happen, get used to it."

Flame ~ Lead Programmer: GMS

Replies are listed 'Best First'.
(jeffa) Re: Tk Explanation
by jeffa (Bishop) on Jun 03, 2002 at 04:29 UTC
      Just a nitpick, but winGTK and wGLADE are for the gtk toolkit, which is a distinct (but apparently not unpopular) alternative to Tk. :)
Re: Tk Explanation
by Popcorn Dave (Abbot) on Jun 03, 2002 at 06:29 UTC
    Jeffa is right about the Tk book. Make SURE you get the one by Liddie and Walsh as the one by Walsh ( previous edition ) is apparently riddled with errors ( as told to me by my Perl teacher ). I've seen it in the bargain bins for $10 or so, but avoid it!

    Some people fall from grace. I prefer a running start...

Re: Tk Explanation
by rbc (Curate) on Jun 03, 2002 at 15:35 UTC
Re: Tk Explanation
by Flame (Deacon) on Jun 03, 2002 at 04:16 UTC
    Also, did anyone notice This node? It's there, but it seems kinda... blank...



    "Weird things happen, get used to it."

    Flame ~ Lead Programmer: GMS

Re: Tk Explanation
by smackdab (Pilgrim) on Jun 03, 2002 at 21:16 UTC
    How do you precicely position an object, for example, a text field in a window?

    --

    Tk is different than the W32 world...In W32, you draw your dialog box with a dialog editor. Unker Tk, almost everyone creates them it with code. I definitely recommend that you adapt your GUI to one of the different geometry managers, unless you REALLY need to do something unique. 90+% of the time, I use pack() and grid().

    Remember, under Tk, everything can stretch. Break everthing up into related Frames...so they size appropriately.

    Once you get used to it, you won't want a dialog editor. It took me a while to "get it", but now wouldn't use a dialog editor...
      I program Win32::GUI without a dialog editor, but I usually make it a habit to start with something designed to 'generate' the output to show me what the technology is capable of. Thanks for the advice though.



      "Weird things happen, get used to it."

      Flame ~ Lead Programmer: GMS

(ichi) Re: Tk Explanation
by ichimunki (Priest) on Jun 03, 2002 at 21:55 UTC
    There are a few different ways to precisely position a widget in Tk. One would be to use a Canvas widget and then place all other widgets on that, but this is top-heavy. One would be to use the Pack geometry manager and very specifically tell each Pack method call how tall and wide to make each widget. Another would be to use the Grid geometry manager. Finally, there is Tk::place, which allows for fairly simple, yet exact control over widget size and placement. This one would be ideal if exactness is called for. But most of us use the Pack geometry manager because it helps us by appropriately sizing widgets based on contents and context.

    You have some pretty good documentation available already in the form of the widget demo (just type widget on a command line to run it), then there's perldoc Tk::Pack; perldoc Tk::Grid; perldoc Tk::place.

    To your second question: I've never thought a GUI builder for Tk to be that needed, but guido may fit the bill. It might be alpha-quality though, but it's a start. Being written in Perl/Tk it might offer some hints about good Perl/Tk programming, though.

    The book "Mastering Perl/Tk" is probably the book to get. Short of buying the book you could always download the code samples the book first.