Ruby/Tk: Problem with left-justifying widgets

Discussion in 'Ruby' started by Ronny, May 5, 2006.

  1. Ronny

    Ronny Guest

    Problem: My window should consists of several lines. Each line consists
    of
    - a checkbox
    - a label
    - an entry field

    I used the following approach (which works basically well - but see
    below):

    # Code for adding one line to the root window:
    frame=TkFrame.new(root)
    frame.pack()
    check=TkCheckButton.new(frame).pack("side" => "left")
    label=TkLabel.new(frame) { text "...." }
    label.pack("side" => "left")
    entry=TkEntry.new(frame).pack("side" => "left")
    entry.value="...."

    Now the problem is that since the label texts and initial values for
    each line are of
    different size, and since by default the frame is centered within the
    root window,
    the check buttons turn out to be not lined up one below the other,
    which gives an ugly look.

    I tried to remedy this by changing the first statement to

    frame=TkFrame.new(root) { justify 'left' }

    but this does not work, because "justify" is not valid for a TkFrame.

    Any idea how to solve this? Since it is so common to have lined up
    checkboxes
    one below the other, I guess there must be an easy solution to this,
    but I don't
    see how...

    Ronald

    PS: As always, other types of critics to my code, as well as hints of
    where on the I could
    have found the information I'm looking for, are welcome.
     
    Ronny, May 5, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Swetha
    Replies:
    4
    Views:
    994
    Swetha
    Feb 5, 2006
  2. Tom Parson
    Replies:
    1
    Views:
    506
    Daniel Dyer
    May 23, 2006
  3. hg
    Replies:
    4
    Views:
    305
    Gabriel Genellina
    Jan 26, 2007
  4. mantrid

    Text box justifying

    mantrid, Jan 4, 2008, in forum: HTML
    Replies:
    2
    Views:
    379
    mantrid
    Jan 4, 2008
  5. Ronny
    Replies:
    2
    Views:
    198
Loading...

Share This Page