Skip to content

AUTOLOAD Issues while with several Tk subroutines (grab_set, wait_window, update_idletasks....) #110

@Digioso

Description

@Digioso

I'm using StrawberryPerl 5.40.0.1-64bit on Windows 11 and have installed Tk using these instructions: StrawberryPerl/Perl-Dist-Strawberry#87 (comment)
I uninstalled StrawberryPerl completely and did a fresh install. The issue persisted.
I noticed this with grab_set, update_idletasks & wait_window so far. I believe there was one more, but can't remember.
Using grab instead of grab_set works.

First thing: I'm from Germany and use a German locale. Tk however doesn't seem to be compatible with non-English locale, so maybe the issues come from there.
This has already been mentioned here: #107 (comment)
And also in the posting I linked above.

Workaround is to set LC_ALL & LANG to C. With this it installed successfully.

C:\>set LC_ALL=C

C:\>set LANG=C

C:\>cpanm https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/patched_cpan_modules/Tk-804.036_001.tar.gz
--> Working on https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/patched_cpan_modules/Tk-804.036_001.tar.gz
Fetching https://github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/patched_cpan_modules/Tk-804.036_001.tar.gz ... OK
Configuring Tk-804.036001 ... OK
Building and testing Tk-804.036001 ... OK
Successfully installed Tk-804.036001
1 distribution installed

C:\>

Example code:

#!/usr/bin/perl -w
use strict;
use warnings;
use utf8;
use POSIX qw(setlocale LC_ALL);
use POSIX;
use Tk;
use feature ('say', 'signatures');

my $mw = MainWindow->new;
$mw->title("Title");
$mw->geometry("800x600");
my $btn_frame = $mw->Frame()->pack(-side => 'right', -fill => 'y');
$btn_frame->Button(-text => 'button-text', -command => \&sub_function)->pack(-fill => 'x');

MainLoop();
exit 0;

sub sub_function
{
    my $pre_dialog = $mw->Toplevel();
	focus_dialog($pre_dialog, "sub text", $mw);
	print "...\n";
}

sub focus_dialog
{
	my ($window_widget, $window_title, $parent_widget) = @_;

    unless (eval { $window_widget->isa('Tk::Widget') } && eval { $parent_widget->isa('Tk::Widget') }) {
        warn "focus_dialog: Ungültige Widget-Argumente erhalten!";
        return;
    }

    $window_widget->title($window_title);
    $window_widget->transient($parent_widget);

    #$window_widget->update_idletasks;


    $window_widget->grab_set();

    $window_widget->focusForce;
}

Example errors:

R:\Pen & Paper\Uniworld\Uniworld Charakter Manager>test.pl
Tk::Error: Failed to AUTOLOAD 'Tk::Toplevel::grab_set' at R:\Pen & Paper\Uniworld\Uniworld Charakter Manager\test.pl line 41.
 Tk callback for .toplevel
 Carp::croak at C:/Strawberry/perl/lib/Carp.pm line 291
 Tk::Widget::__ANON__ at C:/Strawberry/perl/site/lib/Tk/Widget.pm line 347
 main::focus_dialog at R:\Pen & Paper\Uniworld\Uniworld Charakter Manager\test.pl line 41
 main::sub_function at R:\Pen & Paper\Uniworld\Uniworld Charakter Manager\test.pl line 22
 Tk callback for .frame.button
 Tk::__ANON__ at C:/Strawberry/perl/site/lib/Tk.pm line 251
 Tk::Button::butUp at C:/Strawberry/perl/site/lib/Tk/Button.pm line 175
 <ButtonRelease-1>
 (command bound to event)

Tk::Error: Failed to AUTOLOAD 'Tk::Toplevel::update_idletasks' at R:\Pen & Paper\Uniworld\Uniworld Charakter Manager\test.pl line 38.
 Tk callback for .toplevel
 Carp::croak at C:/Strawberry/perl/lib/Carp.pm line 291
 Tk::Widget::__ANON__ at C:/Strawberry/perl/site/lib/Tk/Widget.pm line 347
 main::focus_dialog at R:\Pen & Paper\Uniworld\Uniworld Charakter Manager\test.pl line 38
 main::sub_function at R:\Pen & Paper\Uniworld\Uniworld Charakter Manager\test.pl line 22
 Tk callback for .frame.button
 Tk::__ANON__ at C:/Strawberry/perl/site/lib/Tk.pm line 251
 Tk::Button::butUp at C:/Strawberry/perl/site/lib/Tk/Button.pm line 175
 <ButtonRelease-1>
 (command bound to event)

Tk::Error: Failed to AUTOLOAD 'Tk::Toplevel::wait_window' at R:\Pen & Paper\Uniworld\Uniworld Charakter Manager\test.pl line 38.
 Tk callback for .toplevel
 Carp::croak at C:/Strawberry/perl/lib/Carp.pm line 291
 Tk::Widget::__ANON__ at C:/Strawberry/perl/site/lib/Tk/Widget.pm line 347
 main::focus_dialog at R:\Pen & Paper\Uniworld\Uniworld Charakter Manager\test.pl line 38
 main::sub_function at R:\Pen & Paper\Uniworld\Uniworld Charakter Manager\test.pl line 22
 Tk callback for .frame.button
 Tk::__ANON__ at C:/Strawberry/perl/site/lib/Tk.pm line 251
 Tk::Button::butUp at C:/Strawberry/perl/site/lib/Tk/Button.pm line 175
 <ButtonRelease-1>
 (command bound to event)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions