Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Ship it.


devel / comp.lang.python / Re: Tkinter and cv2: "not responding" popup when imshow launched from tk app

SubjectAuthor
o Re: Tkinter and cv2: "not responding" popup when imshow launched fromWeatherby,Gerard

1
Re: Tkinter and cv2: "not responding" popup when imshow launched from tk app

<mailman.2307.1678801937.20444.python-list@python.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: gweathe...@uchc.edu (Weatherby,Gerard)
Newsgroups: comp.lang.python
Subject: Re: Tkinter and cv2: "not responding" popup when imshow launched from
tk app
Date: Tue, 14 Mar 2023 13:52:04 +0000
Lines: 84
Message-ID: <mailman.2307.1678801937.20444.python-list@python.org>
References: <fbb73dcc4a7bc45c57ce959e09cde2986aacb0b6.camel@johnohagan.com>
<SJ0PR14MB5864AB888CBD9078A3910F4FB9BE9@SJ0PR14MB5864.namprd14.prod.outlook.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de MkRhPmCra2cbrbudLua3JAk35qAH4iJaI9sM2ZT/Xx4Q==
Return-Path: <prvs=04370e2531=gweatherby@uchc.edu>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=uchc.edu header.i=@uchc.edu header.b=ObggJxcL;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.004
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'url-ip:140.82/16': 0.03;
'(which': 0.04; 'def': 0.04; '(e.g.': 0.05; 'error:': 0.05;
'2023': 0.07; 'arrays': 0.07; 'subject:when': 0.07; 'tkinter':
0.07; 'knowledge.': 0.09; 'line:': 0.09; 'numpy': 0.09;
'received:namprd14.prod.outlook.com': 0.09; 'subject:not': 0.09;
'threads': 0.09; 'url:github': 0.14; 'import': 0.15;
'url:mailman': 0.15; 'url-ip:140/8': 0.15; '"not': 0.16; '***':
0.16; 'assuming': 0.16; 'closes': 0.16; 'demonstrates': 0.16;
'displayed': 0.16; 'displays': 0.16; 'paths': 0.16; 'slow': 0.16;
'stuck': 0.16; 'subject:: "': 0.16; 'subject:app': 0.16;
'url:urldefense': 0.16; 'url:v3': 0.16; 'zooming': 0.16;
'problem': 0.16; 'python': 0.16; 'to:addr:python-list': 0.20;
'option': 0.20; "i've": 0.22; 'code': 0.23; 'saying': 0.25;
'url:listinfo': 0.25; 'available,': 0.26; 'opening': 0.26;
'received:edu': 0.26; 'suspect': 0.26; 'email
addr:python.org&gt;': 0.28; 'suggestions': 0.28; 'think': 0.32;
'elements': 0.32; 'launched': 0.32; 'python-list': 0.32; 'window':
0.32; 'but': 0.32; "i'm": 0.33; 'particular': 0.33; 'march': 0.33;
'header:In-Reply-To:1': 0.34; 'trying': 0.35; 'understood': 0.35;
'close': 0.35; 'display': 0.36; 'header:Received:8': 0.36;
'received:filterd': 0.37; 'received:pps.filterd': 0.37;
'subject:from': 0.37; 'using': 0.37; "it's": 0.37; 'url-
ip:13.107/16': 0.38; 'thanks': 0.38; 'changes': 0.39; 'necessary':
0.39; 'date:': 0.39; 'list': 0.39; 'use': 0.39; 'methods': 0.39;
'still': 0.40; 'appears': 0.40; 'seconds': 0.40; 'both': 0.40;
'something': 0.40; 'event': 0.40; 'charset:windows-1252': 0.60;
'email.': 0.61; 'skip:o 10': 0.61; 'from:': 0.62; 'to:': 0.62;
'here': 0.62; 'subject': 0.63; 'between': 0.63; 'button': 0.64;
'skip:r 40': 0.64; 'similar': 0.65; 'back': 0.67; 'url-
ip:104.18/16': 0.67; 'forcing': 0.69; 'url-ip:52.6/16': 0.69;
'within': 0.69; 'waiting': 0.73; 'features': 0.75; 'clicking':
0.76; 'des': 0.78; 'links.': 0.81; 'click': 0.83; 'happens': 0.84;
'attention:': 0.84; 'billion': 0.84; 'cycle': 0.84; 'email
name:&lt;python-list': 0.84; 'skip:& 50': 0.84; 'subject: \n ':
0.84; 'you\x92re': 0.84; 'skip:q 30': 0.91; 'clicks': 0.93;
'skip:q 20': 0.95
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uchc.edu;
h=from : to : subject :
date : message-id : references : in-reply-to : content-type :
mime-version; s=UCHC03162020;
bh=k9XN16Mp7QPrN7iTWjRZp+Ck1qjUAmtkqicg2SKiR2s=;
b=ObggJxcLMkq4ONGIcKl3kR8/BiiHhhVSber5Ila0081X/KOtWbBGQs7pktv4hu+zH6a7
lNitDkPVpBrQKQ/ShH2NgPHJi6hc1sjEeGxq0CEKvLA9HT0mHGRfCax9txm8Ag88SKNt
AcpvmPz149dEyH53fF7iEPGh5HctDjMdG0KZ+4ZSkziiLFLzm2ZuuUMPSYQRhvIQ0lN/
GV8/HlYv0eltdDcVBmTTMaQTWYv7e07ECTngTr/QXAuo+SmCrWu/QCxodiqEAZMlJSzC
yRl/b/chNOoBu79lJzBfOVTqU5prKPfb4tmuUw70hGlVa2NEnTzf49YKhEeJf3PfTU5E ow==
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
b=BZKPIvO4px4SgqWAYYAra2dEz/EA+VBZ9d/KVehYC9jWl3hgURHSC4Z2I7KT8UM7bkfqK7MKgkklsg4M/flAb+nJ+K5ytOiPhWzOgpyOraVM2+ll8Fojz8gN7HSryO6xI8vj3ZSAM0NMgfZ0JF+gVX+UR4ZfN18FyEsk/ZkQPfOt6KuKNiJqq4Rsk1AQEBrrNfjjrHLtQtnsXCase/VRtXJGoLKjZyeT08wblhrx79keCPiG0I6saG1JePe+EQ3MoOix8NqN7olBQW29fGKaic+MwLJ1OxJUnMd8CJIXoXUbEUxBJXceNOFkXgGahS5D248HmjtwvqgNYDnXVQtNpw==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
s=arcselector9901;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
bh=k9XN16Mp7QPrN7iTWjRZp+Ck1qjUAmtkqicg2SKiR2s=;
b=UNrvMm7S8Df8B62XKPlFZpJykqvXQBpa2ySGEL1hxYY6/ndlEQdJe/I3/EEgI5sXO9ZvrEa4D2wFUJGQRvweEED4aEThzmPxTFh2a7Sl5rSEYbp6c7vEJO+4QUVK3E3gv5WJRV4pClHUQEb+eVt1ZWGL08o16mAJAMK3pK30M1TkgJwaJowhWoZTJy8k16iYw7/mAW47RvqCcrIGLV0WS/qQRjWJytBCaT9y9w8fMCUzer4UsLI9cPe5PcufLqU47UWEIws+NHnQ2OC1UqJPw1FnrwmCuTfRsGRRXJdH1sj1BWqk9cLsUwJUGO7nRsyb8YubN0Dp69IKlSsv5gtL2w==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
smtp.mailfrom=uchc.edu; dmarc=pass action=none header.from=uchc.edu;
dkim=pass header.d=uchc.edu; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uchc.onmicrosoft.com;
s=selector2-uchc-onmicrosoft-com;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
bh=k9XN16Mp7QPrN7iTWjRZp+Ck1qjUAmtkqicg2SKiR2s=;
b=dxv5UJFRcjgSjSScVW7koiYBCSnmZW0dVr+HJ+Wn7xnYTFSEwytT1kL51QgT8YS58WyFSMPI6D+SIYsBQtYKVMRir27dlpHAFuZDkGkWtvIcqiLHTIGznecjYcp+tzJ73uCS2g4yv0h8BE+EjhvYrGNGFixwifCaMj6Dok4xj8o=
Thread-Topic: Tkinter and cv2: "not responding" popup when imshow launched
from tk app
Thread-Index: AQHZVmOkGoPvhalUp0+iGrA6/Pfjya76S07u
In-Reply-To: <fbb73dcc4a7bc45c57ce959e09cde2986aacb0b6.camel@johnohagan.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: SJ0PR14MB5864:EE_|DS0PR14MB6951:EE_
x-ms-office365-filtering-correlation-id: 0926afad-dda9-41f1-ab5d-08db24934b62
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: pDjSgb3E64EHUnNjLfgrUSpKs8TKgNLAVJ7F8s2dROOifLGF4j2498zPiqYq0J0hqcxdRfIjxHxYqKGW3wAGUxril42I6iHhEFcVT4RzrDagisqtN+Ht3hODQNKfZJsHrSPP6dqCgJKXlh5yyjjkEEEUxo+k39Qm0gjXfib8u7v/vJ+qqiWxfq5Dpu4rDCX6wwdLyUnShj+9AuSsSAZghr6dDY0HmWeFPB0csHIqSFnHQakNi3NTEskqFR5xtLF5bdgTTxuZcqQ+vG2/+GkvtmeIo34ceTYh+lDpvLhVUE/RSbztPTzIcvX0mbEeVL56XZ1+kFs8PAq6RDvuzbmvO+VEVoBHOTUeIrKaBDBZgeIcKNAsmQW0vNuWPIkdhqVnxQ77bTXG6Ji6pgQOJibEicT0puy/wQijzDS/5jvGGrlt6gI4MFWYtwX89psC4q79aknpMXowdzjGAUJXg19efAEDekVX9KsgIFkHlH1UxBPj/0i/AEWC6yQaKRxemZTOCzRPqqjQQPfbmVEoysqc2tiuxn1g0a060b4bHf1Lpz2bMa5FC9WLvDzbKEeHEE7UMAUKyz1+sTKU4xpDiSj5ezBp006RSGnlXWILDQWTpgOuR6MrWQHQS4D95dI/xlIfoBKhsGOH/EkDJaM5GGVRb6Sa6T5NUChj7SIoR3cQa6LRGXyl9nDTB0VeNeSQP98w
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;
IPV:NLI; SFV:NSPM; H:SJ0PR14MB5864.namprd14.prod.outlook.com; PTR:; CAT:NONE;
SFS:(13230025)(346002)(376002)(39860400002)(366004)(396003)(136003)(451199018)(71200400001)(33656002)(26005)(75432002)(6506007)(7696005)(966005)(9686003)(66476007)(66556008)(66946007)(76116006)(66446008)(122000001)(478600001)(64756008)(6916009)(8676002)(55016003)(5660300002)(83380400001)(91956017)(86362001)(38100700002)(2906002)(316002)(186003)(53546011)(786003)(166002)(41300700001)(52536014)(8936002)(38070700005)(41320700001);
DIR:OUT; SFP:1101;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0: itab2dkm/tzNq0Lpik07SeI0D73ltN1LJiF4nfBT6mobkBmmJgZk6Jve
elSs49mCY/pzYIjYSEsr0RLuhCNKUdhSXzQKTPpDefObD4KC//2XlzsO
6LU3o8C5MyL7TJ3l46pXOwybQrZJ8eCXsunf3xX9rD/SpQ42FllsErTT
iU4yCCazoXOV60jIZByWKb8riKIUttTIW6O6hKv+CuVa5Sc9FtyX6Fvo
DKPuqAm0go7GVK4FORhVTKByW/VTKfoWsK5wRdONiZukHxmY0yNH6+RW
d9XULM2506okj0lEpVsFC6ESeKzb8VBUcGbCFY8CNKleVCBqKbHPlGia
kFMWDZ88tAiMvAJd7ur9ku8+tmSs7HYoc9kd5LYvnkoDdbMW70+KHgTK
APn63jaKOV/lHvBuobvt39xRaR9PelPFi0I8gCY3gvRnoxijYhcOjHbB
GWZEbQTlKFF40kFu4pKilXpacfuJasSE9TZrh0izDHNNPWTxFjRajBvd
kDlYoUE1GFJz1wqB9RYmcTc/0kKstgk6E0xXq9k+xA18Z3FRe0WzBN+w
UPEKXSLHQU0o1WEOhFn6bDJnjGmrc6lIsbRcPhwWz0ho1IsZs1gdSyoz
uVPBhbr7qz0s7p+88Oy+FtcPeqesyOJSz9VB9UzS9D0++S8Eto36C8Rc
dmyLsVK8D2IOcB2rLQ+T1VSukYAG3vX8bQ+DQoS6OXShW9P0O1M2skYG
sicG3LdCL8xfs7kvw8Q7jPqS+1IOBYVeeK+G+WWcoOPgornWfSZesR2W
KX90u1avuxHG8UXHzc3NZUtFrPyxllcsq93HidzxmtFyFjlz429RpOM/
RJFx2Eiw1USXr00e50oY2crydGXqWGGdgI5SRXqb6UV+9uWERoVgFZad
tc9WzL5VBtmf1Vtm/7FW/GpGIFcXcTrHd4p6lktH+I7gaL5PRydwhkqc
iM62eLoOIp0THI3Ukc5KDyIl7J1GVMLMavFAh7Wy3FqpC73h8J+kTgMj
ssOTMfzkaBPaMimSCE945GNm5yzVvofqjbqgonQvRrVz96483z7trGIJ
MIMaknWzXUPZEUZAINKjgMeYBImqEaXAjNqce1nwl7Dzz7wLw/f/InPz
ZmscmzKst1Fh8Oaj1izBEUnv6GRY7c8NFMGRazskgA1eRpvjqPSKoNZO
xp+S414bOcVTPE+yjz9bAZJ8rIxq1Olw6UzAvilm1H9MnCmItlpYkfSF
LVV1l63Pijg1KqgxgUNtT24UBZyiMYh5ADX7V3xuTGbtm0uZPYvkatnv
saJkU3audaaVaxmcRKw2A3YzyiVmZxWJx6lTLq+V0hNxYPUyv8btSmV+
LkwMmSm2tvgp538UpxzY9Cz9eHNQOOhvxZvINKMSJXNJhXlvgsdwNGeB
A2pHgGKd6UGlKAOZ1BsMblb5GYgFlCo3UyvNTiZQXt4wqxV1hstqcgrU
lDI+cgewJn0stHf+TTqK5R9oNEN5/Ip1+ZjdVKJkofRwZE0Onvy7sn0N
EUumlrCA4Nv1UYQrNKrD8jOeNYCyPkBozgUyZ2NqZWQvA991p+3PTTiL
6MJjHQDVNX0qZzZneY7sR0DZaPnQ3owPJ0uZYxvTpP1FMHEhHVv72g
==
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: SJ0PR14MB5864.namprd14.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 0926afad-dda9-41f1-ab5d-08db24934b62
X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Mar 2023 13:52:04.5982 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 5c82d83a-818a-4c16-b540-ded2344a7ad3
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: kytpZ93wSVbwfVGSlmQxMmhU5EvP0udQSGOpIzc8CpuiExC2E5kQfV4j+KdBd5qw0nA7/OadFDieWQOFijf75A==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR14MB6951
X-Proofpoint-GUID: 5E6ZPmhpFNMTIgu-VP4dY15wuEBUrTur
X-Proofpoint-ORIG-GUID: 5E6ZPmhpFNMTIgu-VP4dY15wuEBUrTur
X-Proofpoint-Virus-Version: vendor=baseguard
engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22
definitions=2023-03-14_07,2023-03-14_02,2023-02-09_01
X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0
phishscore=0 mlxlogscore=999
spamscore=0 lowpriorityscore=0 clxscore=1015 suspectscore=0 adultscore=0
mlxscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 bulkscore=0
classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000
definitions=main-2303140118
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <SJ0PR14MB5864AB888CBD9078A3910F4FB9BE9@SJ0PR14MB5864.namprd14.prod.outlook.com>
X-Mailman-Original-References: <fbb73dcc4a7bc45c57ce959e09cde2986aacb0b6.camel@johnohagan.com>
 by: Weatherby,Gerard - Tue, 14 Mar 2023 13:52 UTC

