my $btn_source_file = $mw->new_tk__button( -text => "Choose...", -command => sub { get_source_filename(); } ); sub get_source_filename { $source_file = Tkx::tk___getOpenFile(); }