From d0b92349ddfde42f5261c78d610cc655216eea62 Mon Sep 17 00:00:00 2001 From: Gabriel Linder Date: Sun, 8 Mar 2020 10:34:54 +0100 Subject: [PATCH] Intercept light/dark modes transitions on MacOS. --- examples/__main__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/__main__.py b/examples/__main__.py index 22dd7ef0..df390cb9 100644 --- a/examples/__main__.py +++ b/examples/__main__.py @@ -44,8 +44,9 @@ class ExampleLoader(QtGui.QMainWindow): self.codeBtn = QtGui.QPushButton('Run Edited Code') self.codeLayout = QtGui.QGridLayout() self.ui.codeView.setLayout(self.codeLayout) - #self.simulate_black_mode() self.hl = PythonHighlighter(self.ui.codeView.document()) + app = QtGui.QApplication.instance() + app.paletteChanged.connect(self.updateTheme) self.codeLayout.addItem(QtGui.QSpacerItem(100,100,QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding), 0, 0) self.codeLayout.addWidget(self.codeBtn, 1, 1) self.codeBtn.hide() @@ -83,6 +84,9 @@ class ExampleLoader(QtGui.QMainWindow): app = QtGui.QApplication.instance() app.dark_mode = True + def updateTheme(self): + self.hl = PythonHighlighter(self.ui.codeView.document()) + def populateTree(self, root, examples): for key, val in examples.items(): item = QtGui.QTreeWidgetItem([key])