[v2] py: cam: Convert to PyQt6
diff mbox series

Message ID 20240812172730.204242-1-tomi.valkeinen@ideasonboard.com
State Accepted
Commit 15a51caae8811817f55af0a925915d8fa45ca7a4
Headers show
Series
  • [v2] py: cam: Convert to PyQt6
Related show

Commit Message

Tomi Valkeinen Aug. 12, 2024, 5:27 p.m. UTC
Qt5 is now end of life. The libcamera 'qcam' application has removed
support for Qt5, and updated to Qt6.

Update the python 'cam' application accordingly to Qt6.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
v2:
- Added RB tags
- Updated the commit description

 src/py/cam/cam_qt.py   |  6 +++---
 src/py/cam/cam_qtgl.py | 12 ++++++------
 2 files changed, 9 insertions(+), 9 deletions(-)

Comments

David Plowman Aug. 13, 2024, 8:05 a.m. UTC | #1
Hi everyone

Could I just put in a vote for maintaining backward compatibility with
PyQt5 for the time being? By all means deprecate it, put in a warning,
but please don't break it _yet_. There are many platforms still
running PyQt5 (the latest Raspberry Pi OS based on Debian Bookworm has
PyQt5), and we've found many people have had problems upgrading PyQt
versions and then discovering OpenCV gets upset and doesn't work any
more. We ship versions in apt that we guarantee work properly
together, and I wouldn't like to tell people "sorry, you've got to
find versions for yourself that play nicely, or build everything
yourself from source. Only building some of this stuff can be
non-trivial. Good luck."

Thanks

David

On Mon, 12 Aug 2024 at 18:27, Tomi Valkeinen
<tomi.valkeinen@ideasonboard.com> wrote:
>
> Qt5 is now end of life. The libcamera 'qcam' application has removed
> support for Qt5, and updated to Qt6.
>
> Update the python 'cam' application accordingly to Qt6.
>
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> v2:
> - Added RB tags
> - Updated the commit description
>
>  src/py/cam/cam_qt.py   |  6 +++---
>  src/py/cam/cam_qtgl.py | 12 ++++++------
>  2 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/src/py/cam/cam_qt.py b/src/py/cam/cam_qt.py
> index c1723b44..22d8c4da 100644
> --- a/src/py/cam/cam_qt.py
> +++ b/src/py/cam/cam_qt.py
> @@ -2,7 +2,7 @@
>  # Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
>
>  from helpers import mfb_to_rgb
> -from PyQt5 import QtCore, QtGui, QtWidgets
> +from PyQt6 import QtCore, QtGui, QtWidgets
>  import libcamera as libcam
>  import libcamera.utils
>  import sys
> @@ -63,10 +63,10 @@ class QtRenderer:
>          self.buf_mmap_map = buf_mmap_map
>
>      def run(self):
> -        camnotif = QtCore.QSocketNotifier(self.cm.event_fd, QtCore.QSocketNotifier.Read)
> +        camnotif = QtCore.QSocketNotifier(self.cm.event_fd, QtCore.QSocketNotifier.Type.Read)
>          camnotif.activated.connect(lambda _: self.readcam())
>
> -        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Read)
> +        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Type.Read)
>          keynotif.activated.connect(lambda _: self.readkey())
>
>          print('Capturing...')
> diff --git a/src/py/cam/cam_qtgl.py b/src/py/cam/cam_qtgl.py
> index 6cfbd347..35b4b06b 100644
> --- a/src/py/cam/cam_qtgl.py
> +++ b/src/py/cam/cam_qtgl.py
> @@ -1,8 +1,8 @@
>  # SPDX-License-Identifier: GPL-2.0-or-later
>  # Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
>
> -from PyQt5 import QtCore, QtWidgets
> -from PyQt5.QtCore import Qt
> +from PyQt6 import QtCore, QtWidgets
> +from PyQt6.QtCore import Qt
>
>  import math
>  import os
> @@ -142,10 +142,10 @@ class QtRenderer:
>          self.window = window
>
>      def run(self):
> -        camnotif = QtCore.QSocketNotifier(self.state.cm.event_fd, QtCore.QSocketNotifier.Read)
> +        camnotif = QtCore.QSocketNotifier(self.state.cm.event_fd, QtCore.QSocketNotifier.Type.Read)
>          camnotif.activated.connect(lambda _: self.readcam())
>
> -        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Read)
> +        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Type.Read)
>          keynotif.activated.connect(lambda _: self.readkey())
>
>          print('Capturing...')
> @@ -175,8 +175,8 @@ class MainWindow(QtWidgets.QWidget):
>      def __init__(self, state):
>          super().__init__()
>
> -        self.setAttribute(Qt.WA_PaintOnScreen)
> -        self.setAttribute(Qt.WA_NativeWindow)
> +        self.setAttribute(Qt.WidgetAttribute.WA_PaintOnScreen)
> +        self.setAttribute(Qt.WidgetAttribute.WA_NativeWindow)
>
>          self.state = state
>
> --
> 2.43.0
>
Tomi Valkeinen Aug. 13, 2024, 8:08 a.m. UTC | #2
Hi David,

