Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

'0x1b03b2' Isn't Numeric

by Jeffers (Initiate)
on Aug 06, 2002 at 04:58 UTC ( #187926=perlquestion: print w/ replies, xml ) Need Help??
Jeffers has asked for the wisdom of the Perl Monks concerning the following question:

I am attempting to nest a Toplevel Tk widget into a container frame. The documentation seems pretty simple, saying I should set the Toplevel's -use property to the hex id number returned by "winfo id". Using the code

my $child = $main->Toplevel( -title=>'Child Window', -use=>$box->winfo('id') );

where $box is the container frame, I get this error:

'0x1b03b2' isn't numeric

I searched quite a lot for documentation on winfo or Toplevel, but found nothing that went into detail enough to give me any ideas to solve the problem. All the documentation seems to say that this is pretty simple, so maybe I'm missing something obvious?

Thanks for any help,
-Jeff :)

Comment on '0x1b03b2' Isn't Numeric
Download Code
Re: '0x1b03b2' Isn't Numeric
by Chmrr (Vicar) on Aug 06, 2002 at 06:05 UTC

    I'm unable to replicate your problem. Here's the code I'm using:

    #!/usr/bin/perl -w use strict; use Tk; my $mw = MainWindow->new(-title=>"Foo!"); my $f = $mw->Frame(-width=>400, -height=>400)->pack; print "Tk is $Tk::VERSION; Window id is ",$f->winfo('id'),"\n"; my $child = $mw->Toplevel(-title=>"Bar!",-use=>$f->winfo('id')); $child->Label(-text=>"Bar!")->pack; MainLoop;

    ..which tells me that Tk is 800.023; Window id is 0x2e00004 and pops up a window. Either your version of Tk is out of date or something, or there's something in the surrounding code which is making Tk go awry.

    perl -pe '"I lo*`+$^X$\"$]!$/"=~m%(.*)%s;$_=$1;y^`+*^e v^#$&V"+@( NO CARRIER'

      I tried a ppm install of Tk again with no affect. Copying your exact code simply results in the same error. I'm using ActivePerl 5.6 on Windows 2000. I must find a way to get this to work, or my boss will make me do this program in VB! AH! Help!

      Thanks,
      Jeff :)

        I did a little research, and it looks like you may be essentially out of luck. See item B-10 here; what it boils down to is "it just don't work under Windows sometimes -- it's a problem with Tcl/Tk, not just Perl/Tk." Which is indeed sad news.

        perl -pe '"I lo*`+$^X$\"$]!$/"=~m%(.*)%s;$_=$1;y^`+*^e v^#$&V"+@( NO CARRIER'

Re: '0x1b03b2' Isn't Numeric
by PodMaster (Abbot) on Aug 06, 2002 at 09:46 UTC
    Same here, This is perl, v5.6.1 built for MSWin32-x86-multi-thread (with 1 registered patch, see perl -V for more detail) Copyright 1987-2001, Larry Wall Binary build 633 provided by ActiveState Corp. http://www.ActiveState.com Built 21:33:05 Jun 17 2002
    #!/usr/bin/perl -w use strict; use Tk; my $mw = MainWindow->new( -title=>"Foo!", ); my $f = $mw->Frame( -width=>400, -height=>400, )->pack; $\ = "\n"; print "Tk is $Tk::VERSION; Window id is ", $f->winfo('id'); my $child = $mw->Toplevel( -title => "Bar!", -use => $f->winfo('id'), ); $child->Label( -text=>"Bar!", )->pack; MainLoop(); __END__ Tk is 800.023; Window id is 0x190274 '0x190274' isn't numeric at C:/Perl/site/lib/Tk/Widget.pm line 188. Tk::Widget::new('Tk::Toplevel', 'MainWindow=HASH(0x1ab11dc)', '-ti +tle', 'Bar!', '-use', '0x190274') called at C:/Perl/site/lib/Tk/Widge +t.pm line 247 Tk::Widget::__ANON__('MainWindow=HASH(0x1ab11dc)', '-title', 'Bar! +', '-use', '0x190274') called at foy line 19
    I'm about to try it out on Tk 800.24 in the same perl 5.8.0.

    Bah, forget it. This is yet another eason I say forget Tk, just use WxPerl.

    jsprat: kickass. I've had similar problems when inlining images (--data). I had no idea they had to be base64 encoded. Where is this documented (i know the err kinda gives it away, but i've no idea what the module had expected, and well, looking at the source is something I forgot to do)?

    ____________________________________________________
    ** The Third rule of perl club is a statement of fact: pod is sexy.

      So make it explicitly numeric ;) Your code almost does what I would expect... Two minor changes (see ### commented lines below, and the code works as advertised. Creates a top-level window and places the child window (bar) inside the parent window (foo).

      #!/usr/bin/perl -w use strict; use Tk; my $mw = MainWindow->new( -title=>"Foo!", ); ### '-container' property needs to be true my $f = $mw->Frame( -width=>400, -height=>400, -container => 1, )->pack; $\ = "\n"; print "Tk is $Tk::VERSION; Window id is ", $f->winfo('id'); ### add the following line, change the -use line below my $winfo = hex $f->winfo('id'); my $child = $mw->Toplevel( -title => "Bar!", -use => $winfo, ); $child->Label( -text=>"Bar!", )->pack; MainLoop(); __END__ output: Tk is 800.023; Window id is 0xff0344

      BTW, ++podmaster for doing the hard work

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://187926]
Approved by flocto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2014-12-21 21:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (108 votes), past polls