Tk::Checkbutton - text does not line up ...

Discussion in 'Perl Misc' started by MoshiachNow, Sep 10, 2006.

  1. MoshiachNow

    MoshiachNow Guest

    HI,

    Using a function on Windows,I define a $test variable as following:

    $text=sprintf("%-35s %-13s",$_,'(directory)');

    Then define the checkbutton:

    $button[$i] = $dialog5->Checkbutton(-text => "$text",-variable =>
    \($var->{$_}),-relief => 'flat')->pack(@pl);

    The text in $text DOES NOT get lined up !

    If at the same time I print $text to the black window

    print "$text\n";

    the text DOES look lined up.

    What is wrong ?
    Thanks
     
    MoshiachNow, Sep 10, 2006
    #1
    1. Advertising

  2. MoshiachNow

    Dave Guest

    "MoshiachNow" <> wrote in message
    news:...
    > HI,
    >
    > Using a function on Windows,I define a $test variable as following:
    >
    > $text=sprintf("%-35s %-13s",$_,'(directory)');
    >
    > Then define the checkbutton:
    >
    > $button[$i] = $dialog5->Checkbutton(-text => "$text",-variable =>
    > \($var->{$_}),-relief => 'flat')->pack(@pl);
    >
    > The text in $text DOES NOT get lined up !
    >
    > If at the same time I print $text to the black window
    >
    > print "$text\n";
    >
    > the text DOES look lined up.
    >
    > What is wrong ?
    > Thanks
    >


    By default the text is 'center' anchored; you probably don't want this so
    try setting the -anchor option, e.g. anchor => 'w', as appropriate.
     
    Dave, Sep 10, 2006
    #2
    1. Advertising

  3. MoshiachNow

    Ch Lamprecht Guest

    Dave wrote:
    > "MoshiachNow" <> wrote in message
    > news:...
    >
    >>HI,
    >>
    >>Using a function on Windows,I define a $test variable as following:
    >>
    >>$text=sprintf("%-35s %-13s",$_,'(directory)');
    >>
    >>Then define the checkbutton:


    >>The text in $text DOES NOT get lined up !


    >
    >
    > By default the text is 'center' anchored; you probably don't want this so
    > try setting the -anchor option, e.g. anchor => 'w', as appropriate.
    >
    >
    >

    In addition you might consider using a fixed-width font to have the second part
    of your label aligned vertically as well:

    use strict;
    use warnings;
    use Tk;
    my $mw = tkinit();
    my @text =
    map {sprintf("%-35s %-13s",$_,'(directory)')
    } qw(test something_else);
    my @buttons =
    map {$mw->Checkbutton(-text => $text[$_],
    -font=>[courier => 9]
    )->pack(-anchor=>'w')
    } (0,1);

    MainLoop();


    Christoph


    --

    perl -e "print scalar reverse q//"
     
    Ch Lamprecht, Sep 10, 2006
    #3
  4. MoshiachNow

    MoshiachNow Guest


    > In addition you might consider using a fixed-width font to have the second part
    > of your label aligned vertically as well:



    Thanks !

    This worked like magic !!
     
    MoshiachNow, Sep 11, 2006
    #4
    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. Askari
    Replies:
    2
    Views:
    417
    Eric Brunel
    Jan 15, 2004
  2. Elaine Jackson

    Tkinter CheckButton variables

    Elaine Jackson, Jul 1, 2004, in forum: Python
    Replies:
    1
    Views:
    444
    klappnase
    Jul 1, 2004
  3. Paul Rubin
    Replies:
    3
    Views:
    819
    Eric Brunel
    Jul 4, 2005
  4. Tuvas

    Tkinter- checkbutton

    Tuvas, Nov 4, 2005, in forum: Python
    Replies:
    3
    Views:
    1,136
    Tuvas
    Nov 4, 2005
  5. Dodo
    Replies:
    6
    Views:
    1,166
Loading...

Share This Page