On 13/08/2024 11:05, David Plowman wrote:
> Hi everyone
> 
> Could I just put in a vote for maintaining backward compatibility with
> PyQt5 for the time being? By all means deprecate it, put in a warning,
> but please don't break it _yet_. There are many platforms still
> running PyQt5 (the latest Raspberry Pi OS based on Debian Bookworm has
> PyQt5), and we've found many people have had problems upgrading PyQt
> versions and then discovering OpenCV gets upset and doesn't work any
> more. We ship versions in apt that we guarantee work properly
> together, and I wouldn't like to tell people "sorry, you've got to
> find versions for yourself that play nicely, or build everything
> yourself from source. Only building some of this stuff can be
> non-trivial. Good luck."

I hear you, but this is only about the cam.py example application in 
libcamera's source tree, and only the qt and qtgl renderers of that example.

I don't think that example app is distributed anywhere, or, if I had to 
guess, even used by anyone.

  Tomi

> 
> Thanks
> 
> David
> 
> On Mon, 12 Aug 2024 at 18:27, Tomi Valkeinen
> <tomi.valkeinen@ideasonboard.com> wrote:
>>
>> Qt5 is now end of life. The libcamera 'qcam' application has removed
>> support for Qt5, and updated to Qt6.
>>
>> Update the python 'cam' application accordingly to Qt6.
>>
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
>> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>> ---
>> v2:
>> - Added RB tags
>> - Updated the commit description
>>
>>   src/py/cam/cam_qt.py   |  6 +++---
>>   src/py/cam/cam_qtgl.py | 12 ++++++------
>>   2 files changed, 9 insertions(+), 9 deletions(-)
>>
>> diff --git a/src/py/cam/cam_qt.py b/src/py/cam/cam_qt.py
>> index c1723b44..22d8c4da 100644
>> --- a/src/py/cam/cam_qt.py
>> +++ b/src/py/cam/cam_qt.py
>> @@ -2,7 +2,7 @@
>>   # Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
>>
>>   from helpers import mfb_to_rgb
>> -from PyQt5 import QtCore, QtGui, QtWidgets
>> +from PyQt6 import QtCore, QtGui, QtWidgets
>>   import libcamera as libcam
>>   import libcamera.utils
>>   import sys
>> @@ -63,10 +63,10 @@ class QtRenderer:
>>           self.buf_mmap_map = buf_mmap_map
>>
>>       def run(self):
>> -        camnotif = QtCore.QSocketNotifier(self.cm.event_fd, QtCore.QSocketNotifier.Read)
>> +        camnotif = QtCore.QSocketNotifier(self.cm.event_fd, QtCore.QSocketNotifier.Type.Read)
>>           camnotif.activated.connect(lambda _: self.readcam())
>>
>> -        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Read)
>> +        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Type.Read)
>>           keynotif.activated.connect(lambda _: self.readkey())
>>
>>           print('Capturing...')
>> diff --git a/src/py/cam/cam_qtgl.py b/src/py/cam/cam_qtgl.py
>> index 6cfbd347..35b4b06b 100644
>> --- a/src/py/cam/cam_qtgl.py
>> +++ b/src/py/cam/cam_qtgl.py
>> @@ -1,8 +1,8 @@
>>   # SPDX-License-Identifier: GPL-2.0-or-later
>>   # Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
>>
>> -from PyQt5 import QtCore, QtWidgets
>> -from PyQt5.QtCore import Qt
>> +from PyQt6 import QtCore, QtWidgets
>> +from PyQt6.QtCore import Qt
>>
>>   import math
>>   import os
>> @@ -142,10 +142,10 @@ class QtRenderer:
>>           self.window = window
>>
>>       def run(self):
>> -        camnotif = QtCore.QSocketNotifier(self.state.cm.event_fd, QtCore.QSocketNotifier.Read)
>> +        camnotif = QtCore.QSocketNotifier(self.state.cm.event_fd, QtCore.QSocketNotifier.Type.Read)
>>           camnotif.activated.connect(lambda _: self.readcam())
>>
>> -        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Read)
>> +        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Type.Read)
>>           keynotif.activated.connect(lambda _: self.readkey())
>>
>>           print('Capturing...')
>> @@ -175,8 +175,8 @@ class MainWindow(QtWidgets.QWidget):
>>       def __init__(self, state):
>>           super().__init__()
>>
>> -        self.setAttribute(Qt.WA_PaintOnScreen)
>> -        self.setAttribute(Qt.WA_NativeWindow)
>> +        self.setAttribute(Qt.WidgetAttribute.WA_PaintOnScreen)
>> +        self.setAttribute(Qt.WidgetAttribute.WA_NativeWindow)
>>
>>           self.state = state
>>
>> --
>> 2.43.0
>>
David Plowman Aug. 13, 2024, 8:29 a.m. UTC | #3
Hi Tomi

