Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Creating Tk Applications Graphically

by Vautrin (Hermit)
on Mar 12, 2004 at 17:42 UTC ( #336215=perlquestion: print w/replies, xml ) Need Help??

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

I've taken the dive into my first project with a Tk based GUI. Once I figured out Tk, development has been slow but steady. However I think I could go a lot faster if I could use a Netbeans like interface to create the Gui menus graphically, even if I had to go back in and fill in the subroutines attached to -command keys.

Does such a tool exist? Googling wasn't much help because I ended up finding a lot of Perl Tk applications, and no editors. If it doesn't exist, can anyone point me to some good Emacs elisp files, or similar resources to help create Tk applications?

Many thanks,


Want to support the EFF and FSF by buying cool stuff? Click here.

Replies are listed 'Best First'.
Re: Creating Tk Applications Graphically
by mawe (Hermit) on Mar 12, 2004 at 17:56 UTC

    After some googling I found this. Hope it is what you were looking for :-)

Re: Creating Tk Applications Graphically
by flyingmoose (Priest) on Mar 12, 2004 at 17:53 UTC
    I am one who always prefers writing GUI's in code for ultimate flexibility and control. At least in Tk I'm fast with that -- That is, because, (unlike Swing IMHO), Tk is downright easy to program in (ok, sporty and others have disagreed and like Swing -- I envy them). Why should you not use code generators? Well, because they tend to produce ugly code.

    "Mastering Perl/Tk" by O'Reilly is an incredible book, and it really makes you appreciate Tk over the various other GUI's that virtually require GUI builders (Java, MFC, etc).

    The only times I've been really happy with generated GUI's has been with GUI's that use libGlade to load XML description files. Though it is not Tk related, has anyone had any experience with Glade-Perl?

    If there are any options for libGlade like functionality using Tk (not Gtk), I'd like to hear of them. GTK is ok, but it's not super cross-platform -- plus Perl/Tk is something more people know and understand in the Perl world.

Re: Creating Tk Applications Graphically
by zentara (Archbishop) on Mar 13, 2004 at 15:46 UTC
    Most of the gui-creators are designed for Win32, and cost money. There is the Prima project, at Prima. It is kind of big and bloated and you end up not learning Tk very well. You will find that once you learn how to setup a basic main window, writing Tk is easier if done from scratch. At (the link is down as I write), you can find "Visual PerlTk" or vptk. It could be useful in just widget placement, try it and see.

    Everyone is looking for a Tk development tool like the old Visual Basic, where you right click on the widget, and just select the widget options and callbacks. Ala Qumsieh on is trying to develop "ZooZ" which is like this, but it is still in early development. And has drawbacks, like only uses grid manager.

    I really liked the way Glade worked for Gtk. It would be nice if there was something like that for Tk.

    In the mean time, there are some nice Tk tools, written by Slaven Rezic which aid in widget setup and design. Check out: Widget Dump and Tk::ObjEditor and Tk::ObjScanner from cpan.

    I'm not really a human, but I play one on earth. flash japh
      on osX the interface builder is great. there are a couple perl frameworks out there for use with IB and xcode. It's not Tk...but it's building a GUI and coding in perl.
Re: Creating Tk Applications Graphically
by Popcorn Dave (Abbot) on Mar 13, 2004 at 04:36 UTC
    I agree with flyingmoose about writing the GUI in code. You've got much more control over what you're doing and can tweak it as you desire or need to. Perhaps mave's suggestion will be the ticket for you.

    When I write Tk apps, it's easier for me to layout my interface in Photoshop or Paint Shop Pro, using the rulers set in pixel, and figure out the exact placement points of where I wanted everything to go. That way I have my layout set, and can easily movepieces if I don't like where they're placed. Then I draw dark lines and print the picture, and put the x-y coordinates on the lines. I prefer using cooridinate geometry in Tk, as I find it easier than the compass point geometry.

    Hope that helps!

    There is no emoticon for what I'm feeling now.

      But applications designed like that usually feel to me the same way web pages feel that are done by "visual" layout programs. That is, when I move the lower-right window size box, it should get bigger or smaller, darn it!

      If you lay out "logically" rather than "visually", you don't have any absolute pixels. Everything is just "left" or "right" or "above" other things, and when the main window is resized, everything is still like that. Pixel based layout tools are wrong for that.

      Now, maybe you meant that you do a Photoshop layout, but only to generally figure out where things go, and then you reduce it to simple ->pack calls rather than absolute ->place calls or fixed sizes for all your widgets. But I'm not sure, so I'm raising the issue here.

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.

        Actually for what I did, I wanted the absolute pixel placement. That worked out fine for me in that instance. However that's not to say I'd use that every time. I'd have to look at the app I was building.

        I used that technique with the first Tk app I ever did, and the ability to place things at x-y coordinates was easier for me to deal with for what I did as I had some graphics in my main window. I used Photoshop since I was more comfortable with it than Paint Shop Pro.

        It worked for me, it might not for others. I only offered it as a suggestion as the o.p. seemed to be looking for an easy solution for laying out widgets in Tk.

        There is no emoticon for what I'm feeling now.

        IMHO some of the best web site/UI designs are "pixel perfect" - don't forget stuff like having fixed size gifs (e.g. backgrounds) marry up to tables, etc.
Re: Creating Tk Applications Graphically
by redlemon (Hermit) on Mar 15, 2004 at 12:31 UTC
    If you just want to layout your application, SpecPerl (an adaptation of SpecTcl) may be useful. It's a bit old and rusty, but if you don't expect too much of it it'll do just fine.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://336215]
Approved by Grygonos
Front-paged by Courage
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (2)
As of 2022-05-29 08:05 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (101 votes). Check out past polls.