Assuming you’re using opencv-python, I’d post query at https://github.com/opencv/opencv-python/issues.

From: Python-list <python-list-bounces+gweatherby=uchc.edu@python.org> on behalf of John O'Hagan <research@johnohagan.com>
Date: Tuesday, March 14, 2023 at 6:56 AM
To: Python list <python-list@python.org>
Subject: Tkinter and cv2: "not responding" popup when imshow launched from tk app
*** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. ***

Hi list

I'm trying to use cv2 to display images created as numpy arrays, from
within a tkinter app (which does other things with the arrays before
they are displayed as images). The arrays are colour-coded
visualisations of genomes and can be over a billion elements in size,
and I've found the PIL methods to display images in tkinter are too
slow and memory-heavy.

Here is minimal code that demonstrates the problem in the subject line:

import cv2
from tkinter import *

images=['a.jpg', 'b.jpg', 'c.jpg'] #change to image paths

cv2.namedWindow('W', cv2.WND_PROP_FULLSCREEN)
cv2.setWindowProperty('W', cv2.WND_PROP_FULLSCREEN,
cv2.WINDOW_FULLSCREEN)
counter=[0]
def show():
cv2.imshow('W', cv2.imread(images[counter[0] % len(images)]))
cv2.waitKey(1)
counter[0] += 1