Well, I guess if we don't think there's a real problem then it's fine,
though I assume someone somewhere must be using it! I suppose on a Pi
folks have lots of other apps and Qt apps to run anyway.

Thanks
David

On Tue, 13 Aug 2024 at 09:08, Tomi Valkeinen
<tomi.valkeinen@ideasonboard.com> wrote:
>
> Hi David,
>
> On 13/08/2024 11:05, David Plowman wrote:
> > Hi everyone
> >
> > Could I just put in a vote for maintaining backward compatibility with
> > PyQt5 for the time being? By all means deprecate it, put in a warning,
> > but please don't break it _yet_. There are many platforms still
> > running PyQt5 (the latest Raspberry Pi OS based on Debian Bookworm has
> > PyQt5), and we've found many people have had problems upgrading PyQt
> > versions and then discovering OpenCV gets upset and doesn't work any
> > more. We ship versions in apt that we guarantee work properly
> > together, and I wouldn't like to tell people "sorry, you've got to
> > find versions for yourself that play nicely, or build everything
> > yourself from source. Only building some of this stuff can be
> > non-trivial. Good luck."
>
> I hear you, but this is only about the cam.py example application in
> libcamera's source tree, and only the qt and qtgl renderers of that example.
>
> I don't think that example app is distributed anywhere, or, if I had to
> guess, even used by anyone.
>
>   Tomi
>
> >
> > Thanks
> >
> > David
> >
> > On Mon, 12 Aug 2024 at 18:27, Tomi Valkeinen
> > <tomi.valkeinen@ideasonboard.com> wrote:
> >>
> >> Qt5 is now end of life. The libcamera 'qcam' application has removed
> >> support for Qt5, and updated to Qt6.
> >>
> >> Update the python 'cam' application accordingly to Qt6.
> >>
> >> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> >> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> >> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> >> ---
> >> v2:
> >> - Added RB tags
> >> - Updated the commit description
> >>
> >>   src/py/cam/cam_qt.py   |  6 +++---
> >>   src/py/cam/cam_qtgl.py | 12 ++++++------
> >>   2 files changed, 9 insertions(+), 9 deletions(-)
> >>
> >> diff --git a/src/py/cam/cam_qt.py b/src/py/cam/cam_qt.py
> >> index c1723b44..22d8c4da 100644
> >> --- a/src/py/cam/cam_qt.py
> >> +++ b/src/py/cam/cam_qt.py
> >> @@ -2,7 +2,7 @@
> >>   # Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> >>
> >>   from helpers import mfb_to_rgb
> >> -from PyQt5 import QtCore, QtGui, QtWidgets
> >> +from PyQt6 import QtCore, QtGui, QtWidgets
> >>   import libcamera as libcam
> >>   import libcamera.utils
> >>   import sys
> >> @@ -63,10 +63,10 @@ class QtRenderer:
> >>           self.buf_mmap_map = buf_mmap_map
> >>
> >>       def run(self):
> >> -        camnotif = QtCore.QSocketNotifier(self.cm.event_fd, QtCore.QSocketNotifier.Read)
> >> +        camnotif = QtCore.QSocketNotifier(self.cm.event_fd, QtCore.QSocketNotifier.Type.Read)
> >>           camnotif.activated.connect(lambda _: self.readcam())
> >>
> >> -        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Read)
> >> +        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Type.Read)
> >>           keynotif.activated.connect(lambda _: self.readkey())
> >>
> >>           print('Capturing...')
> >> diff --git a/src/py/cam/cam_qtgl.py b/src/py/cam/cam_qtgl.py
> >> index 6cfbd347..35b4b06b 100644
> >> --- a/src/py/cam/cam_qtgl.py
> >> +++ b/src/py/cam/cam_qtgl.py
> >> @@ -1,8 +1,8 @@
> >>   # SPDX-License-Identifier: GPL-2.0-or-later
> >>   # Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> >>
> >> -from PyQt5 import QtCore, QtWidgets
> >> -from PyQt5.QtCore import Qt
> >> +from PyQt6 import QtCore, QtWidgets
> >> +from PyQt6.QtCore import Qt
> >>
> >>   import math
> >>   import os
> >> @@ -142,10 +142,10 @@ class QtRenderer:
> >>           self.window = window
> >>
> >>       def run(self):
> >> -        camnotif = QtCore.QSocketNotifier(self.state.cm.event_fd, QtCore.QSocketNotifier.Read)
> >> +        camnotif = QtCore.QSocketNotifier(self.state.cm.event_fd, QtCore.QSocketNotifier.Type.Read)
> >>           camnotif.activated.connect(lambda _: self.readcam())
> >>
> >> -        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Read)
> >> +        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Type.Read)
> >>           keynotif.activated.connect(lambda _: self.readkey())
> >>
> >>           print('Capturing...')
> >> @@ -175,8 +175,8 @@ class MainWindow(QtWidgets.QWidget):
> >>       def __init__(self, state):
> >>           super().__init__()
> >>
> >> -        self.setAttribute(Qt.WA_PaintOnScreen)
> >> -        self.setAttribute(Qt.WA_NativeWindow)
> >> +        self.setAttribute(Qt.WidgetAttribute.WA_PaintOnScreen)
> >> +        self.setAttribute(Qt.WidgetAttribute.WA_NativeWindow)
> >>
> >>           self.state = state
> >>
> >> --
> >> 2.43.0
> >>
>
Laurent Pinchart Aug. 13, 2024, 8:31 a.m. UTC | #4
Hi David,

