Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: tk label text disappears ?!

by jdtoronto (Prior)
on Jul 31, 2006 at 13:59 UTC ( #564742=note: print w/ replies, xml ) Need Help??


in reply to tk label text disappears ?!

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


Comment on Re: tk label text disappears ?!
Select or Download Code
Re^2: tk label text disappears ?!
by lepetitalbert (Monsignor) on Jul 31, 2006 at 14:21 UTC

    Hi jdtoronto,

    THANK YOU.

    I somehow totally missed this grid method.

    Have a nice day.

    "There is only one good, namely knowledge, and only one evil, namely ignorance." Socrates

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://564742]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2015-07-05 21:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (68 votes), past polls