|
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, __version__, is_pyqt5 |
32 | 32 | from matplotlib.backends.qt_editor.formsubplottool import UiSubplotTool
|
33 | 33 |
|
34 | 34 | backend_version = __version__
|
@@ -139,9 +139,13 @@ def _create_qApp():
|
139 | 139 |
|
140 | 140 | qApp = QtWidgets.QApplication([six.text_type(" ")])
|
141 | 141 | qApp.lastWindowClosed.connect(qApp.quit)
|
| 142 | + |
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):
|
@@ -605,6 +611,15 @@ def _init_toolbar(self):
|
605 | 611 |
|
606 | 612 | # reference holder for subplots_adjust window
|
607 | 613 | self.adj_window = None
|
| 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 | + |
608 | 623 |
|
609 | 624 | if figureoptions is not None:
|
610 | 625 | def edit_parameters(self):
|
|
0 commit comments