burtmacklin16
burtmacklin16

Reputation: 755

Take a screnshot of a Window in TCL

I have an application written in TCL. I want to be able to run a script that captures a screenshot of a window as a PNG, BMP, etc.

I've looked at this wiki page (http://wiki.tcl.tk/9127), but I think I read that the Img package only works for tcl 8.4.

I've also tried image create photo -format window -data %W, but I get an error saying "image format 'window' is not supported".

Is there a solution to capture and save a TCL window for tcl8.6?

Upvotes: 1

Views: 994

Answers (1)

Donal Fellows
Donal Fellows

Reputation: 137717

This ought to be what's required to make that code work:

package require img::window

It's a sub-package of Img and should most certainly be supported on 8.6. (Mind you, you might have problems on OSX; the ActiveState build of Img on that platform appears to be broken.)

In general, if a package is supported in Tcl/Tk 8.X then it's supported in 8.Y too (were YX). There are a few exceptions to that rule (the main ones to note are probably TclOO, [incr Tcl] and BLT, because they poke their fingers into Tcl very deeply) but they're just that: exceptions.

Upvotes: 2

Related Questions