Title: FigureCanvasWx/Agg fixed size by DietmarSchwertberger · Pull Request #10377 · matplotlib/matplotlib · GitHub
Open Graph Title: FigureCanvasWx/Agg fixed size by DietmarSchwertberger · Pull Request #10377 · matplotlib/matplotlib
X Title: FigureCanvasWx/Agg fixed size by DietmarSchwertberger · Pull Request #10377 · matplotlib/matplotlib
Description: PR Summary (replacement for PR #10153) The embedded FigureCanvasWx currently can't be set to a fixed size. When it is added to a sizer with proportion=0 and wx.EXPAND not set, then it will not expand over it's defined size, as expected. But when the visible area is reduced below the defined size, it will re-scale itself to fit the visible area because 'self.GetClientSize()' is used to read the size. This could happen if the window size is reduced or a splitter is used. When placed on a scrolled window, the problem does not occur, as then the VirtualSize will not change, even when the widget is not 100% visible. This is not a big issue as the behaviour can easily be modified in a derived class. It would be nice though, to have the correct behaviour by default. See attached file embedding_in_wx4_fixed.py for an example. With the modification from the pull request the size will stay fixed. The only change is the sizer.Add call with proportion=0 and without EXPAND: self.figure = Figure(figsize=(5, 4), dpi=100) ... self.canvas = FigureCanvas(self, -1, self.figure) self.sizer = wx.BoxSizer(wx.VERTICAL) #self.sizer.Add(self.canvas, 1, wx.TOP | wx.LEFT | wx.EXPAND) self.sizer.Add(self.canvas, 0, wx.TOP | wx.LEFT) embedding_in_wx4_fixed.py.txt I could commit the example file, but that's probably not worth it. If the canvas is directly used as single child of a frame (i.e. instead of a panel), the behaviour is not modified by the pull request. This could be changed, but I don't see a use case for this. Btw.: I just noticed that the embedding_in_wx4.py example includes an EVT_PAINT handler. I don't think that this is required, as the plot is static. Instead, it causes unnecessary renderings. Also, the structure of fourier_demo_wx.py is a bit unusual. The usual hierarchy would be Frame->Panel->Sizer->Canvas. Actually it's now Frame->Sizer->Window->Canvas where the Window does not have any function and the sliders are drawn on the plain frame background. I could submit a PR to update the demos, if desired. PR Checklist Has Pytest style unit tests Code is PEP 8 compliant New features are documented, with examples if plot related Documentation is sphinx and numpydoc compliant Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there) Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way
Open Graph Description: PR Summary (replacement for PR #10153) The embedded FigureCanvasWx currently can't be set to a fixed size. When it is added to a sizer with proportion=0 and wx.EXPAND not set, then it will not ...
X Description: PR Summary (replacement for PR #10153) The embedded FigureCanvasWx currently can't be set to a fixed size. When it is added to a sizer with proportion=0 and wx.EXPAND not set, then it will ...
Opengraph URL: https://github.com/matplotlib/matplotlib/pull/10377
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:05ffb4a0-35e8-5654-bc78-ab331a8d649c |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | A024:3C2AAD:11BEBA0:19AE31C:6A57ADC5 |
| html-safe-nonce | b48e1d9554678ba0f0a2bf5c3b69e7690ba4a845311b1b438aa4f1a3ce1a77af |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMDI0OjNDMkFBRDoxMUJFQkEwOjE5QUUzMUM6NkE1N0FEQzUiLCJ2aXNpdG9yX2lkIjoiMTQ4MDcxMjY4MDI3NzI1NzY2OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 199c38ddb7248609fadf503aca41b2f6d1adb5c3c57a6a5ee5685a792a59c6a7 |
| hovercard-subject-tag | pull_request:167024675 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/matplotlib/matplotlib/pull/10377/files |
| twitter:image | https://avatars.githubusercontent.com/u/5512021?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/5512021?s=400&v=4 |
| og:image:alt | PR Summary (replacement for PR #10153) The embedded FigureCanvasWx currently can't be set to a fixed size. When it is added to a sizer with proportion=0 and wx.EXPAND not set, then it will not ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 017a07c29bdd8a37b5907fc9a689338deb7103b5af7f56714193b2700229b3df |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4cd16a676f89d1cedb932671a5c2d20b8e60f86a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width