jupyter/qtconsole

Changing syntax highlighting style doesn't work with PySide2 & PySide6

firai opened this issue · 1 comments

firai commented

If I try to change the syntax highlighting style when PySide2 or PySide6 is installed, I get the following error. However, changing the style seems to work with PyQt5 and PyQt6.

image

firai commented

I dug into this and found that the error was caused by:

action = QtWidgets.QAction("{}".format(style), self,
triggered=lambda v,
syntax_style=style:
self.set_syntax_style(
syntax_style=syntax_style))

As it turns out, PySide2 and PySide6 do not seem to accept the lambda that was originally used to connect to the triggered signal (https://stackoverflow.com/questions/70203386/lambda-default-value-with-pyside6-events), and partial objects need to be used instead. I tested replacing the lambda with partial objects against all 4 PyQts and PySides, and they seem to all work now.

The proposed fix is at #538.