Closed ethical-haquer closed 2 months ago
I have this, but It's not quite correct:
font = tkinter.font.Font(name="TkFixedFont", exists=True)
# Use previous height as long as it's not less than two lines high,
# otherwise set height to two lines high.
padding = textutils.get_padding(self._textwidget)[0]
print(f"padding is: {padding}")
linespace = font.metrics('linespace')
linespace += padding
linespace *= 2
# Update needed to get width and height, but causes key bindings to execute
self._textwidget.update()
width, height = textutils.textwidget_size(self._textwidget)
if height < linespace:
print("height is less than linespace")
print(height)
print(linespace)
# For one thing, this doesn't work
self._textwidget.configure(height=linespace)
Now that I look at the code again, maybe the best place is actually the run_command()
function in no_terminal.py
. You will need to set a height in the paneconfigure.
The problem with textwidget.configure(height=...)
is that the panedwindow ignores the text widget's request for size. This makes sense, because the user must be able to resize the text widget by simply dragging the panedwindow.
On my system, it sometimes fails to become large enough:
https://github.com/Akuli/porcupine/assets/18505570/236d0ab8-b33d-403f-830f-0586305bb1b2
I will figure out why.
I tried a few things and can't figure out why that is happening, but I added a funny workaround.
Thanks for working on this! I like it, even though I needed to add an ugly hack, but at least the ugliness is hidden away in a function with good comments :)
No problem! I was a fun challenge looking through the code. As for the "hack", sometimes tkinter is like that. Thanks for guiding me through it!
Fixes #1128.