Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Our reruns are better than theirs." -- Nick at Nite


devel / comp.lang.tcl / Re: Tk app screenshot is all black

SubjectAuthor
* Tk app screenshot is all blackLuc
`* Tk app screenshot is all blackHelmut Giese
 +* Tk app screenshot is all blackLuc
 |`- Tk app screenshot is all blackAndreas Leitgeb
 `* Tk app screenshot is all blackRobert Heller
  `* Tk app screenshot is all blackLuc
   `* Tk app screenshot is all blackRich
    `- Tk app screenshot is all blacksaitology9

1
Tk app screenshot is all black

<20221221101703.7b3ed2a0@lud1.home>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10412&group=comp.lang.tcl#10412

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!HESYh6hlKWfwzlzvFPLFyA.user.46.165.242.75.POSTED!not-for-mail
From: no...@no.no (Luc)
Newsgroups: comp.lang.tcl
Subject: Tk app screenshot is all black
Date: Wed, 21 Dec 2022 10:17:03 -0300
Organization: Aioe.org NNTP Server
Message-ID: <20221221101703.7b3ed2a0@lud1.home>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="34539"; posting-host="HESYh6hlKWfwzlzvFPLFyA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
X-Newsreader: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu)
 by: Luc - Wed, 21 Dec 2022 13:17 UTC

I want to screenshot a Tk app. I mean, I want the app to screenshoot itself.
To take a selfie.

I found code in the wiki that works very well. Except that it only works
if the application's window has focus. If I Alt+Tab away from it while it's
running, the resulting screenshot is just a pitch black screen.

My best guess is nothing can be done because the window manager "unmaps"
the window when I Alt+Tab away from it.

Please tell me that I'm wrong and there is some ninja trick to overcome
this limitation.

Please?

The stolen code:

proc CaptureWindow {win {baseImg ""} {px 0} {py 0}} {
package require Img
# create the base image of win (the root of capturing process)
if {$baseImg eq ""} {
set baseImg [image create photo -format window -data $win]
}
# paste images of win's children on the base image
foreach child [winfo children $win] {
if {![winfo ismapped $child]} continue
set childImg [image create photo -format window -data $child]
regexp {\+(\d*)\+(\d*)} [winfo geometry $child] -> x y
$baseImg copy $childImg -to [incr x $px] [incr y $py]
image delete $childImg
CaptureWindow $child $baseImg $x $y
}
return $baseImg
}

--
Luc
>>

Re: Tk app screenshot is all black

<9s36qhhltlk9eirgo0u44ae9asjbahi1km@4ax.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10413&group=comp.lang.tcl#10413

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: hgi...@ratiosoft.com (Helmut Giese)
Newsgroups: comp.lang.tcl
Subject: Re: Tk app screenshot is all black
Date: Wed, 21 Dec 2022 14:55:20 +0100
Organization: ratiosoft
Lines: 7
Message-ID: <9s36qhhltlk9eirgo0u44ae9asjbahi1km@4ax.com>
References: <20221221101703.7b3ed2a0@lud1.home>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Injection-Info: reader01.eternal-september.org; posting-host="fd717b15cda283c317bce4d94112e368";
logging-data="1106503"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX197PGz0zHUWGJCMW1BLM6FL"
Cancel-Lock: sha1:AN7OqXCt4EWF0hyppneD+KU2UJA=
X-Newsreader: Forte Free Agent 1.93/32.576 English (American)
 by: Helmut Giese - Wed, 21 Dec 2022 13:55 UTC

Hi Luc,

>I want to screenshot a Tk app.
you are aware that you can take a screen shot of _any_ window by means
of the 'Alt + Print' key combo?
HTH
Helmut

Re: Tk app screenshot is all black

<20221221121838.5f7f050d@lud1.home>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10415&group=comp.lang.tcl#10415

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!HESYh6hlKWfwzlzvFPLFyA.user.46.165.242.75.POSTED!not-for-mail
From: no...@no.no (Luc)
Newsgroups: comp.lang.tcl
Subject: Re: Tk app screenshot is all black
Date: Wed, 21 Dec 2022 12:18:38 -0300
Organization: Aioe.org NNTP Server
Message-ID: <20221221121838.5f7f050d@lud1.home>
References: <20221221101703.7b3ed2a0@lud1.home>
<9s36qhhltlk9eirgo0u44ae9asjbahi1km@4ax.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="33632"; posting-host="HESYh6hlKWfwzlzvFPLFyA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Newsreader: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu)
X-Notice: Filtered by postfilter v. 0.9.2
 by: Luc - Wed, 21 Dec 2022 15:18 UTC

On Wed, 21 Dec 2022 14:55:20 +0100, Helmut Giese wrote:

> Hi Luc,
>
> >I want to screenshot a Tk app.
> you are aware that you can take a screen shot of _any_ window by means
> of the 'Alt + Print' key combo?

