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

StackOverflow https://stackoverflow.com/questions/18244249

  •  24-06-2022
  •  | 
  •  

Вопрос

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

Это было полезно?

Решение

$self->{class_source_txt}->SetLabel($classifier);

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

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top