# Assuming my $mw = MainWindow(...) sub button_press { # Do some work $mw->update; # Do some more work $mw->update; # etc...