Not good. I want the app to do it automatically at a certain point of
its routine.

And I want it to be able to do it even when the parent window doesn't have
focus in the window manager.

--
Luc
>>

Re: Tk app screenshot is all black

<CqacnXuucqRWpT7-nZ2dnZfqn_SdnZ2d@giganews.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10418&group=comp.lang.tcl#10418

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Wed, 21 Dec 2022 16:48:11 +0000
MIME-Version: 1.0
From: hel...@deepsoft.com (Robert Heller)
Organization: Deepwoods Software
X-Newsreader: TkNews 3.0 (1.2.15)
Subject: Re: Tk app screenshot is all black
In-Reply-To: <9s36qhhltlk9eirgo0u44ae9asjbahi1km@4ax.com>
References: <20221221101703.7b3ed2a0@lud1.home>
<9s36qhhltlk9eirgo0u44ae9asjbahi1km@4ax.com>
Newsgroups: comp.lang.tcl
Content-Type: text/plain;
charset="us-ascii"
Originator: heller@sharky4.deepsoft.com
Message-ID: <CqacnXuucqRWpT7-nZ2dnZfqn_SdnZ2d@giganews.com>
Date: Wed, 21 Dec 2022 16:48:11 +0000
Lines: 22
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-5RaN2lqZH9TYblC8ZJ7m+UHct+UH3n0rsUzOyHOzAG4qHiXU/Cyubrnu1oMW7cp3ET5aE9U6l3FsLmR!E+yRWG7D7gWFyUmiz04kj0SlxheoWbXQLP7fzAiTHf0TwRRgeL3wzEOCQ+8aqbU6xH+hsoI8V80b!0Jc=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: Robert Heller - Wed, 21 Dec 2022 16:48 UTC

At Wed, 21 Dec 2022 14:55:20 +0100 Helmut Giese <hgiese@ratiosoft.com> wrote:

>
> Hi Luc,
>
> >I want to screenshot a Tk app.
> you are aware that you can take a screen shot of _any_ window by means
> of the 'Alt + Print' key combo?

That is dependent on the O/S and/or desktop system.

> HTH
> Helmut
>
>

--
Robert Heller -- Cell: 413-658-7953 GV: 978-633-5364
Deepwoods Software -- Custom Software Services
http://www.deepsoft.com/ -- Linux Administration Services
heller@deepsoft.com -- Webhosting Services

Re: Tk app screenshot is all black

<20221221135424.7146f929@lud1.home>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10419&group=comp.lang.tcl#10419

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!HESYh6hlKWfwzlzvFPLFyA.user.46.165.242.75.POSTED!not-for-mail
From: no...@no.no (Luc)
Newsgroups: comp.lang.tcl
Subject: Re: Tk app screenshot is all black
Date: Wed, 21 Dec 2022 13:54:23 -0300
Organization: Aioe.org NNTP Server
Message-ID: <20221221135424.7146f929@lud1.home>
References: <20221221101703.7b3ed2a0@lud1.home>
<9s36qhhltlk9eirgo0u44ae9asjbahi1km@4ax.com>
<CqacnXuucqRWpT7-nZ2dnZfqn_SdnZ2d@giganews.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="2385"; posting-host="HESYh6hlKWfwzlzvFPLFyA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
X-Newsreader: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu)
 by: Luc - Wed, 21 Dec 2022 16:54 UTC

On Wed, 21 Dec 2022 16:48:11 +0000, Robert Heller wrote:

> At Wed, 21 Dec 2022 14:55:20 +0100 Helmut Giese wrote:
>
> >
> > Hi Luc,
> >
> > >I want to screenshot a Tk app.
> > you are aware that you can take a screen shot of _any_ window by means
> > of the 'Alt + Print' key combo?
>
> That is dependent on the O/S and/or desktop system.

Hi, Helmut.

It's Linux and Openbox.

--
Luc
>>

Re: Tk app screenshot is all black

<tnvge1$132ml$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10422&group=comp.lang.tcl#10422

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: ric...@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: Tk app screenshot is all black
Date: Wed, 21 Dec 2022 17:40:17 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <tnvge1$132ml$2@dont-email.me>
References: <20221221101703.7b3ed2a0@lud1.home> <9s36qhhltlk9eirgo0u44ae9asjbahi1km@4ax.com> <CqacnXuucqRWpT7-nZ2dnZfqn_SdnZ2d@giganews.com> <20221221135424.7146f929@lud1.home>
Injection-Date: Wed, 21 Dec 2022 17:40:17 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="3f4718d035ce4159c17b6ad5c54e3c17";
logging-data="1149653"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18UDcf0uIdeaU72tYo1SDKE"
User-Agent: tin/2.0.1-20111224 ("Achenvoir") (UNIX) (Linux/3.10.17 (x86_64))
Cancel-Lock: sha1:2TUM29rUncq9BzoOo4uwgn1/PxE=
 by: Rich - Wed, 21 Dec 2022 17:40 UTC

