How to use a style to uppercase the text in a textbutton?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
DrakOne
Newbie
Posts: 1
Joined: Tue Feb 19, 2019 11:31 pm
Contact:

How to use a style to uppercase the text in a textbutton?

#1 Post by DrakOne »

I would like to be able to place textbuttons in a container (hbox, vbox, etc.), and have the text in the buttons be uppercased, based on an inhereted style. I can obviously do this through modifying the text itself, and on some screens (like say, etc.) I can do this by intercepting the parameter and .upper()-ing it, but textbuttons aren't a screen (and I don't want this to apply to every button anyways).

For example, if I'd like all of the MainMenu buttons to be all Caps (Like START, LOAD, ETC), but I don't want to retype the text (because I'll be doing it elsewhere as well, not just the start menu, and there may be times I don't want it to be all caps, hence the desire for a style, shich can be applied/removed programatically, or applied to different containers which then hold the StartMenu screen, etc...), is there a way to use a style (or transform or something) in the container the textbuttons are in to have it uppercase the text of the buttons?

Can I define a custom style tag that would somehow grab the text about to be drawn to the button, then .upper() it and hand it back? Is there a better way?

I'm a fairly advanced programmer, but pretty new to ren'py, so feel free to provide solutions like class, inheretence, functions, etc.

I have considered simply building an all caps font, and using styles to replace the font, but this is a somewhat kludgy solution, and it seems like there should be a better solution, so I was checking here.

Thanks in advance for your answers and feedback!

Post Reply

Who is online

Users browsing this forum: Sugar_and_rice