On Tue, Aug 13, 2024 at 09:05:03AM +0100, David Plowman wrote:
> Hi everyone
> 
> Could I just put in a vote for maintaining backward compatibility with
> PyQt5 for the time being? By all means deprecate it, put in a warning,
> but please don't break it _yet_. There are many platforms still
> running PyQt5 (the latest Raspberry Pi OS based on Debian Bookworm has
> PyQt5), and we've found many people have had problems upgrading PyQt
> versions and then discovering OpenCV gets upset and doesn't work any
> more.

This is the exact kind of reason why I proposed supporting both PyQt5
and PyQt6 for the time being.

> We ship versions in apt that we guarantee work properly
> together, and I wouldn't like to tell people "sorry, you've got to
> find versions for yourself that play nicely, or build everything
> yourself from source. Only building some of this stuff can be
> non-trivial. Good luck."

Tomi, could you send a patch to restore PyQt5 support ?

David, please note that this will be best effort, until we start using
Qt features that differ between Qt5 and Qt6. I don't expect that to
happen soon though, there's little development done on the Qt backend of
cam.py at the moment.

> On Mon, 12 Aug 2024 at 18:27, Tomi Valkeinen wrote:
> >
> > Qt5 is now end of life. The libcamera 'qcam' application has removed
> > support for Qt5, and updated to Qt6.
> >
> > Update the python 'cam' application accordingly to Qt6.
> >
> > Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> > v2:
> > - Added RB tags
> > - Updated the commit description
> >
> >  src/py/cam/cam_qt.py   |  6 +++---
> >  src/py/cam/cam_qtgl.py | 12 ++++++------
> >  2 files changed, 9 insertions(+), 9 deletions(-)
> >
> > diff --git a/src/py/cam/cam_qt.py b/src/py/cam/cam_qt.py
> > index c1723b44..22d8c4da 100644
> > --- a/src/py/cam/cam_qt.py
> > +++ b/src/py/cam/cam_qt.py
> > @@ -2,7 +2,7 @@
> >  # Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> >
> >  from helpers import mfb_to_rgb
> > -from PyQt5 import QtCore, QtGui, QtWidgets
> > +from PyQt6 import QtCore, QtGui, QtWidgets
> >  import libcamera as libcam
> >  import libcamera.utils
> >  import sys
> > @@ -63,10 +63,10 @@ class QtRenderer:
> >          self.buf_mmap_map = buf_mmap_map
> >
> >      def run(self):
> > -        camnotif = QtCore.QSocketNotifier(self.cm.event_fd, QtCore.QSocketNotifier.Read)
> > +        camnotif = QtCore.QSocketNotifier(self.cm.event_fd, QtCore.QSocketNotifier.Type.Read)
> >          camnotif.activated.connect(lambda _: self.readcam())
> >
> > -        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Read)
> > +        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Type.Read)
> >          keynotif.activated.connect(lambda _: self.readkey())
> >
> >          print('Capturing...')
> > diff --git a/src/py/cam/cam_qtgl.py b/src/py/cam/cam_qtgl.py
> > index 6cfbd347..35b4b06b 100644
> > --- a/src/py/cam/cam_qtgl.py
> > +++ b/src/py/cam/cam_qtgl.py
> > @@ -1,8 +1,8 @@
> >  # SPDX-License-Identifier: GPL-2.0-or-later
> >  # Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> >
> > -from PyQt5 import QtCore, QtWidgets
> > -from PyQt5.QtCore import Qt
> > +from PyQt6 import QtCore, QtWidgets
> > +from PyQt6.QtCore import Qt
> >
> >  import math
> >  import os
> > @@ -142,10 +142,10 @@ class QtRenderer:
> >          self.window = window
> >
> >      def run(self):
> > -        camnotif = QtCore.QSocketNotifier(self.state.cm.event_fd, QtCore.QSocketNotifier.Read)
> > +        camnotif = QtCore.QSocketNotifier(self.state.cm.event_fd, QtCore.QSocketNotifier.Type.Read)
> >          camnotif.activated.connect(lambda _: self.readcam())
> >
> > -        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Read)
> > +        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Type.Read)
> >          keynotif.activated.connect(lambda _: self.readkey())
> >
> >          print('Capturing...')
> > @@ -175,8 +175,8 @@ class MainWindow(QtWidgets.QWidget):
> >      def __init__(self, state):
> >          super().__init__()
> >
> > -        self.setAttribute(Qt.WA_PaintOnScreen)
> > -        self.setAttribute(Qt.WA_NativeWindow)
> > +        self.setAttribute(Qt.WidgetAttribute.WA_PaintOnScreen)
> > +        self.setAttribute(Qt.WidgetAttribute.WA_NativeWindow)
> >
> >          self.state = state
> >
Tomi Valkeinen Aug. 13, 2024, 9:04 a.m. UTC | #5
Hi,

