cormanaz has asked for the wisdom of the Perl Monks concerning the following question:

Good day Monks. When I run the follow code,
use Win32::GUI; $dataform = Win32::GUI::Window->new( -name => 'dataform', -width => 400, -height => 600, ); $dataform->AddTextfield( -name => 'example', -text => 'Here is some text', ); $dataform->Show(); Win32::GUI::Dialog(); sub dataform_Terminate { -1; }
I get a window with nothing in it. If I add a -prompt value to the Textfield object, I get a prompt but no text. If I print $dataform->{example}->{'-text'} it prints out OK. Why won't it show on the window?!? Many thanks..... Steve

Replies are listed 'Best First'.
Re: Win32::GUI::Textfield problems
by PodMaster (Abbot) on Jul 20, 2004 at 20:09 UTC
    You need to specify dimensions and location, ie
    -left => 10, -top => 10, -width => 200, -height => 22,
    wxPerl is a much nicer choice.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Re: Win32::GUI::Textfield problems
by heroin_bob (Sexton) on Jul 20, 2004 at 19:02 UTC
    I'm not very familiar with this module, but I'd guess that the trailing comma after the last param "-height => 600," and "-text => 'Here is some text'," might be to blame. Are you using strict?
    ~hb
      No, that's actually just a plain Perl hash declaration. Watch:
      #!perl use strict; use warnings; my %hash = ( one => 1, two => 2, ); print "$_ => $hash{$_}\n" for keys %hash;
      No error.
      It's just "syntactic sugar" to make the declaration more uniform, I believe.
      Hope this helped.
      CombatSquirrel.

      Entropy is the tendency of everything going to hell.
        Gotcha, that's definitely good to know... Thnx for the tip!
        ~hb
      No, the problem was that I didn't have -height explicitly specified!

      Steve

Re: Win32::GUI::Textfield problems
by Belgarion (Chaplain) on Jul 20, 2004 at 20:09 UTC

    Try giving your text field a width and a height. Right now the field is 0x0 and positioned in the upper left hand corner of the parent window. Change your AddTextfield call to:

    $dataform->AddTextfield( -name => 'example', -text => 'Here is some text', -width => 100, -height => 100, );