Luc <no@no.no> wrote:
> On Wed, 21 Dec 2022 16:48:11 +0000, Robert Heller wrote:
>
>> At Wed, 21 Dec 2022 14:55:20 +0100 Helmut Giese wrote:
>>
>> >
>> > Hi Luc,
>> >
>> > >I want to screenshot a Tk app.
>> > you are aware that you can take a screen shot of _any_ window by means
>> > of the 'Alt + Print' key combo?
>>
>> That is dependent on the O/S and/or desktop system.
>
>
> Hi, Helmut.
>
> It's Linux and Openbox.

This is still very likely dependent upon how the Img package is
obtaining the bitmap that is the window contents. And how successful
Img is at that is itself also dependent upon window manager and/or
desktop environment.

Here, under X11 and Fvwm2, doing a 'snapshot' of a partially obscured
Tk window using Img returns the visible parts as visible and the
obscured parts as pure black. Which also means that if the window were
fully obscured, the return would be all pure black.

Re: Tk app screenshot is all black

<tnviuc$sum$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10425&group=comp.lang.tcl#10425

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!aioe.org!Uw/OCQynP0ivtNQPQQJATg.user.46.165.242.75.POSTED!not-for-mail
From: saitolo...@gmail.com (saitology9)
Newsgroups: comp.lang.tcl
Subject: Re: Tk app screenshot is all black
Date: Wed, 21 Dec 2022 13:23:07 -0500
Organization: Aioe.org NNTP Server
Message-ID: <tnviuc$sum$1@gioia.aioe.org>
References: <20221221101703.7b3ed2a0@lud1.home>
<9s36qhhltlk9eirgo0u44ae9asjbahi1km@4ax.com>
<CqacnXuucqRWpT7-nZ2dnZfqn_SdnZ2d@giganews.com>
<20221221135424.7146f929@lud1.home> <tnvge1$132ml$2@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="29654"; posting-host="Uw/OCQynP0ivtNQPQQJATg.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.3.2
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: saitology9 - Wed, 21 Dec 2022 18:23 UTC

On 12/21/2022 12:40 PM, Rich wrote:
> Luc <no@no.no> wrote:
>> On Wed, 21 Dec 2022 16:48:11 +0000, Robert Heller wrote:
>
> Here, under X11 and Fvwm2, doing a 'snapshot' of a partially obscured
> Tk window using Img returns the visible parts as visible and the
> obscured parts as pure black. Which also means that if the window were
> fully obscured, the return would be all pure black.
>
>

On Windows, the obscured part is not black but it captures the other
window that is doing the obscuring. Looks weird.

In any case, I am not sure if it was a post here or on the wiki but I
recall seeing code that did something similar, except that it did
differently, iirc pixel by pixel. It may have been part of the alited
editor, if I am spelling it correctly. I would look into that as an
alternative.

Re: Tk app screenshot is all black

<slrntq9qcm.21q.avl@logic.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=10447&group=comp.lang.tcl#10447

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: avl...@logic.at (Andreas Leitgeb)
Newsgroups: comp.lang.tcl
Subject: Re: Tk app screenshot is all black
Date: Thu, 22 Dec 2022 23:34:46 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <slrntq9qcm.21q.avl@logic.at>
References: <20221221101703.7b3ed2a0@lud1.home>
<9s36qhhltlk9eirgo0u44ae9asjbahi1km@4ax.com>
<20221221121838.5f7f050d@lud1.home>
Reply-To: avl@logic.at
Injection-Date: Thu, 22 Dec 2022 23:34:46 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="cae48fbb1e7e7280e42dd808750bb88a";
logging-data="1573350"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+x+VcKjHTrAnVTxKZSmD4q"
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:3KzdQg6o9fGudOoGU71hUJbeRoU=
 by: Andreas Leitgeb - Thu, 22 Dec 2022 23:34 UTC

Luc <no@no.no> wrote:
>>> I want to screenshot a Tk app.
>>> Please tell me that I'm wrong and there is some ninja trick to overcome
>>> this limitation.
> I want the app to do it automatically at a certain point of
> its routine.
> And I want it to be able to do it even when the parent window doesn't have
> focus in the window manager.

Talking about "ninja tricks"... does it need to run on the active
desktop?

I'm talking of either multiple Desktop-sessions (essentially multiple
X or wayland servers running in parallel on different ttys.

If you still need to have it available right there on the main desktop,
you could start a nested X-session Xnest (in Package "xnest" on debian-
systems, likely similar on other distributions) and start a WM and your
application inside it.

Chances are, that while your Xnest-root-window is obscured, minimized,
and/or out of focus, the front applications running inside will still
assume to have your full attention.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor