30
30
import sys
31
31
32
32
from matplotlib .backends .qt_compat import QtCore , QtGui , QtWidgets
33
- from matplotlib .backends .qt_compat import _enum , _exec
33
+ from matplotlib .backends .qt_compat import _exec
34
34
35
35
36
36
# matplotlib stores the baseline images under two separate subtrees,
@@ -62,13 +62,13 @@ def __init__(self, parent, index, name):
62
62
layout = QtWidgets .QVBoxLayout ()
63
63
64
64
label = QtWidgets .QLabel (name )
65
- label .setAlignment (_enum ( ' QtCore.Qt.AlignmentFlag' ) .AlignHCenter |
66
- _enum ( ' QtCore.Qt.AlignmentFlag' ) .AlignVCenter )
65
+ label .setAlignment (QtCore .Qt .AlignmentFlag .AlignHCenter |
66
+ QtCore .Qt .AlignmentFlag .AlignVCenter )
67
67
layout .addWidget (label , 0 )
68
68
69
69
self .image = QtWidgets .QLabel ()
70
- self .image .setAlignment (_enum ( ' QtCore.Qt.AlignmentFlag' ) .AlignHCenter |
71
- _enum ( ' QtCore.Qt.AlignmentFlag' ) .AlignVCenter )
70
+ self .image .setAlignment (QtCore .Qt .AlignmentFlag .AlignHCenter |
71
+ QtCore .Qt .AlignmentFlag .AlignVCenter )
72
72
self .image .setMinimumSize (800 // 3 , 600 // 3 )
73
73
layout .addWidget (self .image )
74
74
self .setLayout (layout )
@@ -86,7 +86,7 @@ def __init__(self, window):
86
86
self .window = window
87
87
88
88
def eventFilter (self , receiver , event ):
89
- if event .type () == _enum ( ' QtCore.QEvent.Type' ) .KeyPress :
89
+ if event .type () == QtCore .QEvent .Type .KeyPress :
90
90
self .window .keyPressEvent (event )
91
91
return True
92
92
else :
@@ -127,8 +127,8 @@ def __init__(self, entries):
127
127
images_box = QtWidgets .QWidget ()
128
128
self .image_display = QtWidgets .QLabel ()
129
129
self .image_display .setAlignment (
130
- _enum ( ' QtCore.Qt.AlignmentFlag' ) .AlignHCenter |
131
- _enum ( ' QtCore.Qt.AlignmentFlag' ) .AlignVCenter )
130
+ QtCore .Qt .AlignmentFlag .AlignHCenter |
131
+ QtCore .Qt .AlignmentFlag .AlignVCenter )
132
132
self .image_display .setMinimumSize (800 , 600 )
133
133
images_layout .addWidget (self .image_display , 6 )
134
134
images_box .setLayout (images_layout )
@@ -167,8 +167,8 @@ def set_entry(self, index):
167
167
pixmap = QtGui .QPixmap (os .fspath (fname ))
168
168
scaled_pixmap = pixmap .scaled (
169
169
thumbnail .size (),
170
- _enum ( ' QtCore.Qt.AspectRatioMode' ) .KeepAspectRatio ,
171
- _enum ( ' QtCore.Qt.TransformationMode' ) .SmoothTransformation )
170
+ QtCore .Qt .AspectRatioMode .KeepAspectRatio ,
171
+ QtCore .Qt .TransformationMode .SmoothTransformation )
172
172
thumbnail .image .setPixmap (scaled_pixmap )
173
173
self .pixmaps .append (scaled_pixmap )
174
174
@@ -177,14 +177,14 @@ def set_entry(self, index):
177
177
178
178
def set_large_image (self , index ):
179
179
self .thumbnails [self .current_thumbnail ].setFrameShape (
180
- _enum ( ' QtWidgets.QFrame.Shape' ) .NoFrame )
180
+ QtWidgets .QFrame .Shape .NoFrame )
181
181
self .current_thumbnail = index
182
182
pixmap = QtGui .QPixmap (os .fspath (
183
183
self .entries [self .current_entry ]
184
184
.thumbnails [self .current_thumbnail ]))
185
185
self .image_display .setPixmap (pixmap )
186
186
self .thumbnails [self .current_thumbnail ].setFrameShape (
187
- _enum ( ' QtWidgets.QFrame.Shape' ) .Box )
187
+ QtWidgets .QFrame .Shape .Box )
188
188
189
189
def accept_test (self ):
190
190
entry = self .entries [self .current_entry ]
@@ -209,17 +209,17 @@ def reject_test(self):
209
209
self .set_entry (min ((self .current_entry + 1 ), len (self .entries ) - 1 ))
210
210
211
211
def keyPressEvent (self , e ):
212
- if e .key () == _enum ( ' QtCore.Qt.Key' ) .Key_Left :
212
+ if e .key () == QtCore .Qt .Key .Key_Left :
213
213
self .set_large_image ((self .current_thumbnail - 1 ) % 3 )
214
- elif e .key () == _enum ( ' QtCore.Qt.Key' ) .Key_Right :
214
+ elif e .key () == QtCore .Qt .Key .Key_Right :
215
215
self .set_large_image ((self .current_thumbnail + 1 ) % 3 )
216
- elif e .key () == _enum ( ' QtCore.Qt.Key' ) .Key_Up :
216
+ elif e .key () == QtCore .Qt .Key .Key_Up :
217
217
self .set_entry (max (self .current_entry - 1 , 0 ))
218
- elif e .key () == _enum ( ' QtCore.Qt.Key' ) .Key_Down :
218
+ elif e .key () == QtCore .Qt .Key .Key_Down :
219
219
self .set_entry (min (self .current_entry + 1 , len (self .entries ) - 1 ))
220
- elif e .key () == _enum ( ' QtCore.Qt.Key' ) .Key_A :
220
+ elif e .key () == QtCore .Qt .Key .Key_A :
221
221
self .accept_test ()
222
- elif e .key () == _enum ( ' QtCore.Qt.Key' ) .Key_R :
222
+ elif e .key () == QtCore .Qt .Key .Key_R :
223
223
self .reject_test ()
224
224
else :
225
225
super ().keyPressEvent (e )
0 commit comments