On 13/08/2024 11:31, Laurent Pinchart wrote:
> Hi David,
> 
> On Tue, Aug 13, 2024 at 09:05:03AM +0100, David Plowman wrote:
>> Hi everyone
>>
>> Could I just put in a vote for maintaining backward compatibility with
>> PyQt5 for the time being? By all means deprecate it, put in a warning,
>> but please don't break it _yet_. There are many platforms still
>> running PyQt5 (the latest Raspberry Pi OS based on Debian Bookworm has
>> PyQt5), and we've found many people have had problems upgrading PyQt
>> versions and then discovering OpenCV gets upset and doesn't work any
>> more.

But there are ready PyQt6 packages available, aren't there? So if the 
user wants to run libcamera's cam.py, he just needs to "apt install 
python3-pyqt6"?

> This is the exact kind of reason why I proposed supporting both PyQt5
> and PyQt6 for the time being.
> 
>> We ship versions in apt that we guarantee work properly
>> together, and I wouldn't like to tell people "sorry, you've got to
>> find versions for yourself that play nicely, or build everything
>> yourself from source. Only building some of this stuff can be
>> non-trivial. Good luck."
> 
> Tomi, could you send a patch to restore PyQt5 support ?

Aren't we then just adding code for the theoretical case that someone 
needs and uses this and cannot install PyQt6? Again, this is an example 
that is not distributed anywhere (afaik) else but the source tree. It 
does not affect any other python script or library, nor does it prevent 
people from continuing to use PyQt5.

