[{"id":30760,"web_url":"https://patchwork.libcamera.org/comment/30760/","msgid":"<20240812161052.GA32749@pendragon.ideasonboard.com>","date":"2024-08-12T16:10:52","subject":"Re: [PATCH] py: cam: Convert to PyQt6","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Tomi,\n\nThank you for the patch.\n\nOn Mon, Aug 12, 2024 at 05:50:34PM +0300, Tomi Valkeinen wrote:\n> Perhaps it's time... Convert the py cam tool to PyQt6.\n> \n> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n> ---\n>  src/py/cam/cam_qt.py   |  6 +++---\n>  src/py/cam/cam_qtgl.py | 12 ++++++------\n>  2 files changed, 9 insertions(+), 9 deletions(-)\n> \n> diff --git a/src/py/cam/cam_qt.py b/src/py/cam/cam_qt.py\n> index c1723b44..22d8c4da 100644\n> --- a/src/py/cam/cam_qt.py\n> +++ b/src/py/cam/cam_qt.py\n> @@ -2,7 +2,7 @@\n>  # Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n>  \n>  from helpers import mfb_to_rgb\n> -from PyQt5 import QtCore, QtGui, QtWidgets\n> +from PyQt6 import QtCore, QtGui, QtWidgets\n>  import libcamera as libcam\n>  import libcamera.utils\n>  import sys\n> @@ -63,10 +63,10 @@ class QtRenderer:\n>          self.buf_mmap_map = buf_mmap_map\n>  \n>      def run(self):\n> -        camnotif = QtCore.QSocketNotifier(self.cm.event_fd, QtCore.QSocketNotifier.Read)\n> +        camnotif = QtCore.QSocketNotifier(self.cm.event_fd, QtCore.QSocketNotifier.Type.Read)\n>          camnotif.activated.connect(lambda _: self.readcam())\n>  \n> -        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Read)\n> +        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Type.Read)\n\nPyQt5 also defines the Read type in QtCore.QSocketNotifier.Type, so this\ncode is compatible with both Python versions.\n\n>          keynotif.activated.connect(lambda _: self.readkey())\n>  \n>          print('Capturing...')\n> diff --git a/src/py/cam/cam_qtgl.py b/src/py/cam/cam_qtgl.py\n> index 6cfbd347..35b4b06b 100644\n> --- a/src/py/cam/cam_qtgl.py\n> +++ b/src/py/cam/cam_qtgl.py\n> @@ -1,8 +1,8 @@\n>  # SPDX-License-Identifier: GPL-2.0-or-later\n>  # Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n>  \n> -from PyQt5 import QtCore, QtWidgets\n> -from PyQt5.QtCore import Qt\n> +from PyQt6 import QtCore, QtWidgets\n> +from PyQt6.QtCore import Qt\n>  \n>  import math\n>  import os\n> @@ -142,10 +142,10 @@ class QtRenderer:\n>          self.window = window\n>  \n>      def run(self):\n> -        camnotif = QtCore.QSocketNotifier(self.state.cm.event_fd, QtCore.QSocketNotifier.Read)\n> +        camnotif = QtCore.QSocketNotifier(self.state.cm.event_fd, QtCore.QSocketNotifier.Type.Read)\n>          camnotif.activated.connect(lambda _: self.readcam())\n>  \n> -        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Read)\n> +        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Type.Read)\n>          keynotif.activated.connect(lambda _: self.readkey())\n>  \n>          print('Capturing...')\n> @@ -175,8 +175,8 @@ class MainWindow(QtWidgets.QWidget):\n>      def __init__(self, state):\n>          super().__init__()\n>  \n> -        self.setAttribute(Qt.WA_PaintOnScreen)\n> -        self.setAttribute(Qt.WA_NativeWindow)\n> +        self.setAttribute(Qt.WidgetAttribute.WA_PaintOnScreen)\n> +        self.setAttribute(Qt.WidgetAttribute.WA_NativeWindow)\n\nThis works with PyQt5 too.\n\nShould we try to keep Qt5 compatibility with\n\ntry:\n    from PyQt6 import QtCore, QtWidgets\n    from PyQt6.QtCore import Qt\nexcept:\n    from PyQt5 import QtCore, QtWidgets\n    from PyQt5.QtCore import Qt\n\n?\n\n>  \n>          self.state = state\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id C81E7BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 12 Aug 2024 16:11:18 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E81EC63398;\n\tMon, 12 Aug 2024 18:11:17 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0417863369\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 12 Aug 2024 18:11:15 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 41FFC836;\n\tMon, 12 Aug 2024 18:10:19 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"UhxBsmS/\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1723479019;\n\tbh=QhUxjTtiWsmHHica9r1kroTOBAeWzvnXtm+uo9LQISQ=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=UhxBsmS//F4R3WOX6cl7LGmYUb25vEQd3L7nCAvy8BSMniJ5HKzCvWPYS6dLWSvfN\n\tQw5rcgxkC1NkCqFJ4u2YIquqOrfSrpWoME/VR4M5yVHXigagDYEUxrJydTrwkBXdvo\n\tmMyeAfmsROD9VbDc8I+FXbdxOk2+gccUQJaEvB8g=","Date":"Mon, 12 Aug 2024 19:10:52 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tStefan Klug <stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH] py: cam: Convert to PyQt6","Message-ID":"<20240812161052.GA32749@pendragon.ideasonboard.com>","References":"<20240812145034.190342-1-tomi.valkeinen@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240812145034.190342-1-tomi.valkeinen@ideasonboard.com>","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":30761,"web_url":"https://patchwork.libcamera.org/comment/30761/","msgid":"<482e04a3-648f-40e8-adae-0b0dde7536ef@ideasonboard.com>","date":"2024-08-12T16:23:08","subject":"Re: [PATCH] py: cam: Convert to PyQt6","submitter":{"id":109,"url":"https://patchwork.libcamera.org/api/people/109/","name":"Tomi Valkeinen","email":"tomi.valkeinen@ideasonboard.com"},"content":"Hi,\n\nOn 12/08/2024 19:10, Laurent Pinchart wrote:\n> Hi Tomi,\n> \n> Thank you for the patch.\n> \n> On Mon, Aug 12, 2024 at 05:50:34PM +0300, Tomi Valkeinen wrote:\n>> Perhaps it's time... Convert the py cam tool to PyQt6.\n>>\n>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n>> ---\n>>   src/py/cam/cam_qt.py   |  6 +++---\n>>   src/py/cam/cam_qtgl.py | 12 ++++++------\n>>   2 files changed, 9 insertions(+), 9 deletions(-)\n>>\n>> diff --git a/src/py/cam/cam_qt.py b/src/py/cam/cam_qt.py\n>> index c1723b44..22d8c4da 100644\n>> --- a/src/py/cam/cam_qt.py\n>> +++ b/src/py/cam/cam_qt.py\n>> @@ -2,7 +2,7 @@\n>>   # Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n>>   \n>>   from helpers import mfb_to_rgb\n>> -from PyQt5 import QtCore, QtGui, QtWidgets\n>> +from PyQt6 import QtCore, QtGui, QtWidgets\n>>   import libcamera as libcam\n>>   import libcamera.utils\n>>   import sys\n>> @@ -63,10 +63,10 @@ class QtRenderer:\n>>           self.buf_mmap_map = buf_mmap_map\n>>   \n>>       def run(self):\n>> -        camnotif = QtCore.QSocketNotifier(self.cm.event_fd, QtCore.QSocketNotifier.Read)\n>> +        camnotif = QtCore.QSocketNotifier(self.cm.event_fd, QtCore.QSocketNotifier.Type.Read)\n>>           camnotif.activated.connect(lambda _: self.readcam())\n>>   \n>> -        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Read)\n>> +        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Type.Read)\n> \n> PyQt5 also defines the Read type in QtCore.QSocketNotifier.Type, so this\n> code is compatible with both Python versions.\n> \n>>           keynotif.activated.connect(lambda _: self.readkey())\n>>   \n>>           print('Capturing...')\n>> diff --git a/src/py/cam/cam_qtgl.py b/src/py/cam/cam_qtgl.py\n>> index 6cfbd347..35b4b06b 100644\n>> --- a/src/py/cam/cam_qtgl.py\n>> +++ b/src/py/cam/cam_qtgl.py\n>> @@ -1,8 +1,8 @@\n>>   # SPDX-License-Identifier: GPL-2.0-or-later\n>>   # Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n>>   \n>> -from PyQt5 import QtCore, QtWidgets\n>> -from PyQt5.QtCore import Qt\n>> +from PyQt6 import QtCore, QtWidgets\n>> +from PyQt6.QtCore import Qt\n>>   \n>>   import math\n>>   import os\n>> @@ -142,10 +142,10 @@ class QtRenderer:\n>>           self.window = window\n>>   \n>>       def run(self):\n>> -        camnotif = QtCore.QSocketNotifier(self.state.cm.event_fd, QtCore.QSocketNotifier.Read)\n>> +        camnotif = QtCore.QSocketNotifier(self.state.cm.event_fd, QtCore.QSocketNotifier.Type.Read)\n>>           camnotif.activated.connect(lambda _: self.readcam())\n>>   \n>> -        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Read)\n>> +        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Type.Read)\n>>           keynotif.activated.connect(lambda _: self.readkey())\n>>   \n>>           print('Capturing...')\n>> @@ -175,8 +175,8 @@ class MainWindow(QtWidgets.QWidget):\n>>       def __init__(self, state):\n>>           super().__init__()\n>>   \n>> -        self.setAttribute(Qt.WA_PaintOnScreen)\n>> -        self.setAttribute(Qt.WA_NativeWindow)\n>> +        self.setAttribute(Qt.WidgetAttribute.WA_PaintOnScreen)\n>> +        self.setAttribute(Qt.WidgetAttribute.WA_NativeWindow)\n> \n> This works with PyQt5 too.\n> \n> Should we try to keep Qt5 compatibility with\n> \n> try:\n>      from PyQt6 import QtCore, QtWidgets\n>      from PyQt6.QtCore import Qt\n> except:\n>      from PyQt5 import QtCore, QtWidgets\n>      from PyQt5.QtCore import Qt\n\nWill someone maintain and test the Qt5 version? Does libcamera elsewhere \nsupport both Qt5 and Qt6?\n\nI don't mind the few lines above, but I fear supporting Qt5 could easily \nbecome a hindrance for no benefit, as (afaiu) Qt5 is already end of \nlife. Are there users out there who need cam.py and can't install Qt6?\n\n  Tomi","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 5913FC323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 12 Aug 2024 16:23:14 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 64F51633B9;\n\tMon, 12 Aug 2024 18:23:13 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CC68A63369\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 12 Aug 2024 18:23:11 +0200 (CEST)","from [192.168.88.20] (91-156-87-48.elisa-laajakaista.fi\n\t[91.156.87.48])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E55C8836;\n\tMon, 12 Aug 2024 18:22:14 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"cGp+zOMw\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1723479735;\n\tbh=W7QnDJPnfIhTl7djxXbDztg907Cci8RggxkYdyjtlxM=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=cGp+zOMwHeu3OnoazuAFHzpsj7okGV1aXjC8+2W9c/wTXApew7jU02k6vtGbeCnMP\n\tcEJS6AkGCRkmib76bbnDeJPkw6Sxy0FCD/6RN0336a/XB+LToWa1tmlIGjekxRJYN7\n\tZxTOjT6GR0fV7UpcZlGTPgQ0QHBA3ogrBah6mg3w=","Message-ID":"<482e04a3-648f-40e8-adae-0b0dde7536ef@ideasonboard.com>","Date":"Mon, 12 Aug 2024 19:23:08 +0300","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH] py: cam: Convert to PyQt6","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tStefan Klug <stefan.klug@ideasonboard.com>","References":"<20240812145034.190342-1-tomi.valkeinen@ideasonboard.com>\n\t<20240812161052.GA32749@pendragon.ideasonboard.com>","Content-Language":"en-US","From":"Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>","Autocrypt":"addr=tomi.valkeinen@ideasonboard.com; keydata=\n\txsFNBE6ms0cBEACyizowecZqXfMZtnBniOieTuFdErHAUyxVgtmr0f5ZfIi9Z4l+uUN4Zdw2\n\twCEZjx3o0Z34diXBaMRJ3rAk9yB90UJAnLtb8A97Oq64DskLF81GCYB2P1i0qrG7UjpASgCA\n\tRu0lVvxsWyIwSfoYoLrazbT1wkWRs8YBkkXQFfL7Mn3ZMoGPcpfwYH9O7bV1NslbmyJzRCMO\n\teYV258gjCcwYlrkyIratlHCek4GrwV8Z9NQcjD5iLzrONjfafrWPwj6yn2RlL0mQEwt1lOvn\n\tLnI7QRtB3zxA3yB+FLsT1hx0va6xCHpX3QO2gBsyHCyVafFMrg3c/7IIWkDLngJxFgz6DLiA\n\tG4ld1QK/jsYqfP2GIMH1mFdjY+iagG4DqOsjip479HCWAptpNxSOCL6z3qxCU8MCz8iNOtZk\n\tDYXQWVscM5qgYSn+fmMM2qN+eoWlnCGVURZZLDjg387S2E1jT/dNTOsM/IqQj+ZROUZuRcF7\n\t0RTtuU5q1HnbRNwy+23xeoSGuwmLQ2UsUk7Q5CnrjYfiPo3wHze8avK95JBoSd+WIRmV3uoO\n\trXCoYOIRlDhg9XJTrbnQ3Ot5zOa0Y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Wy1hGddpkgnMjyOfLI7B\n\tCFrdecTZbR5upjNSDvQ7RG85SnpYJTIin+SAUazAeA2nS6gTZzumgtdw8XmVXZwdBfF+ICof\n\t92UkbYcYNbzWO/GHgsNT1WnM4sa9lwCSWH8Fw1o/3bX1VVPEsnESOfxkNdu+gAF5S6+I6n3a\n\tueeIlwJl5CpT5l8RpoZXEOVtXYn8zzOJ7oGZYINRV9Pf8qKGLf3Dft7zKBP832I3PQjeok7F\n\tyjt+9S+KgSFSHP3Pa4E7lsSdWhSlHYNdG/czhoUkSCN09C0rEK93wxACx3vtxPLjXu6RptBw\n\t3dRq7n+mQChEB1am0BueV1JZaBboIL0AGlSJkm23kw==","In-Reply-To":"<20240812161052.GA32749@pendragon.ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":30763,"web_url":"https://patchwork.libcamera.org/comment/30763/","msgid":"<172348015630.1687952.3871753549336770947@ping.linuxembedded.co.uk>","date":"2024-08-12T16:29:16","subject":"Re: [PATCH] py: cam: Convert to PyQt6","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart (2024-08-12 17:10:52)\n> Hi Tomi,\n> \n> Thank you for the patch.\n> \n> On Mon, Aug 12, 2024 at 05:50:34PM +0300, Tomi Valkeinen wrote:\n> > Perhaps it's time... Convert the py cam tool to PyQt6.\n> > \n\nI would probably say :\n\n\"\"\"\nQT5 is now end of life. The libcamera 'qcam' application has removed\nsupport for QT5, and updated to QT6.\n\nUpdate the python 'cam' QT implementation accordingly to QT6.\n\nQT5 support is kept as backwards compatibilty if QT6 is not found.\n\"\"\"\n\nWith the last sentence being dependant upon the question below :D\n\n\n> > Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n> > ---\n> >  src/py/cam/cam_qt.py   |  6 +++---\n> >  src/py/cam/cam_qtgl.py | 12 ++++++------\n> >  2 files changed, 9 insertions(+), 9 deletions(-)\n> > \n> > diff --git a/src/py/cam/cam_qt.py b/src/py/cam/cam_qt.py\n> > index c1723b44..22d8c4da 100644\n> > --- a/src/py/cam/cam_qt.py\n> > +++ b/src/py/cam/cam_qt.py\n> > @@ -2,7 +2,7 @@\n> >  # Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n> >  \n> >  from helpers import mfb_to_rgb\n> > -from PyQt5 import QtCore, QtGui, QtWidgets\n> > +from PyQt6 import QtCore, QtGui, QtWidgets\n> >  import libcamera as libcam\n> >  import libcamera.utils\n> >  import sys\n> > @@ -63,10 +63,10 @@ class QtRenderer:\n> >          self.buf_mmap_map = buf_mmap_map\n> >  \n> >      def run(self):\n> > -        camnotif = QtCore.QSocketNotifier(self.cm.event_fd, QtCore.QSocketNotifier.Read)\n> > +        camnotif = QtCore.QSocketNotifier(self.cm.event_fd, QtCore.QSocketNotifier.Type.Read)\n> >          camnotif.activated.connect(lambda _: self.readcam())\n> >  \n> > -        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Read)\n> > +        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Type.Read)\n> \n> PyQt5 also defines the Read type in QtCore.QSocketNotifier.Type, so this\n> code is compatible with both Python versions.\n> \n> >          keynotif.activated.connect(lambda _: self.readkey())\n> >  \n> >          print('Capturing...')\n> > diff --git a/src/py/cam/cam_qtgl.py b/src/py/cam/cam_qtgl.py\n> > index 6cfbd347..35b4b06b 100644\n> > --- a/src/py/cam/cam_qtgl.py\n> > +++ b/src/py/cam/cam_qtgl.py\n> > @@ -1,8 +1,8 @@\n> >  # SPDX-License-Identifier: GPL-2.0-or-later\n> >  # Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n> >  \n> > -from PyQt5 import QtCore, QtWidgets\n> > -from PyQt5.QtCore import Qt\n> > +from PyQt6 import QtCore, QtWidgets\n> > +from PyQt6.QtCore import Qt\n> >  \n> >  import math\n> >  import os\n> > @@ -142,10 +142,10 @@ class QtRenderer:\n> >          self.window = window\n> >  \n> >      def run(self):\n> > -        camnotif = QtCore.QSocketNotifier(self.state.cm.event_fd, QtCore.QSocketNotifier.Read)\n> > +        camnotif = QtCore.QSocketNotifier(self.state.cm.event_fd, QtCore.QSocketNotifier.Type.Read)\n> >          camnotif.activated.connect(lambda _: self.readcam())\n> >  \n> > -        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Read)\n> > +        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Type.Read)\n> >          keynotif.activated.connect(lambda _: self.readkey())\n> >  \n> >          print('Capturing...')\n> > @@ -175,8 +175,8 @@ class MainWindow(QtWidgets.QWidget):\n> >      def __init__(self, state):\n> >          super().__init__()\n> >  \n> > -        self.setAttribute(Qt.WA_PaintOnScreen)\n> > -        self.setAttribute(Qt.WA_NativeWindow)\n> > +        self.setAttribute(Qt.WidgetAttribute.WA_PaintOnScreen)\n> > +        self.setAttribute(Qt.WidgetAttribute.WA_NativeWindow)\n> \n> This works with PyQt5 too.\n> \n> Should we try to keep Qt5 compatibility with\n> \n> try:\n>     from PyQt6 import QtCore, QtWidgets\n>     from PyQt6.QtCore import Qt\n> except:\n>     from PyQt5 import QtCore, QtWidgets\n>     from PyQt5.QtCore import Qt\n> \n> ?\n\nWe've completely dropped QT5 from the list of requirements for qcam, and\nonly support QT6 for that now, so I don't think this is 'required'.\n\nHowever - that's very \"lightweight\" to support Qt5.. so I don't object.\n\n\nAnyway, definitely time to move this to QT6...\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n--\nKieran\n\n\n> \n> >  \n> >          self.state = state\n> >  \n> \n> -- \n> Regards,\n> \n> Laurent Pinchart","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 46DC4BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 12 Aug 2024 16:29:21 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E122F633B9;\n\tMon, 12 Aug 2024 18:29:20 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id ACFCD63369\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 12 Aug 2024 18:29:19 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2A801836;\n\tMon, 12 Aug 2024 18:28:23 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"F1QungAa\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1723480103;\n\tbh=FTFwFyzDTXoRTY/J9a8cds2N0lUIVCsZchYpqsFr5ng=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=F1QungAa++f7kHaRYuc+n2y2ObGmWnK14MlyL8UaqQu2AaZBl01kZX2swBPZfyfew\n\tNIPnQqSv76d8RsZd10NrPr/rBR1rcrQ8smrKRe8plV0KWIxO0hZDKIcCl3mTJSH+Rp\n\tmkKG43C7u2+bONpvISOB5kyc46xLmrCWgOPKUn2U=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20240812161052.GA32749@pendragon.ideasonboard.com>","References":"<20240812145034.190342-1-tomi.valkeinen@ideasonboard.com>\n\t<20240812161052.GA32749@pendragon.ideasonboard.com>","Subject":"Re: [PATCH] py: cam: Convert to PyQt6","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tStefan Klug <stefan.klug@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tTomi Valkeinen <tomi.valkeinen@ideasonboard.com>","Date":"Mon, 12 Aug 2024 17:29:16 +0100","Message-ID":"<172348015630.1687952.3871753549336770947@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":30764,"web_url":"https://patchwork.libcamera.org/comment/30764/","msgid":"<20240812164200.GB32749@pendragon.ideasonboard.com>","date":"2024-08-12T16:42:00","subject":"Re: [PATCH] py: cam: Convert to PyQt6","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Mon, Aug 12, 2024 at 07:23:08PM +0300, Tomi Valkeinen wrote:\n> On 12/08/2024 19:10, Laurent Pinchart wrote:\n> > On Mon, Aug 12, 2024 at 05:50:34PM +0300, Tomi Valkeinen wrote:\n> >> Perhaps it's time... Convert the py cam tool to PyQt6.\n> >>\n> >> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n> >> ---\n> >>   src/py/cam/cam_qt.py   |  6 +++---\n> >>   src/py/cam/cam_qtgl.py | 12 ++++++------\n> >>   2 files changed, 9 insertions(+), 9 deletions(-)\n> >>\n> >> diff --git a/src/py/cam/cam_qt.py b/src/py/cam/cam_qt.py\n> >> index c1723b44..22d8c4da 100644\n> >> --- a/src/py/cam/cam_qt.py\n> >> +++ b/src/py/cam/cam_qt.py\n> >> @@ -2,7 +2,7 @@\n> >>   # Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n> >>   \n> >>   from helpers import mfb_to_rgb\n> >> -from PyQt5 import QtCore, QtGui, QtWidgets\n> >> +from PyQt6 import QtCore, QtGui, QtWidgets\n> >>   import libcamera as libcam\n> >>   import libcamera.utils\n> >>   import sys\n> >> @@ -63,10 +63,10 @@ class QtRenderer:\n> >>           self.buf_mmap_map = buf_mmap_map\n> >>   \n> >>       def run(self):\n> >> -        camnotif = QtCore.QSocketNotifier(self.cm.event_fd, QtCore.QSocketNotifier.Read)\n> >> +        camnotif = QtCore.QSocketNotifier(self.cm.event_fd, QtCore.QSocketNotifier.Type.Read)\n> >>           camnotif.activated.connect(lambda _: self.readcam())\n> >>   \n> >> -        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Read)\n> >> +        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Type.Read)\n> > \n> > PyQt5 also defines the Read type in QtCore.QSocketNotifier.Type, so this\n> > code is compatible with both Python versions.\n> > \n> >>           keynotif.activated.connect(lambda _: self.readkey())\n> >>   \n> >>           print('Capturing...')\n> >> diff --git a/src/py/cam/cam_qtgl.py b/src/py/cam/cam_qtgl.py\n> >> index 6cfbd347..35b4b06b 100644\n> >> --- a/src/py/cam/cam_qtgl.py\n> >> +++ b/src/py/cam/cam_qtgl.py\n> >> @@ -1,8 +1,8 @@\n> >>   # SPDX-License-Identifier: GPL-2.0-or-later\n> >>   # Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n> >>   \n> >> -from PyQt5 import QtCore, QtWidgets\n> >> -from PyQt5.QtCore import Qt\n> >> +from PyQt6 import QtCore, QtWidgets\n> >> +from PyQt6.QtCore import Qt\n> >>   \n> >>   import math\n> >>   import os\n> >> @@ -142,10 +142,10 @@ class QtRenderer:\n> >>           self.window = window\n> >>   \n> >>       def run(self):\n> >> -        camnotif = QtCore.QSocketNotifier(self.state.cm.event_fd, QtCore.QSocketNotifier.Read)\n> >> +        camnotif = QtCore.QSocketNotifier(self.state.cm.event_fd, QtCore.QSocketNotifier.Type.Read)\n> >>           camnotif.activated.connect(lambda _: self.readcam())\n> >>   \n> >> -        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Read)\n> >> +        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Type.Read)\n> >>           keynotif.activated.connect(lambda _: self.readkey())\n> >>   \n> >>           print('Capturing...')\n> >> @@ -175,8 +175,8 @@ class MainWindow(QtWidgets.QWidget):\n> >>       def __init__(self, state):\n> >>           super().__init__()\n> >>   \n> >> -        self.setAttribute(Qt.WA_PaintOnScreen)\n> >> -        self.setAttribute(Qt.WA_NativeWindow)\n> >> +        self.setAttribute(Qt.WidgetAttribute.WA_PaintOnScreen)\n> >> +        self.setAttribute(Qt.WidgetAttribute.WA_NativeWindow)\n> > \n> > This works with PyQt5 too.\n> > \n> > Should we try to keep Qt5 compatibility with\n> > \n> > try:\n> >      from PyQt6 import QtCore, QtWidgets\n> >      from PyQt6.QtCore import Qt\n> > except:\n> >      from PyQt5 import QtCore, QtWidgets\n> >      from PyQt5.QtCore import Qt\n> \n> Will someone maintain and test the Qt5 version?\n\nQuite unlikely.\n\n> Does libcamera elsewhere support both Qt5 and Qt6?\n\nI think qcam did a hard switch to Qt6.\n\n> I don't mind the few lines above, but I fear supporting Qt5 could easily \n> become a hindrance for no benefit, as (afaiu) Qt5 is already end of \n> life. Are there users out there who need cam.py and can't install Qt6?\n\nI don't want to maintain both versions. I was thinking it could be nice\nfor users to support both for a transition period, given how easy it is.\nAs soon as it becomes a burden, or even before that, we can drop Qt5\nsupport. A warning message in the except path above would make sense to\nwarn users they should migrate.\n\nThis being said, given that qcam now requires Qt6, it may make even less\nsense to support Qt5 in cam.py. I'll leave the decision to you, either\nway,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id F19DDC323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 12 Aug 2024 16:42:27 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D1685633B5;\n\tMon, 12 Aug 2024 18:42:26 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5497163369\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 12 Aug 2024 18:42:25 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 60B16836;\n\tMon, 12 Aug 2024 18:41:28 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"mPZMiAla\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1723480888;\n\tbh=p+H+1U8592/3KlMSBUT+igK46RH7vs6NSNI3EP7J7jE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=mPZMiAlaP3P4av1jNNAz5+Qqq9A2pavpRpGDyiwdfV78O6SG2u4pSAA1yVymQkYLy\n\tiFfCkeAYYYuPlny3WpYiltxDc0Rpo/rLpVoetK69trjkinXkOMxdb5XoqcQ5fQkCY9\n\tvdO3lmHSBc8gFQTK2gEL1g+moDpBYk72tkrWfZHw=","Date":"Mon, 12 Aug 2024 19:42:00 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tStefan Klug <stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH] py: cam: Convert to PyQt6","Message-ID":"<20240812164200.GB32749@pendragon.ideasonboard.com>","References":"<20240812145034.190342-1-tomi.valkeinen@ideasonboard.com>\n\t<20240812161052.GA32749@pendragon.ideasonboard.com>\n\t<482e04a3-648f-40e8-adae-0b0dde7536ef@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<482e04a3-648f-40e8-adae-0b0dde7536ef@ideasonboard.com>","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]