Skip to content

Commit

Permalink
Work around PySide2 incompatibility with Python 3.10.
Browse files Browse the repository at this point in the history
  • Loading branch information
QuLogic committed Aug 20, 2021
1 parent c2f83ec commit ce84623
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
24 changes: 12 additions & 12 deletions lib/matplotlib/backends/backend_qt.py
Expand Up @@ -626,9 +626,9 @@ class NavigationToolbar2QT(NavigationToolbar2, QtWidgets.QToolBar):
def __init__(self, canvas, parent, coordinates=True):
"""coordinates: should we show the coordinates on the right?"""
QtWidgets.QToolBar.__init__(self, parent)
self.setAllowedAreas(
_enum("QtCore.Qt.ToolBarArea").TopToolBarArea
| _enum("QtCore.Qt.ToolBarArea").TopToolBarArea)
self.setAllowedAreas(QtCore.Qt.ToolBarArea(
_to_int(_enum("QtCore.Qt.ToolBarArea").TopToolBarArea) |
_to_int(_enum("QtCore.Qt.ToolBarArea").BottomToolBarArea)))

self.coordinates = coordinates
self._actions = {} # mapping of toolitem method names to QActions.
Expand All @@ -651,9 +651,9 @@ def __init__(self, canvas, parent, coordinates=True):
# will resize this label instead of the buttons.
if self.coordinates:
self.locLabel = QtWidgets.QLabel("", self)
self.locLabel.setAlignment(
_enum("QtCore.Qt.AlignmentFlag").AlignRight
| _enum("QtCore.Qt.AlignmentFlag").AlignVCenter)
self.locLabel.setAlignment(QtCore.Qt.AlignmentFlag(
_to_int(_enum("QtCore.Qt.AlignmentFlag").AlignRight) |
_to_int(_enum("QtCore.Qt.AlignmentFlag").AlignVCenter)))
self.locLabel.setSizePolicy(QtWidgets.QSizePolicy(
_enum("QtWidgets.QSizePolicy.Policy").Expanding,
_enum("QtWidgets.QSizePolicy.Policy").Ignored,
Expand Down Expand Up @@ -883,13 +883,13 @@ class ToolbarQt(ToolContainerBase, QtWidgets.QToolBar):
def __init__(self, toolmanager, parent):
ToolContainerBase.__init__(self, toolmanager)
QtWidgets.QToolBar.__init__(self, parent)
self.setAllowedAreas(
_enum("QtCore.Qt.ToolBarArea").TopToolBarArea
| _enum("QtCore.Qt.ToolBarArea").TopToolBarArea)
self.setAllowedAreas(QtCore.Qt.ToolBarArea(
_to_int(_enum("QtCore.Qt.ToolBarArea").TopToolBarArea) |
_to_int(_enum("QtCore.Qt.ToolBarArea").BottomToolBarArea)))
message_label = QtWidgets.QLabel("")
message_label.setAlignment(
_enum("QtCore.Qt.AlignmentFlag").AlignRight
| _enum("QtCore.Qt.AlignmentFlag").AlignVCenter)
message_label.setAlignment(QtCore.Qt.AlignmentFlag(
_to_int(_enum("QtCore.Qt.AlignmentFlag").AlignRight) |
_to_int(_enum("QtCore.Qt.AlignmentFlag").AlignVCenter)))
message_label.setSizePolicy(QtWidgets.QSizePolicy(
_enum("QtWidgets.QSizePolicy.Policy").Expanding,
_enum("QtWidgets.QSizePolicy.Policy").Ignored,
Expand Down
10 changes: 7 additions & 3 deletions lib/matplotlib/backends/qt_editor/_formlayout.py
Expand Up @@ -48,7 +48,7 @@

from matplotlib import _api, colors as mcolors
from .. import qt_compat
from ..qt_compat import QtGui, QtWidgets, QtCore, _enum
from ..qt_compat import QtGui, QtWidgets, QtCore, _enum, _to_int

_log = logging.getLogger(__name__)

Expand Down Expand Up @@ -441,8 +441,12 @@ def __init__(self, data, title="", comment="",

# Button box
self.bbox = bbox = QtWidgets.QDialogButtonBox(
_enum("QtWidgets.QDialogButtonBox.StandardButton").Ok
| _enum("QtWidgets.QDialogButtonBox.StandardButton").Cancel)
QtWidgets.QDialogButtonBox.StandardButton(
_to_int(
_enum("QtWidgets.QDialogButtonBox.StandardButton").Ok) |
_to_int(
_enum("QtWidgets.QDialogButtonBox.StandardButton").Cancel)
))
self.formwidget.update_buttons.connect(self.update_buttons)
if self.apply_callback is not None:
apply_btn = bbox.addButton(
Expand Down

0 comments on commit ce84623

Please sign in to comment.