Skip to content

Commit

Permalink
Use qdarkstyle package for older versions of PyQt
Browse files Browse the repository at this point in the history
  • Loading branch information
rayosborn committed Oct 3, 2023
1 parent 584aea4 commit 9994141
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
3 changes: 0 additions & 3 deletions src/nexpy/gui/plotview.py
Original file line number Diff line number Diff line change
Expand Up @@ -3902,9 +3902,6 @@ def __init__(self, canvas, parent=None, coordinates=True):
labelAction.setVisible(True)

NavigationToolbar2.__init__(self, canvas)
if in_dark_mode() and (
parse_version(QtCore.__version__) <= parse_version('5.15')):
self.setStyleSheet('color: black')
self.plotview = canvas.parent()
self.zoom()

Expand Down
15 changes: 9 additions & 6 deletions src/nexpy/gui/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
from matplotlib import rcParams
from matplotlib.colors import colorConverter, hex2color, rgb2hex
from pkg_resources import parse_version
from qdarkstyle import load_stylesheet
from qdarkstyle.dark.palette import DarkPalette
from qdarkstyle.light.palette import LightPalette

from .pyqt import QtCore, QtWidgets

Expand All @@ -41,8 +44,8 @@
fabio = None

from nexusformat.nexus import (NeXusError, NXcollection, NXdata, NXfield,
NXLock, NXLockException, NXnote,
nxgetconfig, nxload, nxsetconfig)
NXLock, NXLockException, NXnote, nxgetconfig,
nxload, nxsetconfig)

ansi_re = re.compile(r'\x1b' + r'\[([\dA-Fa-f;]*?)m')

Expand Down Expand Up @@ -737,18 +740,18 @@ def define_mode(mode=None):
if mode == 'Dark':
_mainwindow.console.set_default_style('linux')
if legacy_pyqt:
_mainwindow.statusBar().setStyleSheet('color: black')
_mainwindow.app.app.setStyleSheet(load_stylesheet(DarkPalette))
else:
_mainwindow.console.set_default_style()
if legacy_pyqt:
_mainwindow.app.app.setStyleSheet(load_stylesheet(LightPalette))

for dialog in _mainwindow.dialogs:
if dialog.windowTitle() == 'Script Editor':
for tab in [dialog.tabs[t] for t in dialog.tabs]:
tab.define_style()
elif dialog.windowTitle().startswith('Log File'):
dialog.format_log()
if legacy_pyqt:
for plotview in _mainwindow.plotviews.values():
plotview.otab.setStyleSheet('color: black')


class NXListener(QtCore.QObject):
Expand Down

0 comments on commit 9994141

Please sign in to comment.