Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bd6fc99

Browse files
authored
Merge pull request matplotlib#17562 from meeseeksmachine/auto-backport-of-pr-17470-on-v3.2.x
Backport PR matplotlib#17470 on branch v3.2.x (FIX: add guardrails for too big tk figures)
2 parents 3e98746 + 04a55eb commit bd6fc99

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/matplotlib/backends/_backend_tk.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,17 @@ def _get_toolmanager(self):
460460
return toolmanager
461461

462462
def resize(self, width, height):
463+
max_size = 1_400_000 # the measured max on xorg 1.20.8 was 1_409_023
464+
465+
if (width > max_size or height > max_size) and sys.platform == 'linux':
466+
raise ValueError(
467+
'You have requested to resize the '
468+
f'Tk window to ({width}, {height}), one of which '
469+
f'is bigger than {max_size}. At larger sizes xorg will '
470+
'either exit with an error on newer versions (~1.20) or '
471+
'cause corruption on older version (~1.19). We '
472+
'do not expect a window over a million pixel wide or tall '
473+
'to be intended behavior.')
463474
self.canvas._tkcanvas.configure(width=width, height=height)
464475

465476
def show(self):

0 commit comments

Comments
 (0)