3030import sys
3131
3232from 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
3434
3535
3636# matplotlib stores the baseline images under two separate subtrees,
@@ -62,13 +62,13 @@ def __init__(self, parent, index, name):
6262 layout = QtWidgets .QVBoxLayout ()
6363
6464 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 )
6767 layout .addWidget (label , 0 )
6868
6969 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 )
7272 self .image .setMinimumSize (800 // 3 , 600 // 3 )
7373 layout .addWidget (self .image )
7474 self .setLayout (layout )
@@ -86,7 +86,7 @@ def __init__(self, window):
8686 self .window = window
8787
8888 def eventFilter (self , receiver , event ):
89- if event .type () == _enum ( ' QtCore.QEvent.Type' ) .KeyPress :
89+ if event .type () == QtCore .QEvent .Type .KeyPress :
9090 self .window .keyPressEvent (event )
9191 return True
9292 else :
@@ -127,8 +127,8 @@ def __init__(self, entries):
127127 images_box = QtWidgets .QWidget ()
128128 self .image_display = QtWidgets .QLabel ()
129129 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 )
132132 self .image_display .setMinimumSize (800 , 600 )
133133 images_layout .addWidget (self .image_display , 6 )
134134 images_box .setLayout (images_layout )
@@ -167,8 +167,8 @@ def set_entry(self, index):
167167 pixmap = QtGui .QPixmap (os .fspath (fname ))
168168 scaled_pixmap = pixmap .scaled (
169169 thumbnail .size (),
170- _enum ( ' QtCore.Qt.AspectRatioMode' ) .KeepAspectRatio ,
171- _enum ( ' QtCore.Qt.TransformationMode' ) .SmoothTransformation )
170+ QtCore .Qt .AspectRatioMode .KeepAspectRatio ,
171+ QtCore .Qt .TransformationMode .SmoothTransformation )
172172 thumbnail .image .setPixmap (scaled_pixmap )
173173 self .pixmaps .append (scaled_pixmap )
174174
@@ -177,14 +177,14 @@ def set_entry(self, index):
177177
178178 def set_large_image (self , index ):
179179 self .thumbnails [self .current_thumbnail ].setFrameShape (
180- _enum ( ' QtWidgets.QFrame.Shape' ) .NoFrame )
180+ QtWidgets .QFrame .Shape .NoFrame )
181181 self .current_thumbnail = index
182182 pixmap = QtGui .QPixmap (os .fspath (
183183 self .entries [self .current_entry ]
184184 .thumbnails [self .current_thumbnail ]))
185185 self .image_display .setPixmap (pixmap )
186186 self .thumbnails [self .current_thumbnail ].setFrameShape (
187- _enum ( ' QtWidgets.QFrame.Shape' ) .Box )
187+ QtWidgets .QFrame .Shape .Box )
188188
189189 def accept_test (self ):
190190 entry = self .entries [self .current_entry ]
@@ -209,17 +209,17 @@ def reject_test(self):
209209 self .set_entry (min ((self .current_entry + 1 ), len (self .entries ) - 1 ))
210210
211211 def keyPressEvent (self , e ):
212- if e .key () == _enum ( ' QtCore.Qt.Key' ) .Key_Left :
212+ if e .key () == QtCore .Qt .Key .Key_Left :
213213 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 :
215215 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 :
217217 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 :
219219 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 :
221221 self .accept_test ()
222- elif e .key () == _enum ( ' QtCore.Qt.Key' ) .Key_R :
222+ elif e .key () == QtCore .Qt .Key .Key_R :
223223 self .reject_test ()
224224 else :
225225 super ().keyPressEvent (e )
0 commit comments