jupyter / qtconsole

Jupyter Qt Console
https://qtconsole.readthedocs.io/en/stable/
BSD 3-Clause "New" or "Revised" License
413 stars 199 forks source link

Horizontal scrolling not updated until wndow resize event #599

Open hrdl-github opened 9 months ago

hrdl-github commented 9 months ago

Wide figures (e.g. produced using import matplotlib.pyplot as plt; plt.figure(dpi=300); plt.plot([1,2,3])) are truncated when the window is narrow enough. Resizing the window causes the horizontal scrollbar to appear / be updated. Horizontal scrolling allows the entire figure to be viewed then.

qtconsole version: 5.5.1

ccordoba12 commented 5 months ago

Hey @hrdl-github, thanks for reporting. I also think it's important to fix this issue but I don't have time to take a look at it.

Could you try to solve it to see how hard it is?

hrdl-github commented 5 months ago

I don't know enough about GUI frameworks to make sense of this. Apparently both the vertical scroll bar's visibility policy and whether we update the vertical scrollbar's range influence whether the horizontal scrollbar behaves as expected.

Removing https://github.com/jupyter/qtconsole/blob/56e5a5ec5cfccf5afd098fe8bb5b2c558a1dc8f9/qtconsole/console_widget.py#L2556 while setting control.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) seems to work. Doing the former with any other value or not explicitly setting affects prevents both scrollbars from being displayed.

Also, calling e.g. self._control.horizontalScrollBar().setRange(0, 10) in adjust_scrollbars() will cause this function to be called infinitely often.

hrdl-github commented 5 months ago

Under certain conditions this breaks vertical scrolling, so it's more of a starting point to investigate what goes wrong.