Skip to content

tk window immediately resizes down to zero-height upon showing up. #16926

Closed

Description

@anntzer

Bug report

Bug summary

tk window (whether tkagg or mplcairo.tk) immediately resizes down to zero-height upon showing up.

Code for reproduction

$ MPLBACKEND=tkagg python -c "from pylab import *; plot(); show()"

Actual outcome

As described above.

Expected outcome

Window stays at original size.

Matplotlib version

  • Operating system: arch linux
  • Matplotlib version: master
  • Matplotlib backend (print(matplotlib.get_backend())): tkany
  • Python version: 38
  • Jupyter version (if applicable):
  • Other libraries:

This bisects to #16828 (attn @QuLogic), even though it's not clear how that's related... perhaps the dynamic changes to figure dpi confuse tk, but it's not clear why this is different from before?

Activity

  1. added
    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
    on Mar 26, 2020
  2. added this to the v3.3.0 milestone on Mar 26, 2020
  3. changed the title [-]tkagg [/-] [+]tk window immediately resizes down to zero-height upon showing up.[/+] on Mar 26, 2020
  4. QuLogic commented on Mar 27, 2020

    @QuLogic
    Member

    I'm guessing this is related to the flaky test on AppVeyor. The only thing that's hit by that test is the fix to Text.get_window_extent: https://github.com/matplotlib/matplotlib/pull/16828/files#diff-15e8fbe2a4d40deb738e8627eba02318L894

    My best guess is that figure.dpi has never been correctly set, and it's been relying on this accidental change to do so.

  5. QuLogic commented on Mar 27, 2020

    @QuLogic
    Member

    So it seems that's not it, as I can never trigger a case where dpi is not None, but self.figure.dpi is None (or something other than dpi). The strange thing is that if I print out all the properties that would be changed in Figure._set_dpi, nothing changes. So neither the forward call to Figure.set_size_inches (which might hit the canvas/toolbar size), nor the callbacks for the dpi_changed event do this. Yet somehow on a later call, the size is smaller...

    There's definitely something else weird going on; if you add an extra dpi changed on the old code:

    MPLBACKEND=tkagg python -c "from pylab import *; plot(); gcf().dpi=100; show()"
    

    then there will be one call to Figure.set_size_inches with [6.4 4.46], but it magically fixes itself. I'm guessing what happens is that since the dpi change in the Text.get_window_extent is part of the draw/stale mechanism, it is enough to propagate that height change.

  6. FBIShowYourHand commented on Mar 27, 2020

    @FBIShowYourHand

    a question about how to use Chinese,when I want to show Chinese,it always shows me errors,thanks

  7. added a commit that references this issue on Mar 27, 2020
    1b82a96
  8. modified the milestones: v3.3.0, v3.2.2 on Mar 27, 2020
  9. tacaswell commented on Mar 27, 2020

    @tacaswell
    Member

    was #16828 backported to the v3.2.x branch?

  10. tacaswell commented on Mar 27, 2020

    @tacaswell
    Member

    Ah, I understand now, not a regression on 3.2.x, but was backported there because it fixed some other bugs.

  11. QuLogic commented on Mar 28, 2020

    @QuLogic
    Member

    You're right though; this bug was never in 3.2, so this issue shouldn't be tagged on it.

  12. modified the milestones: v3.2.2, v3.3.0 on Mar 28, 2020
  13. added a commit that references this issue on Apr 6, 2020
    deadb3d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    GUI: tkRelease criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions