Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

comment on

( [id://3333] : superdoc . print w/replies, xml ) Need Help??
Esteemed monks,

In a Perl/Tk application I create a notebook, then a tab which I populate. One of the fields is a Tk::Entry which is to get a file name. But when the variable gets updated, the value shown in the Tk::Entry does not change on the screen.

Draw the notebook:
sub draw { my $self = shift; print "Notebook Page ", $self->{_nb}; my $notebook = $self->{_nb}->parent(); #$notebook->pageconfigure( 'page12', -raisecmd => sub { $self->_load +_configs } ); #notebook portion $self->{_subnb} = $self->{_nb}->NoteBook()->grid(); $self->{subnb_p1} = $self->{_subnb}->add( 'page1', -label => 'Prepar +e email message' ); $self->_draw_subnb_p1(); }
then populate it:
sub _draw_subnb_p1 { my $self = shift; # FRAME - top left side $self->{subnb_p1}->Label( -text => 'Email Subject', )->grid( $self->{subnb_p1}->Entry( -width => 50, -textvariable => \$::cini_global->{trickle}->{subject}, ), -padx => 5, -pady => 5, ); $self->{subnb_p1}->Label( -text => 'Email template', -width => '12', )->grid( $self->{subnb_p1}->Entry( -width => '50', -textvariable => \$::cini_global->{trickle}->{email_template_fil +e} ), $self->{subnb_p1}->Button( -text => 'Browse', -command => sub { $self->_getImportFile() }, ), $self->{_edemail_button} = $self->{subnb_p1}->Button( -text => 'Edit', -command => sub { $self->_edit_emailtemplate() }, ), -padx => 5, -pady => 5, ); my $top = $self->{subnb_p1}->Frame( -borderwidth => 2, -relief => 'r +aised' )->grid(); $top->Button( -text => 'Preview Email', -command => sub { $self->_preview_emailtemplate() }, )->grid( $top->Button( -text => 'Send Emails', -command => sub { $self->_send_emails() }, ), -padx => 5, -pady => 5, ); }
 $::cini_global is a global configuration hash whioch is populate using Config::IniHash

Now click on the button to change the file name and this gets called:

sub _getImportFile { my $self = shift; # Get the name of the file we are going to import my @types = ( [ "TMPL files", '.tmpl' ], [ "All Files", "*" ], ); $::cini_global->{trickle}->{email_template_file} = $self->{_nb}->get +OpenFile( -filetypes => \@types ); if ( $::cini_global->{trickle}->{email_template_file} ) { $self->{_edemail_button}->configure( -state => 'normal' ); } WriteINI( $::CONFIG_FILE, $::cini_global ); print Dumper $::cini_global; $self->{_mw}->update(); }
You will see as soon as I get the file name I write the config hash back to disk - just in case. I can see the file change when I look at it, but despite the fact that $::cini_global->{trickle}->{email_template_file} has changed the display does not change! Am I doing something stupid here? Or is there a bug somewhere??


In reply to Tk::Entry not updating when textvariable changes. by jdtoronto

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.