Skip to content

Minor Textbox bugfixes #5723

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
Jul 19, 2023
Merged

Minor Textbox bugfixes #5723

merged 2 commits into from
Jul 19, 2023

Conversation

ollie-d
Copy link
Contributor

@ollie-d ollie-d commented Jul 19, 2023

Previously when size and textgrid_shape were both None, the program would crash. I fixed this by setting textgrid_shape to (len(text),1) when both are None.

I also fixed a textgrid.py crash caused by size being too small to render a single character. A ValueError is now raised which tells the user to increase the size or use the textgrid_shape option.

Finally, I added AttributeError to the exceptions of __del__ in textgrid.py. Previously this would cause an additional error message whenever textgrid.py raised an error which makes actual problems difficult to detect.

P.S. I got to TextBox via looking for rendering improvements for TextBox2. TextBox is much faster when drawing multiple instances. I plan on continuing my tinkering with TextBox2, but figured these quick bug fixes would be useful in the meantime.

ollie-d added 2 commits July 18, 2023 18:09
Previously when size and textgrid_shape were both None, there would be a crash. I fixed this by detecting when both were none and setting textgrid_shape to len(text) by 1, thus solving the issue. I also fixed a problem where size was too small, which caused textgrid.py to crash. I added a check to make sure the size wouldn't lead to an integer division error. Instead, if the size is not large enough (e.g. would cause an error), a ValueError is raised which tells the user to increase the size or use the textgrid_shape option.
Added AttributeError to exception on final case in textgrid.py. Previously this would cause an additional error message to trump the ValueError raised when size is too small.
@TEParsons
Copy link
Contributor

The ultimate goal is to bring the speed of TextBox2 up to match TextBox so that we can remove TextBox altogether, but in the meantime these fixes seem a good stop gap :)

@TEParsons TEParsons merged commit 8faad22 into psychopy:dev Jul 19, 2023
@ollie-d ollie-d deleted the textbox_bugfixes branch July 19, 2023 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants