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

Hi,

I'm sort of learning Perl as I go, so if this sounds like a basic question, it probably is.
Right now, I'm using Tk and Tk::Photo to display some images (I'm working in WinXP). Everything is working fine, however; I'd like to display these images WITHOUT the title bar and close/maximize/minimize buttons.
Is this possible? If so, what package should I use?
Also, during my script, I'd like to change the image inside this 'frameless' window without seeing a flicker or seeing the old image turn off followed by the new one turning on a fraction of a second later. I've read that GTk has a feature called 'freeze' and 'thaw' that does this. Do most imaging packages have something like this?

Thanks for your help.

Butch

Replies are listed 'Best First'.
(bbfu) Re: A question about displaying images
by bbfu (Curate) on Jan 04, 2003 at 03:10 UTC

    To show a window without the title-bar in Perl/Tk, you would use the $toplevel->overrideredirect(1) method. (Update: FYI, overrideredirect is documented under Tk::Wm.) Note that if you do so, the user can't move the window around any more, as they can't drag the title-bar. So you should be careful about window positioning, or give them some other way to move the window (such as dragging anywhere on the image, or providing a "drag area").

    Generally, if you just tell Tk to use the new image, it will update the screen appropriately, and without flicker. (At least, it doesn't have any flicker for me. Let me know if you get any.)

    The following code should do what you want.

    #!/win2k/Perl/bin/perl use warnings; use strict; use Tk; our $CurrentImage = -1; our @Images = qw( D:/Wallpapers/tmp/wide.gif D:/Wallpapers/tmp/deepsea.gif D:/Wallpapers/tmp/flea.gif D:/Wallpapers/tmp/forest.gif ); our $MainWin = Tk::MainWindow->new(); our $ImgLabel = $MainWin->Label()->pack; $MainWin->overrideredirect(1); # Remove border and title bar from win +dow $MainWin->bind('<KeyPress-Escape>', [$MainWin, 'destroy']); $MainWin->bind('<KeyPress-minus>', \&prev_image); $MainWin->bind('<KeyPress-plus>', \&next_image); load_images(); next_image(); center($MainWin); MainLoop; sub next_image { $CurrentImage = ++$CurrentImage % @Images; $ImgLabel->configure(-image => $Images[$CurrentImage]); } sub prev_image { $CurrentImage = $#Images if(--$CurrentImage < 0); $ImgLabel->configure(-image => $Images[$CurrentImage]); } sub load_images { for my $image (@Images) { # Replace image filename w/ loaded image $image = $MainWin->Photo( -file => $image, -format => 'gif', ); } } sub center { my $win = shift; $win->withdraw; # Hide the window while we move it about $win->update; # Make sure width and height are current # Center window $win->geometry( '+' . int( ($win->screenwidth - $win->width) / 2 ) . '+' . int( ($win->screenheight - $win->height) / 2 ) ); $win->deiconify; # Show the window again }

    bbfu
    Black flowers blossum
    Fearless on my breath

      Thanks, I think this technique will work perfectly for what I'm working on.

      Thanks again,

      Butch