|
28 | 28 | except ImportError: |
29 | 29 | figureoptions = None |
30 | 30 |
|
31 | | -from .qt_compat import QtCore, QtGui, QtWidgets, _getSaveFileName, __version__ |
| 31 | +from .qt_compat import (QtCore, QtGui, QtWidgets, _getSaveFileName, |
| 32 | + __version__, is_pyqt5) |
32 | 33 | from matplotlib.backends.qt_editor.formsubplottool import UiSubplotTool |
33 | 34 |
|
34 | 35 | backend_version = __version__ |
@@ -142,6 +143,9 @@ def _create_qApp(): |
142 | 143 | else: |
143 | 144 | qApp = app |
144 | 145 |
|
| 146 | + if is_pyqt5(): |
| 147 | + qApp.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps) |
| 148 | + |
145 | 149 |
|
146 | 150 | class Show(ShowBase): |
147 | 151 | def mainloop(self): |
@@ -566,6 +570,8 @@ def __init__(self, canvas, parent, coordinates=True): |
566 | 570 | NavigationToolbar2.__init__(self, canvas) |
567 | 571 |
|
568 | 572 | def _icon(self, name): |
| 573 | + if is_pyqt5(): |
| 574 | + name = name.replace('.png', '_hidpi.png') |
569 | 575 | return QtGui.QIcon(os.path.join(self.basedir, name)) |
570 | 576 |
|
571 | 577 | def _init_toolbar(self): |
@@ -606,6 +612,14 @@ def _init_toolbar(self): |
606 | 612 | # reference holder for subplots_adjust window |
607 | 613 | self.adj_window = None |
608 | 614 |
|
| 615 | + # Esthetic adjustments - we need to set these explicitly in PyQt5 |
| 616 | + # otherwise the layout looks different - but we don't want to set it if |
| 617 | + # not using HiDPI icons otherwise they look worse than before. |
| 618 | + if is_pyqt5(): |
| 619 | + self.setIconSize(QtCore.QSize(24, 24)) |
| 620 | + self.layout().setSpacing(12) |
| 621 | + self.setMinimumHeight(48) |
| 622 | + |
609 | 623 | if figureoptions is not None: |
610 | 624 | def edit_parameters(self): |
611 | 625 | allaxes = self.canvas.figure.get_axes() |
|
0 commit comments