root=Tk()
root.wm_attributes("-topmost", 1)
Button(root, text=' Show ', command=show).pack()
mainloop()

It works up to a point - I can cycle through the images by clicking the
button - but if I mouse-click on the displayed image (e.g. to use the
zooming and panning features of cv2), nothing happens, and a few
seconds later the image greys out and a popup appears saying "'Unknown'
is not responding" and giving the option of waiting or forcing close
(but sometimes these options are greyed out too). Clicking "wait", if
available, closes the popup but it comes back a few seconds later. If I
then click on the tkinter window titlebar, the popup changes to "'Tk'
is not responding". Clicking on the button still works and after a few
clicks the popup closes.

This happens under both x11 and wayland, but under wayland, I also get
this error:

"QSocketNotifier: Can only be used with threads started with QThread
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()"

and only every second button press displays a new image ,with only
every second image displayed.

I think this particular popup is a Gnome thing, but AIUI most DEs have
something similar to detect stuck apps. But the app is not stuck.

I suspect this is some kind of interaction between the call to
cv2.waitKey (which is necessary but I've never understood why!) and the
tkinter event loop, but it's beyond my knowledge.

Any suggestions about causes or workarounds?

Thanks

--

John

--
https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!iHFg1AtgcwsfEeHXaH_Nasebf9SGreVlDs-DevEIQbFiwUQThx-_rah1QkSHRJEotJFyd-d6OCQ3GuQa1MxvsnGA$<https://urldefense.com/v3/__https:/mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!iHFg1AtgcwsfEeHXaH_Nasebf9SGreVlDs-DevEIQbFiwUQThx-_rah1QkSHRJEotJFyd-d6OCQ3GuQa1MxvsnGA$>

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor