From 87911febf17309434a761f3e98fbea29ad60f572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Gosselin?= Date: Mon, 11 Nov 2019 22:00:47 -0500 Subject: [PATCH 1/2] HTMLDelegate: Pass widget to drawControl --- spyder/widgets/helperwidgets.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spyder/widgets/helperwidgets.py b/spyder/widgets/helperwidgets.py index 013414af943..dc6aa599b91 100644 --- a/spyder/widgets/helperwidgets.py +++ b/spyder/widgets/helperwidgets.py @@ -127,11 +127,11 @@ def _prepare_text_document(self, option, index): def paint(self, painter, option, index): options, doc = self._prepare_text_document(option, index) - style = (QApplication.style() if options.widget is None - else options.widget.style()) - + widget = QApplication if options.widget is None else options.widget + style = widget.style() options.text = "" - style.drawControl(QStyle.CE_ItemViewItem, options, painter) + style.drawControl(QStyle.CE_ItemViewItem, options, painter, + options.widget) ctx = QAbstractTextDocumentLayout.PaintContext() From 719fc5cfe24be8038637d4a5a9e9caf59c0ebb3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Gosselin?= Date: Mon, 11 Nov 2019 22:32:37 -0500 Subject: [PATCH 2/2] Pass instance of QApplication instead of QApplication --- spyder/widgets/helperwidgets.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spyder/widgets/helperwidgets.py b/spyder/widgets/helperwidgets.py index dc6aa599b91..aff7b8493fa 100644 --- a/spyder/widgets/helperwidgets.py +++ b/spyder/widgets/helperwidgets.py @@ -110,6 +110,7 @@ class HTMLDelegate(QStyledItemDelegate): Taken from https://stackoverflow.com/a/5443112/2399799 """ + def __init__(self, parent, margin=0): super(HTMLDelegate, self).__init__(parent) self._margin = margin @@ -127,7 +128,8 @@ def _prepare_text_document(self, option, index): def paint(self, painter, option, index): options, doc = self._prepare_text_document(option, index) - widget = QApplication if options.widget is None else options.widget + widget = (QApplication.instance() if options.widget is None + else options.widget) style = widget.style() options.text = "" style.drawControl(QStyle.CE_ItemViewItem, options, painter,