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

Skip to content

FIX: add guardrails for too big tk figures #17470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/matplotlib/backends/_backend_tk.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,17 @@ def _get_toolbar(self):
return toolbar

def resize(self, width, height):
max_size = 1_400_000 # the measured max on xorg 1.20.8 was 1_409_023

if (width > max_size or height > max_size) and sys.platform == 'linux':
raise ValueError(
'You have requested to resize the '
f'Tk window to ({width}, {height}), one of which '
f'is bigger than {max_size}. At larger sizes xorg will '
'either exit with an error on newer versions (~1.20) or '
'cause corruption on older version (~1.19). We '
'do not expect a window over a million pixel wide or tall '
'to be intended behavior.')
self.canvas._tkcanvas.configure(width=width, height=height)

def show(self):
Expand Down