The change itself is trivial, but I truly don't see the point.

  Tomi

> David, please note that this will be best effort, until we start using
> Qt features that differ between Qt5 and Qt6. I don't expect that to
> happen soon though, there's little development done on the Qt backend of
> cam.py at the moment.
> 
>> On Mon, 12 Aug 2024 at 18:27, Tomi Valkeinen wrote:
>>>
>>> Qt5 is now end of life. The libcamera 'qcam' application has removed
>>> support for Qt5, and updated to Qt6.
>>>
>>> Update the python 'cam' application accordingly to Qt6.
>>>
>>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
>>> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
>>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>>> ---
>>> v2:
>>> - Added RB tags
>>> - Updated the commit description
>>>
>>>   src/py/cam/cam_qt.py   |  6 +++---
>>>   src/py/cam/cam_qtgl.py | 12 ++++++------
>>>   2 files changed, 9 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/src/py/cam/cam_qt.py b/src/py/cam/cam_qt.py
>>> index c1723b44..22d8c4da 100644
>>> --- a/src/py/cam/cam_qt.py
>>> +++ b/src/py/cam/cam_qt.py
>>> @@ -2,7 +2,7 @@
>>>   # Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
>>>
>>>   from helpers import mfb_to_rgb
>>> -from PyQt5 import QtCore, QtGui, QtWidgets
>>> +from PyQt6 import QtCore, QtGui, QtWidgets
>>>   import libcamera as libcam
>>>   import libcamera.utils
>>>   import sys
>>> @@ -63,10 +63,10 @@ class QtRenderer:
>>>           self.buf_mmap_map = buf_mmap_map
>>>
>>>       def run(self):
>>> -        camnotif = QtCore.QSocketNotifier(self.cm.event_fd, QtCore.QSocketNotifier.Read)
>>> +        camnotif = QtCore.QSocketNotifier(self.cm.event_fd, QtCore.QSocketNotifier.Type.Read)
>>>           camnotif.activated.connect(lambda _: self.readcam())
>>>
>>> -        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Read)
>>> +        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Type.Read)
>>>           keynotif.activated.connect(lambda _: self.readkey())
>>>
>>>           print('Capturing...')
>>> diff --git a/src/py/cam/cam_qtgl.py b/src/py/cam/cam_qtgl.py
>>> index 6cfbd347..35b4b06b 100644
>>> --- a/src/py/cam/cam_qtgl.py
>>> +++ b/src/py/cam/cam_qtgl.py
>>> @@ -1,8 +1,8 @@
>>>   # SPDX-License-Identifier: GPL-2.0-or-later
>>>   # Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
>>>
>>> -from PyQt5 import QtCore, QtWidgets
>>> -from PyQt5.QtCore import Qt
>>> +from PyQt6 import QtCore, QtWidgets
>>> +from PyQt6.QtCore import Qt
>>>
>>>   import math
>>>   import os
>>> @@ -142,10 +142,10 @@ class QtRenderer:
>>>           self.window = window
>>>
>>>       def run(self):
>>> -        camnotif = QtCore.QSocketNotifier(self.state.cm.event_fd, QtCore.QSocketNotifier.Read)
>>> +        camnotif = QtCore.QSocketNotifier(self.state.cm.event_fd, QtCore.QSocketNotifier.Type.Read)
>>>           camnotif.activated.connect(lambda _: self.readcam())
>>>
>>> -        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Read)
>>> +        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Type.Read)
>>>           keynotif.activated.connect(lambda _: self.readkey())
>>>
>>>           print('Capturing...')
>>> @@ -175,8 +175,8 @@ class MainWindow(QtWidgets.QWidget):
>>>       def __init__(self, state):
>>>           super().__init__()
>>>
>>> -        self.setAttribute(Qt.WA_PaintOnScreen)
>>> -        self.setAttribute(Qt.WA_NativeWindow)
>>> +        self.setAttribute(Qt.WidgetAttribute.WA_PaintOnScreen)
>>> +        self.setAttribute(Qt.WidgetAttribute.WA_NativeWindow)
>>>
>>>           self.state = state
>>>
>

