GASP/GASP_Code
6
1
Fork
You've already forked GASP_Code
4

Text size does not appear to be working #18

Open
opened 2022年08月14日 13:16:21 +02:00 by jelkner · 3 comments

I just completed Challange 4 in the Robots sheet, which is supposed to set the font size to 48. It does not appear to be working. I tried changing the font size (even setting it to 0) and it doesn't change. See attached screenshot.

I just completed Challange 4 in the [Robots sheet](http://www.openbookproject.net/pybiblio/gasp/course/5-robots.html), which is supposed to set the font size to 48. It does not appear to be working. I tried changing the font size (even setting it to 0) and it doesn't change. See attached screenshot.

I seem to have found the root of the issue. The size attribute of the Text class was never used! I changed the initialization of the Text class to now change size when first drawing. I decided to keep it simple and not add a "set_size" or "set_font" method because this is the beginners module. Bogging down new users with class methods seems unfair. That functionality still exists in gasp games, though. So I would direct anyone looking for a more robust Text class to use that module instead.

Now the code:

from gasp import *
begin_graphics()
run = True
while run:
 # Exit on Spacebar Press
 if "space" in keys_pressed():
 run = False
 text = Text("You can now change the text size!", (300, 300), size=48)
end_graphics()

Changes the size of the text to 48. I have demostrated this in the attached screenshots.

I think this should solve your problem, but if there is anything else I should add/change before I push to PyPI let me know.

P.S. Size 48 seems a bit large. Maybe try a smaller value and we can update the sheet later :)

I seem to have found the root of the issue. The size attribute of the Text class was never used! I changed the initialization of the Text class to now change size when first drawing. I decided to keep it simple and not add a "set_size" or "set_font" method because this is the beginners module. Bogging down new users with class methods seems unfair. That functionality still exists in gasp games, though. So I would direct anyone looking for a more robust Text class to use that module instead. Now the code: ``` from gasp import * begin_graphics() run = True while run: # Exit on Spacebar Press if "space" in keys_pressed(): run = False text = Text("You can now change the text size!", (300, 300), size=48) end_graphics() ``` Changes the size of the text to 48. I have demostrated this in the attached screenshots. I think this should solve your problem, but if there is anything else I should add/change before I push to PyPI let me know. P.S. Size 48 seems a bit large. Maybe try a smaller value and we can update the sheet later :)
Author
Owner
Copy link

Thanks, Richard! As soon as this fix is in PyPI, I'll have students:

% pip freeze > requirements.txt
% pip install -r requirements.txt --upgrade

so that they get the new version.

Thanks, Richard! As soon as this fix is in PyPI, I'll have students: % pip freeze > requirements.txt % pip install -r requirements.txt --upgrade so that they get the new version.

The changes have now been pushed to PyPI, the newest GASP version is now 0.6.2.

https://pypi.org/project/gasp/

The changes have now been pushed to PyPI, the newest GASP version is now 0.6.2. https://pypi.org/project/gasp/
Sign in to join this conversation.
No Branch/Tag specified
main
No results found.
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
GASP/GASP_Code#18
Reference in a new issue
GASP/GASP_Code
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?