Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Win32 GUI - Problem with text input field

by Anonymous Monk
on Jun 15, 2014 at 23:11 UTC ( [id://1089976]=note: print w/replies, xml ) Need Help??


in reply to Win32 GUI - Problem with text input field

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

Replies are listed 'Best First'.
Re^2: Win32 GUI - Problem with text input field
by dasgar (Priest) on Oct 15, 2014 at 06:44 UTC
    Win32::GUI is a dead end, hasn't been updated in forever

    Sounds like from your post that you have a long list of reasons for not liking Win32::GUI. However, just wanted to point out that it looks like there's been 2 new version releases of Win32::GUI in the past 7 days according to its change log. Of course, that's about 4 months after the date of your post.

    Doubt that this new information will change your opinion about using Win32::GUI, but for those looking for help with Win32::GUI and come across this thread, they probably would appreciate knowing that the module is being actively maintained with fairly recent updates.

      dasgar, first release since the seven years since the last time Win32::GUI was abandoned, even microsoft is not pushing MFC anymore

      Adding compiler fixes, and applying five year old patches isn't exactly what I would call "actively maintained" -- its getting some love and that is a good thing

      Single-platform toolkits just are not appealing ( even KMX knows, he releases IUP )

      but if are making money on Win32::GUI, great :)

Re^2: Win32 GUI - Problem with text input field
by Andreas44 (Initiate) on Jun 17, 2014 at 18:00 UTC
    Thank you for your help

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1089976]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-04-25 05:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found