Patch
diff mbox series

diff --git a/src/py/cam/cam_qt.py b/src/py/cam/cam_qt.py
index c1723b44..22d8c4da 100644
--- a/src/py/cam/cam_qt.py
+++ b/src/py/cam/cam_qt.py
@@ -2,7 +2,7 @@ 
 # Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
 
 from helpers import mfb_to_rgb
-from PyQt5 import QtCore, QtGui, QtWidgets
+from PyQt6 import QtCore, QtGui, QtWidgets
 import libcamera as libcam
 import libcamera.utils
 import sys
@@ -63,10 +63,10 @@  class QtRenderer:
         self.buf_mmap_map = buf_mmap_map
 
     def run(self):
-        camnotif = QtCore.QSocketNotifier(self.cm.event_fd, QtCore.QSocketNotifier.Read)
+        camnotif = QtCore.QSocketNotifier(self.cm.event_fd, QtCore.QSocketNotifier.Type.Read)
         camnotif.activated.connect(lambda _: self.readcam())
 
-        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Read)
+        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Type.Read)
         keynotif.activated.connect(lambda _: self.readkey())
 
         print('Capturing...')
diff --git a/src/py/cam/cam_qtgl.py b/src/py/cam/cam_qtgl.py
index 6cfbd347..35b4b06b 100644
--- a/src/py/cam/cam_qtgl.py
+++ b/src/py/cam/cam_qtgl.py
@@ -1,8 +1,8 @@ 
 # SPDX-License-Identifier: GPL-2.0-or-later
 # Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
 
-from PyQt5 import QtCore, QtWidgets
-from PyQt5.QtCore import Qt
+from PyQt6 import QtCore, QtWidgets
+from PyQt6.QtCore import Qt
 
 import math
 import os
@@ -142,10 +142,10 @@  class QtRenderer:
         self.window = window
 
     def run(self):
-        camnotif = QtCore.QSocketNotifier(self.state.cm.event_fd, QtCore.QSocketNotifier.Read)
+        camnotif = QtCore.QSocketNotifier(self.state.cm.event_fd, QtCore.QSocketNotifier.Type.Read)
         camnotif.activated.connect(lambda _: self.readcam())
 
-        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Read)
+        keynotif = QtCore.QSocketNotifier(sys.stdin.fileno(), QtCore.QSocketNotifier.Type.Read)
         keynotif.activated.connect(lambda _: self.readkey())
 
         print('Capturing...')
@@ -175,8 +175,8 @@  class MainWindow(QtWidgets.QWidget):
     def __init__(self, state):
         super().__init__()
 
-        self.setAttribute(Qt.WA_PaintOnScreen)
-        self.setAttribute(Qt.WA_NativeWindow)
+        self.setAttribute(Qt.WidgetAttribute.WA_PaintOnScreen)
+        self.setAttribute(Qt.WidgetAttribute.WA_NativeWindow)
 
         self.state = state