Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Object isn't fully affected by the Animate method in Win32::GUI module

by Anonymous Monk
on Aug 11, 2024 at 12:53 UTC ( [id://11160992]=perlquestion: print w/replies, xml ) Need Help??

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

I am on Windows 10, and I am using Win32::GUI module to create a GUI-based application. The problem is, when I tried to use the Animate method (which is a common method) with a label, only the top left part of the label was applied to the animation. I had tried to change the size of the label but, the affected area was always at the top left corner, and the ratio of the affected area with respect to the whole label area seemed to remain the same.

Here is the code, when we press the button, the animation will be applied to the label:

use strict; use warnings; use Win32::GUI(); my $mainWindow = new Win32::GUI::Window( -name => 'mainWindow', -title => 'sample window', -size => [1200, 800], -minsize => [1200, 800], -onTerminate => sub { return -1; }, ); $mainWindow->AddLabel( -name => 'label1', -text => 'string in label 1', -background => 0x00ff00, -size => [500, 300], -pos => [300, 300], ); $mainWindow->AddButton( -name => 'b1', -text => 'label 1', -pos => [100, 0], -onClick => sub { $mainWindow->label1->Animate( -show => !$mainWindow->label1->IsVisible(), -activate => 1, -time => 600, -direction => 'lr', -animation => 'roll', ); }, ); $mainWindow->Show(); Win32::GUI::Dialog();

Why is that and how to solve it?

Btw, I also couldn't use any direction other than 'lr' and 'tb'.

  • Comment on Object isn't fully affected by the Animate method in Win32::GUI module
  • Download Code

Replies are listed 'Best First'.
Re: Object isn't fully affected by the Animate method in Win32::GUI module
by dasgar (Priest) on Aug 12, 2024 at 05:47 UTC

    On my Windows 10 system (22H2 build 19045.4529), I downloaded two versions of portable Strawberry Perl: 5.38.2. 64-bit, 5.32.1.1 32-bit. With both I installed Win32::GUI 1.14 and had no issues running your posted code or using any of the 8 acceptable values for the 'direction' option. Even when I add your second button into the code, it is working without the issue that you are describing.

      I think the problem is with my machine. I tried installing Strawberry Perl on another machine, and it worked fine. I also installed Cygwin, as Danny suggested, but I still encountered the same issue.

      I had MSYS2 preinstalled, so I started to think it might be the problem. However, it seemed not to be the case. I removed both MSYS2 and Strawberry, then reinstalled just Strawberry, but nothing changed.

Re: Object isn't fully affected by the Animate method in Win32::GUI module
by Danny (Hermit) on Aug 11, 2024 at 14:32 UTC
    I just installed Win32::GUI and this seems to be working ok for me. It just redraws the green rectangle with the text at the top left from left to right. Btw, I changed mine with a $mainWindow->label1->Hide; before the animate call and used -show => 1, in the Animate call so that it just redraws every time you click the button instead of toggling every other time. It also worked from bottom to top and right to left for me (and probably other combos). I'm doing this under cygwin.

      The problem seems to be because it doesn't work with an object that was already shown. I tried to hide it at first, like you, and it worked well for showing, and it also worked for other directions. But if I add a button to hide it, it still suffers from the problem that I mentioned.

      Here is the code for hiding button:

      $mainWindow->AddButton( -name => 'b2', -text => 'label 1 hide', -pos => [150, 0], -onClick => sub { $mainWindow->label1->Animate( -show => 0, -time => 600, -direction => 'lr', -animation => 'roll', ); }, );

      What should I do?

        I'm not following exactly what you mean, but here is the code I'm currently using. Your original code worked also, but the toggle seemed weird.
        $mainWindow->AddButton ( -name => 'b1', -text => 'label 1', -pos => [100, 0], -onClick => sub { $mainWindow->label1->Hide; $mainWindow->label1->Animate ( -show => 1, # !$mainWindow->label1->IsVisible(), -activate => 1, -time => 600, -direction => 'brtl', -animation => 'roll', ); }, );
        So that you can compare, I'm using the latest perl and modules available from cygwin on windows 11. Perl 5.36.3, Win32::GUI v1.14.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11160992]
Approved by marto
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-09-10 21:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (9 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.