Initial diagnosis and why Win32::GUI is bad :)

Hello, I am currently trying to design a simple perl program with Win32::GUI.

Win32::GUI is a dead end, hasn't been updated in forever, doesn't support unicode.... other problems with Win32::GUI and why I laught at those choosing Win32::GUI

If the sub window is called again in the same season, no new input is being accepted... Does anyone know how to solve that problem?

I assume its because of the way you write code , the way Win32::GUI docs encourage, the nested subs memory leaking closure way; see write Tk callbacks all lexically scoped and not-memory leaking with no nested subs ever :) avoid nested subs and closures because nested named subs because they're closures

update: yup, my assumption was correct; if you add  use warnings; you will be warned about this Variable "$main" will not stay shared ... Variable "$add" will not stay shared a ...

update: your code fixed up

#!/usr/bin/perl -- ## ## ## ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if " -otr -opr +-ce -nibc -i=4 -pt=0 "-nsak=*" #!/usr/bin/perl -- use strict; use warnings; use Win32::GUI(); Main( @ARGV ); exit( 0 ); sub Main { my $mainWindow = MainWindow(); warn "Dialog ", $mainWindow->Dialog; return; } sub MainWindow { my $main = Win32::GUI::Window->new( -width => 840, -height => 480, -text => 'Main', ); $main->AddButton( -width => 130, -height => 60, -pos => [ 100, 100 ], -text => 'Sub', -onClick => sub { warn "onClick @_ "; IncrementButtonText( @_ ); AddWindow( @_ ); ## launch another dialog? icky }, ); $main->AddButton( -width => 66, -height => 24, -pos => [ 750, 410 ], -text => 'Exit', -onClick => sub { warn "onClick @_ "; return -1; ## end this mainloop }, ); $main->Show(); return $main; } ## end sub MainWindow sub IncrementButtonText { my( $button ) = @_; my $text = $button->Text; $text =~ s{(\d*)$}{ 1 + ($1?$1:0) }e; $button->Text( $text ); return $button; } sub AddWindow { my $add = Win32::GUI::Window->new( -width => 840, -height => 480, -text => 'Add', -onTerminate => sub { warn "onTerminate @_ "; return 1; ## end this dialog }, ); $add->AddTextfield( -width => 360, -height => 130, -pos => [ 100, 100 ], -text => join( ' ', 'Input', scalar gmtime, scalar localtim +e ), -name => 'input', ); my $endthisdialog = sub { AddEnd( $add, @_ ); undef $add; 0; }; $add->AddButton( -width => 130, -height => 60, -pos => [ 100, 300 ], -text => 'Submit', -onClick => $endthisdialog, ); $add->AddButton( -width => 66, -height => 24, -pos => [ 750, 410 ], -text => "Back", -onClick => $endthisdialog, ); $add->Show(); return $add->Dialog(); } ## end sub AddWindow sub AddEnd { warn "AddEnd @_ "; my( $add, $button ) = @_; print $add->input->Text(), "\n"; return; }

http://search.cpan.org/~robertmay/Win32-GUI-1.06/docs/GUI/Reference/Options.pod#-onEVENT
http://search.cpan.org/~robertmay/Win32-GUI-1.06/docs/GUI/Reference/Options.pod#-eventmodel

more generic win32 tips

If you want to automate anything on win32 you have to absorb the following knowledge . It mostly consists of learing the ole/excel/powerpoint... object model, and using Win32::OLE to call it or sending messages using guitest. OLE is essentially a fancy/standardised way of sending messages. Its very much like web-scraping, you have to know HTTP/HTML DOM .... the rest is just legwork


In reply to Re: Win32 GUI - Problem with text input field by Anonymous Monk
in thread Win32 GUI - Problem with text input field by Andreas44

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.