Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: How do you make Tk look good?

by zentara (Archbishop)
on Jul 16, 2008 at 12:48 UTC ( #697956=note: print w/replies, xml ) Need Help??

in reply to How do you make Tk look good?

I'm one of those types that like to get one thing working well and under my control, and use that come what may. That said, I decided a long time ago, that the Canvas (and Tk::Zinc) widgets, will do anything you want, and can be made to look as nice as the effort you are willing to put into it. Just look at the Tk::Zinc demo. Now that the Goo::Canvas is coming along nicely( for Gtk2), I will probably concentrate on that.

If you try, you will find that emulating the regular widgets in Tk on a Canvas, is not that difficult. You get far more control over all the bindings (which is a real hassle on some of the regular widgets, where button 1 presses are predefined), and you can make nice shapes and graphics for buttons and labels. The biggest problem you need to deal with is the size and spacing of text. I found an easy workaround by taking the bbox of a capital W, and use that as the default spacing for the font used. Using that, you can make side-by-side lists, and do easy drag-and-drop. Additionally, the canvas is very good at memory management on it's items......and this avoids many memory gain problems encountered in standard widgets, when you do alot of changes.

Anyways..... if I want something to look good, I will go with one of the various canvases, not that Tkx isn't good, but I would rather be good at the canvas( where I'm in full control), than half-ass good at Tkx (where I'm dependent on some other programmers and have less control).

Oh yeah, the canvas's already do tiling of backgrounds. :-)

I'm not really a human, but I play one on earth CandyGram for Mongo

Replies are listed 'Best First'.
Re^2: How do you make Tk look good?
by Anonymous Monk on Jul 16, 2008 at 14:37 UTC

    If you were starting a project today from scratch and could choose either, would you go with Tk/Tk::Zinc or Gtk2?

      I would go with the Goo::Canvas, because it does everything Zinc does, (transparency, rotations, zooming, etc) plus it outputs it's entire scrollregion as pdf or svg. Zinc has no pdf output. The Tk::Canvas doesn't do transparency nor rotations(easily). So it really depends on whether I need transparency, rotations, and saving. If so.... Goo::Canvas; but if not, probably Tk::Canvas since it is more portable as of now, but in general, I don't care about MSWindows, I write for linux/unix type systems.

      I'm not really a human, but I play one on earth CandyGram for Mongo
Re^2: How do you make Tk look good?
by cmv (Chaplain) on Jul 17, 2008 at 21:09 UTC
    zentara I also used the bbox of Capital-W method, but just recently uncovered something called fontMeasure from Mastering Perl/Tk in Chapter 3 - Font Manipulation Methods. I've not really tried it yet, but would this be a better solution for this problem?
      Hi, I think I went with bbox for the Canvas, because it gives BOTH height and width. The fontMeasure says it measures width, and seems to be oriented towards text widgets, that do vertical spacing automatically for you. When you are putting lists on a Canvas, you need to take care of the vertical spacing yourself. I chose the W, since it seemed the biggest( not in honor of George W. Bush:-) ). That way, I can do one calculation for my vertical spacing (assuming font is constant)..... get the bbox of W, take the diff of the y's....add 2 pixels for line spacing.

      I'm not really a human, but I play one on earth CandyGram for Mongo

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://697956]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2017-08-22 23:48 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (344 votes). Check out past polls.