It's all about packing order. You were placing the labels over the top of each other. Try this:
#!/usr/bin/perl -w use strict; use strict; use warnings; use Tk; use Tk::DialogBox; my $main_window = MainWindow -> new(); $main_window -> bind ( "<Control-Key-c>" , \&add_client ) ; # Ctrl c MainLoop; sub add_client { my $add_client_win = $main_window -> DialogBox ( -title => 'Ajouter un client' , -buttons => [ 'Valider' , 'Annuler' ] ); # BUG HERE BUG HERE BUG HERE BUG HERE BUG HERE BUG HERE BUG HERE my $firstname_line = $add_client_win -> add ( 'Label' , -height => '5', -text => 'Some text', -font => 'Helvetica 10 bold' , ) -> grid( #-side => 'top' , #-fill => 'x' ); # END BUG END BUG END BUG END BUG END BUG END BUG END BUG END BUG # -- CANTON -- my $canton_line = $add_client_win -> add ( 'Label' , -height => '5' ) -> grid( #-side => 'top' , #-fill => 'x' ); my $label_canton = $canton_line -> Label ( -font => 'Helvetica 10 bold' , -text => 'Localisation :', -padx => '10' , -pady => '5' ) -> pack ( -side => 'left' ); my ($canton_data, $canton_display ); my $canton_choice = $canton_line -> Optionmenu( -options => [ [ 'Genève' => '000' ] , [ 'Vaud' => '100' ] , [ ' - Chablais vaudois' => '110' ] , [ ' - Lausanne' => '120' ] , [ ' - Montreux-Vevey' => '130' ] , [ ' - Morges' => '140' ] , [ ' - Nyon' => '150' ] , [ ' - Yverdon' => '160' ] , [ ' - Arc lémanique' => '170' ] , [ 'Valais' => '200' ] , [ ' - Chablais valaisan' => '210' ] , [ ' - Bas Valais' => '220' ] , [ ' - Haut Valais' => '230' ] , [ 'Fribourg' => '400' ] , [ 'France voisine' => '500' ] , [ 'Paris' => '600' ] , [ 'Cote d Azur' => '700' ] , [ 'Italie' => '800' ] , ] , -command => sub { } , -variable => \$canton_data , -textvariable => \$canton_display ) -> pack( -side => 'right' , ); my $reponse = $add_client_win -> Show ( ) ; }
By using the  grid geometry manager they are placed vertically in order in a grid.

jdtoronto


In reply to Re: tk label text disappears ?! by jdtoronto
in thread tk label text disappears ?! by lepetitalbert

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.