How can I dynamically updatea StaticText label after a button click event in wxPerl?

214 views Asked by At

I have a Static Text displaying the currently selected file name. I'd like it to update every time the user chooses a new file using the 'Select File' button.

I've tried using the Update() method inside the EVT_BUTTON subroutine call but is not working.

Below is a section of my code. Please excuse any bad coding practices, relatively new to this.

      $self->{class_source_txt} = Wx::StaticText->new(
                                 $panel,
                                              1,
               "Classifier Source: $classifier",
                         [-1,-1]);

      $self->{file_select} = Wx::Button->new(
                $panel,
                1,
                "Select Classifier",
               );

      EVT_BUTTON(   
        $self,
        1,
        sub{
        $classifier = FileSelect();
        $self->{class_source_txt}->Update();
            }
                );

Specifically what I am trying to do is to have the Classifier Source: $classifier line display the new value of $classifier created by the EVT_BUTTON

1

There are 1 answers

0
Alec On BEST ANSWER
$self->{class_source_txt}->SetLabel($classifier);

You could install Wx::Demo and learn from these examples.