14
14
from . import qt_compat
15
15
from .qt_compat import (
16
16
QtCore , QtGui , QtWidgets , __version__ , QT_API ,
17
- _enum , _to_int , _isdeleted , _maybe_allow_interrupt
17
+ _to_int , _isdeleted , _maybe_allow_interrupt
18
18
)
19
19
20
20
21
21
# SPECIAL_KEYS are Qt::Key that do *not* return their Unicode name
22
22
# instead they have manually specified names.
23
23
SPECIAL_KEYS = {
24
- _to_int (getattr (_enum ( " QtCore.Qt.Key" ) , k )): v for k , v in [
24
+ _to_int (getattr (QtCore .Qt .Key , k )): v for k , v in [
25
25
("Key_Escape" , "escape" ),
26
26
("Key_Tab" , "tab" ),
27
27
("Key_Backspace" , "backspace" ),
66
66
# Elements are (Qt::KeyboardModifiers, Qt::Key) tuples.
67
67
# Order determines the modifier order (ctrl+alt+...) reported by Matplotlib.
68
68
_MODIFIER_KEYS = [
69
- (_to_int (getattr (_enum ( " QtCore.Qt.KeyboardModifier" ) , mod )),
70
- _to_int (getattr (_enum ( " QtCore.Qt.Key" ) , key )))
69
+ (_to_int (getattr (QtCore .Qt .KeyboardModifier , mod )),
70
+ _to_int (getattr (QtCore .Qt .Key , key )))
71
71
for mod , key in [
72
72
("ControlModifier" , "Key_Control" ),
73
73
("AltModifier" , "Key_Alt" ),
76
76
]
77
77
]
78
78
cursord = {
79
- k : getattr (_enum ( " QtCore.Qt.CursorShape" ) , v ) for k , v in [
79
+ k : getattr (QtCore .Qt .CursorShape , v ) for k , v in [
80
80
(cursors .MOVE , "SizeAllCursor" ),
81
81
(cursors .HAND , "PointingHandCursor" ),
82
82
(cursors .POINTER , "ArrowCursor" ),
@@ -142,7 +142,6 @@ def _create_qApp():
142
142
app .setWindowIcon (icon )
143
143
app .lastWindowClosed .connect (app .quit )
144
144
cbook ._setup_new_guiapp ()
145
-
146
145
if qt_version == 5 :
147
146
app .setAttribute (QtCore .Qt .AA_UseHighDpiPixmaps )
148
147
@@ -184,7 +183,7 @@ class FigureCanvasQT(FigureCanvasBase, QtWidgets.QWidget):
184
183
manager_class = _api .classproperty (lambda cls : FigureManagerQT )
185
184
186
185
buttond = {
187
- getattr (_enum ( " QtCore.Qt.MouseButton" ) , k ): v for k , v in [
186
+ getattr (QtCore .Qt .MouseButton , k ): v for k , v in [
188
187
("LeftButton" , MouseButton .LEFT ),
189
188
("RightButton" , MouseButton .RIGHT ),
190
189
("MiddleButton" , MouseButton .MIDDLE ),
@@ -202,8 +201,7 @@ def __init__(self, figure=None):
202
201
self ._draw_rect_callback = lambda painter : None
203
202
self ._in_resize_event = False
204
203
205
- self .setAttribute (
206
- _enum ("QtCore.Qt.WidgetAttribute" ).WA_OpaquePaintEvent )
204
+ self .setAttribute (QtCore .Qt .WidgetAttribute .WA_OpaquePaintEvent )
207
205
self .setMouseTracking (True )
208
206
self .resize (* self .get_width_height ())
209
207
@@ -554,7 +552,7 @@ def __init__(self, canvas, num):
554
552
# StrongFocus accepts both tab and click to focus and will enable the
555
553
# canvas to process event without clicking.
556
554
# https://doc.qt.io/qt-5/qt.html#FocusPolicy-enum
557
- self .canvas .setFocusPolicy (_enum ( " QtCore.Qt.FocusPolicy" ) .StrongFocus )
555
+ self .canvas .setFocusPolicy (QtCore .Qt .FocusPolicy .StrongFocus )
558
556
self .canvas .setFocus ()
559
557
560
558
self .window .raise_ ()
@@ -634,9 +632,8 @@ def __init__(self, canvas, parent=None, coordinates=True):
634
632
"""coordinates: should we show the coordinates on the right?"""
635
633
QtWidgets .QToolBar .__init__ (self , parent )
636
634
self .setAllowedAreas (QtCore .Qt .ToolBarArea (
637
- _to_int (_enum ("QtCore.Qt.ToolBarArea" ).TopToolBarArea ) |
638
- _to_int (_enum ("QtCore.Qt.ToolBarArea" ).BottomToolBarArea )))
639
-
635
+ _to_int (QtCore .Qt .ToolBarArea .TopToolBarArea ) |
636
+ _to_int (QtCore .Qt .ToolBarArea .BottomToolBarArea )))
640
637
self .coordinates = coordinates
641
638
self ._actions = {} # mapping of toolitem method names to QActions.
642
639
self ._subplot_dialog = None
@@ -659,11 +656,12 @@ def __init__(self, canvas, parent=None, coordinates=True):
659
656
if self .coordinates :
660
657
self .locLabel = QtWidgets .QLabel ("" , self )
661
658
self .locLabel .setAlignment (QtCore .Qt .AlignmentFlag (
662
- _to_int (_enum ("QtCore.Qt.AlignmentFlag" ).AlignRight ) |
663
- _to_int (_enum ("QtCore.Qt.AlignmentFlag" ).AlignVCenter )))
659
+ _to_int (QtCore .Qt .AlignmentFlag .AlignRight ) |
660
+ _to_int (QtCore .Qt .AlignmentFlag .AlignVCenter )))
661
+
664
662
self .locLabel .setSizePolicy (QtWidgets .QSizePolicy (
665
- _enum ( " QtWidgets.QSizePolicy.Policy" ) .Expanding ,
666
- _enum ( " QtWidgets.QSizePolicy.Policy" ) .Ignored ,
663
+ QtWidgets .QSizePolicy .Policy .Expanding ,
664
+ QtWidgets .QSizePolicy .Policy .Ignored ,
667
665
))
668
666
labelAction = self .addWidget (self .locLabel )
669
667
labelAction .setVisible (True )
@@ -689,7 +687,7 @@ def _icon(self, name):
689
687
icon_color = self .palette ().color (self .foregroundRole ())
690
688
mask = pm .createMaskFromColor (
691
689
QtGui .QColor ('black' ),
692
- _enum ( " QtCore.Qt.MaskMode" ) .MaskOutColor )
690
+ QtCore .Qt .MaskMode .MaskOutColor )
693
691
pm .fill (icon_color )
694
692
pm .setMask (mask )
695
693
return QtGui .QIcon (pm )
@@ -793,8 +791,8 @@ def save_figure(self, *args):
793
791
except Exception as e :
794
792
QtWidgets .QMessageBox .critical (
795
793
self , "Error saving file" , str (e ),
796
- _enum ( " QtWidgets.QMessageBox.StandardButton" ) .Ok ,
797
- _enum ( " QtWidgets.QMessageBox.StandardButton" ) .NoButton )
794
+ QtWidgets .QMessageBox .StandardButton .Ok ,
795
+ QtWidgets .QMessageBox .StandardButton .NoButton )
798
796
799
797
def set_history_buttons (self ):
800
798
can_backward = self ._nav_stack ._pos > 0
@@ -908,15 +906,15 @@ def __init__(self, toolmanager, parent=None):
908
906
ToolContainerBase .__init__ (self , toolmanager )
909
907
QtWidgets .QToolBar .__init__ (self , parent )
910
908
self .setAllowedAreas (QtCore .Qt .ToolBarArea (
911
- _to_int (_enum ( " QtCore.Qt.ToolBarArea" ) .TopToolBarArea ) |
912
- _to_int (_enum ( " QtCore.Qt.ToolBarArea" ) .BottomToolBarArea )))
909
+ _to_int (QtCore .Qt .ToolBarArea .TopToolBarArea ) |
910
+ _to_int (QtCore .Qt .ToolBarArea .BottomToolBarArea )))
913
911
message_label = QtWidgets .QLabel ("" )
914
912
message_label .setAlignment (QtCore .Qt .AlignmentFlag (
915
- _to_int (_enum ( " QtCore.Qt.AlignmentFlag" ) .AlignRight ) |
916
- _to_int (_enum ( " QtCore.Qt.AlignmentFlag" ) .AlignVCenter )))
913
+ _to_int (QtCore .Qt .AlignmentFlag .AlignRight ) |
914
+ _to_int (QtCore .Qt .AlignmentFlag .AlignVCenter )))
917
915
message_label .setSizePolicy (QtWidgets .QSizePolicy (
918
- _enum ( " QtWidgets.QSizePolicy.Policy" ) .Expanding ,
919
- _enum ( " QtWidgets.QSizePolicy.Policy" ) .Ignored ,
916
+ QtWidgets .QSizePolicy .Policy .Expanding ,
917
+ QtWidgets .QSizePolicy .Policy .Ignored ,
920
918
))
921
919
self ._message_action = self .addWidget (message_label )
922
920
self ._toolitems = {}
0 commit comments