Skip Menu |

This queue is for tickets about the Tk CPAN distribution.

Report information
The Basics
Id: 52335
Status: open
Priority: 0/
Queue: Tk

People
Owner: Nobody in particular
Requestors: michael.parker [...] st.com
slaven [...] rezic.de
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



CC: <slaven [...] rezic.de>
Subject: Tk 'chooseDirectory' widget inoperative under Tk-804.028_501 on Cygwin 1.7
Date: Tue, 1 Dec 2009 10:53:58 -0000
To: <bug-Tk [...] rt.cpan.org>
From: Michael PARKER <michael.parker [...] st.com>
I'm attempting to use the Tk 'chooseDirectory' widget on a Cygwin 1.7 platform, running Tk-804.028_501. Invoking 'chooseDirectory', I see the following stacktrace: Tk::Error: Odd number of args to Tk::Button->new(...) Tk callback for . Tk callback for .fbox.frame Tk callback for .fbox.frame1 Tk callback for .fbox.frame2 Tk::Widget::new at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Widget.pm line 165 Tk::Widget::__ANON__ at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Widget.pm line 258 Tk::FBox::Populate at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/FBox.pm line 136 Tk::Derived::InitObject at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Derived.pm line 477 Tk::Widget::new at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Widget.pm line 204 Tk::Widget::__ANON__ at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Widget.pm line 258 Tk::DialogWrapper at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk.pm line 372 Tk::FDialog at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk.pm line 403 Tk::__ANON__ at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk.pm line 271 Tk::chooseDirectory at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk.pm line 352 Odd number of args to Tk::Button->new(...) at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Widget.pm line 204 This traces back to the Populate method of the FBox module, where cget's are being called on $f2_lab Label widget (line 136-146, FBox.pm). Looking at the contents of the $f2_lab hash in the debugger, it appears to be basically empty except for the a single key/data pair. There's certainly no data for the cget's to report back, causing the Button widget creation at line 136 to include undefined data for some values: $w->{'typeMenuLab'} = my $typeMenuLab = $f3->Button (-text => 'Files of type:', -anchor => 'e', -width => 14, -underline => 9, -bd => $f2_lab->cget(-bd), -highlightthickness => $f2_lab->cget(-highlightthickness), -relief => $f2_lab->cget(-relief), -padx => $f2_lab->cget(-padx), -pady => $f2_lab->cget(-pady), -takefocus => 0, ); As a workaround, I've inserted checks to see whether the cget's are defined before assigning them. If they're not defined, safe values are assigned: $w->{'typeMenuLab'} = my $typeMenuLab = $f3->Button (-text => 'Files of type:', -anchor => 'e', -width => 14, -underline => 9, -bd => (defined $f2_lab->cget(-bd) ? $f2_lab->cget(-bd) : 1), -highlightthickness => (defined $f2_lab->cget(-highlightthickness) ? $f2_lab->cget(-highlightthickness) : 0), -relief => (defined $f2_lab->cget(-relief) ? $f2_lab->cget(-relief) : "flat"), -padx => (defined $f2_lab->cget(-padx) ? $f2_lab->cget(-padx) : 0), -pady => (defined $f2_lab->cget(-pady) ? $f2_lab->cget(-pady) : 0), -takefocus => 0, ); Although the issue re. why the $f2_lab Label widget is essentially empty remains, the above hack appears to successfully workaround the issue. With this workaround in place, invoking 'chooseDirectory' now produces the following: Tk::Error: Can't set -activebackground to `undef' for Tk::Menu=HASH(0x10b31b38): Cannot use undef value for object of type 'border' at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Configure.pm line 46. at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Derived.pm line 294 Tk callback for . Tk callback for .fbox.frame Tk callback for .fbox.frame1 Tk callback for .fbox.frame2 Tk::Derived::configure at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Derived.pm line 306 Tk::Widget::new at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Widget.pm line 206 Tk::Widget::__ANON__ at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Widget.pm line 258 Tk::Menubutton::menu at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Menubutton.pm line 348 Tk::Menubutton::InitObject at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Menubutton.pm line 43 Tk::Widget::new at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Widget.pm line 204 Tk::Widget::__ANON__ at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Widget.pm line 258 Tk::FBox::Populate at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/FBox.pm line 150 Tk::Derived::InitObject at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Derived.pm line 477 Tk::Widget::new at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Widget.pm line 204 Tk::Widget::__ANON__ at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Widget.pm line 258 Tk::DialogWrapper at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk.pm line 372 Tk::FDialog at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk.pm line 403 Tk::__ANON__ at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk.pm line 271 Tk::chooseDirectory at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk.pm line 352 Can't set -activebackground to `undef' for Tk::Menu=HASH(0x10b31b38): Cannot use undef value for object of type 'border' at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Configure.pm line 46. at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Derived.pm line 294 at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Derived.pm line 306 This appears to have similar origins to the FBox problem, only this time a Menubutton widget is being configure'd with undefined data. As a workaround, I've added the following to the 'menu' sub of the Menubutton.pm module to filter out undefined properties: sub menu { my ($w,%args) = @_; my $menu = $w->cget('-menu'); if (!defined $menu) { require Tk::Menu; $w->ColorOptions(\%args) if ($Tk::platform eq 'unix'); +> foreach my $key (keys %args) +> { +> delete $args{$key} if (!defined $args{$key}); +> } $menu = $w->Menu(%args); $w->configure('-menu'=>$menu); } else { $menu->configure(%args); } return $menu; } This now results in an apparently functional 'chooseDirectory' widget. Mike
CC: <bug-Tk [...] rt.cpan.org>
Subject: Re: Tk 'chooseDirectory' widget inoperative under Tk-804.028_501 on Cygwin 1.7
Date: Tue, 01 Dec 2009 22:05:30 +0100
To: <michael.parker [...] st.com>
From: Slaven Rezic <slaven [...] rezic.de>
Michael PARKER <michael.parker@st.com> writes: Show quoted text
> I'm attempting to use the Tk 'chooseDirectory' widget on a Cygwin 1.7 platform, running Tk-804.028_501. > > Invoking 'chooseDirectory', I see the following stacktrace: > > Tk::Error: Odd number of args to Tk::Button->new(...) > Tk callback for . > Tk callback for .fbox.frame > Tk callback for .fbox.frame1 > Tk callback for .fbox.frame2 > Tk::Widget::new at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Widget.pm line 165 > Tk::Widget::__ANON__ at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Widget.pm line 258 > Tk::FBox::Populate at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/FBox.pm line 136 > Tk::Derived::InitObject at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Derived.pm line 477 > Tk::Widget::new at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Widget.pm line 204 > Tk::Widget::__ANON__ at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Widget.pm line 258 > Tk::DialogWrapper at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk.pm line 372 > Tk::FDialog at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk.pm line 403 > Tk::__ANON__ at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk.pm line 271 > Tk::chooseDirectory at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk.pm line 352 > Odd number of args to Tk::Button->new(...) > at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Widget.pm line 204 > > This traces back to the Populate method of the FBox module, where cget's are being called on $f2_lab Label widget (line 136-146, FBox.pm). Looking at the contents of the $f2_lab hash in the debugger, it appears to be basically empty except for the a single key/data pair. There's certainly no data for the cget's to report back, causing the Button widget creation at line 136 to include undefined data for some values: > > $w->{'typeMenuLab'} = my $typeMenuLab = $f3->Button > (-text => 'Files of type:', > -anchor => 'e', > -width => 14, > -underline => 9, > > > -bd => $f2_lab->cget(-bd), > -highlightthickness => $f2_lab->cget(-highlightthickness), > -relief => $f2_lab->cget(-relief), > -padx => $f2_lab->cget(-padx), > -pady => $f2_lab->cget(-pady), > > > -takefocus => 0, > ); >
Hi Mike, can you try to add these lines before the ->Button call: use Data::Dumper; warn Dumper({ -bd => $f2_lab->cget(-bd), -highlightthickness => $f2_lab->cget(-highlightthickness), -relief => $f2_lab->cget(-relief), -padx => $f2_lab->cget(-padx), -pady => $f2_lab->cget(-pady), }); and send the output back to me? It is possible that one or some of the cget() calls return an empty list instead of an undef value. This would explain the "Odd number of args to" error. Regards, Slaven -- Slaven Rezic - slaven <at> rezic <dot> de tkrevdiff - graphical display of diffs between revisions (RCS, CVS or SVN) http://ptktools.sourceforge.net/#tkrevdiff
Slaven, As requested: $VAR1 = { '-pady' => undef, '-relief' => '-padx', '-bd' => '-highlightthickness' }; Tk::Error: Odd number of args to Tk::Button->new(...) Tk callback for . Tk callback for .fbox.frame Tk callback for .fbox.frame1 Tk callback for .fbox.frame2 Tk::Widget::new at /usr/lib/perl5/vendor_perl/5.10/i686- cygwin/Tk/Widget.pm line 165 Tk::Widget::__ANON__ at /usr/lib/perl5/vendor_perl/5.10/i686- cygwin/Tk/Widget.pm line 258 Tk::FBox::Populate at /usr/lib/perl5/vendor_perl/5.10/i686- cygwin/Tk/FBox.pm line 145 Tk::Derived::InitObject at /usr/lib/perl5/vendor_perl/5.10/i686- cygwin/Tk/Derived.pm line 477 Tk::Widget::new at /usr/lib/perl5/vendor_perl/5.10/i686- cygwin/Tk/Widget.pm line 204 Tk::Widget::__ANON__ at /usr/lib/perl5/vendor_perl/5.10/i686- cygwin/Tk/Widget.pm line 258 Tk::DialogWrapper at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk.pm line 372 Tk::FDialog at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk.pm line 403 Tk::__ANON__ at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk.pm line 271 Tk::chooseDirectory at /usr/lib/perl5/vendor_perl/5.10/i686- cygwin/Tk.pm line 352 Odd number of args to Tk::Button->new(...) at /usr/lib/perl5/vendor_perl/5.10/i686-cygwin/Tk/Widget.pm line 204 --- From my limited knowledge, this behaviour appears to be consistent with zero-sized lists being returned by the cget's e.g. Show quoted text
> perl -e 'use strict; my @empty = (); my %hash = (1, @empty, 2, 3);
foreach my $key (keys %hash) {print $key." ".$hash{$key}."\n"}' Is the ability of empty lists to modify their "parent" data structure a known "feature" of Perl? Best regards, Mike
On Wed Dec 02 03:46:22 2009, michael.parker@st.com wrote: Show quoted text
> > From my limited knowledge, this behaviour appears to be consistent with > zero-sized lists being returned by the cget's >
This is quite strange, as cget should never return an empty list, but instead just undef. In fact, I installed recent cygwin and tried Tk 804.028_502 and cannot reproduce the behavior. So it is maybe fixed in my version of cygwin, or in the newer version of Tk (unlikely), or it is dependent on your X11 environment (e.g. used window manager, contents of .Xdefaults etc.). I used fvwm2 in my tests. Regards, Slaven
CC: <slaven [...] rezic.de>
Subject: RE: [rt.cpan.org #52335] Tk 'chooseDirectory' widget inoperative under Tk-804.028_501 on Cygwin 1.7
Date: Thu, 4 Feb 2010 10:25:31 -0000
To: <bug-Tk [...] rt.cpan.org>
From: Michael PARKER <michael.parker [...] st.com>
Slaven, Reviewing the contents of the bug, the problem is not that cget is returning an empty list. Rather, cget is correctly returning an 'undef' but the code calling the cget is unable to handle the 'undef' cget is returning. My workarounds improve the ability of the parent code to handle the 'undef' value returned by cget. The root issue is why the hash(es) queried by cget are basically empty, causing cget to return the undef. Hope that helps, Mike Show quoted text
> -----Original Message----- > From: Slaven_Rezic via RT [mailto:bug-Tk@rt.cpan.org] > Sent: Tuesday, February 02, 2010 7:03 PM > To: michael.parker@st.com; slaven@rezic.de > Subject: [rt.cpan.org #52335] Tk 'chooseDirectory' widget > inoperative under Tk-804.028_501 on Cygwin 1.7 > > <URL: https://rt.cpan.org/Ticket/Display.html?id=52335 > > > On Wed Dec 02 03:46:22 2009, michael.parker@st.com wrote:
> > > > From my limited knowledge, this behaviour appears to be
> consistent with
> > zero-sized lists being returned by the cget's > >
> > This is quite strange, as cget should never return an empty list, but > instead just undef. In fact, I installed recent cygwin and tried Tk > 804.028_502 and cannot reproduce the behavior. So it is maybe fixed in > my version of cygwin, or in the newer version of Tk > (unlikely), or it is > dependent on your X11 environment (e.g. used window manager, > contents of > .Xdefaults etc.). I used fvwm2 in my tests. > > Regards, > Slaven > >