File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -243,6 +243,11 @@ def __init__(self, figure):
243
243
w , h = self .get_width_height ()
244
244
self .resize (w , h )
245
245
246
+ def get_width_height (self ):
247
+ dpi_ratio = self .devicePixelRatio ()
248
+ w , h = FigureCanvasBase .get_width_height (self )
249
+ return int (w / dpi_ratio ), int (h / dpi_ratio )
250
+
246
251
def enterEvent (self , event ):
247
252
FigureCanvasBase .enter_notify_event (self , guiEvent = event )
248
253
@@ -320,7 +325,7 @@ def keyReleaseEvent(self, event):
320
325
print ('key release' , key )
321
326
322
327
def resizeEvent (self , event ):
323
- dpi_ratio = getattr ( self , '_dpi_ratio' , 1 )
328
+ dpi_ratio = self . devicePixelRatio ( )
324
329
w = event .size ().width () * dpi_ratio
325
330
h = event .size ().height () * dpi_ratio
326
331
if DEBUG :
Original file line number Diff line number Diff line change @@ -229,6 +229,11 @@ def __init__(self, figure):
229
229
self ._drawRect = None
230
230
self .blitbox = []
231
231
self ._dpi_ratio = self .devicePixelRatio ()
232
+ # We don't want to scale up the figure DPI more than once.
233
+ # Note, we don't handle a signal for changing DPI yet.
234
+ if not hasattr (self .figure , '_original_dpi' ):
235
+ self .figure ._original_dpi = self .figure .dpi
236
+ self .figure .dpi = self ._dpi_ratio * self .figure ._original_dpi
232
237
self .setAttribute (QtCore .Qt .WA_OpaquePaintEvent )
233
238
234
239
You can’t perform that action at this time.
0 commit comments