Combine imagebutton and text into one button?

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
Posts: 150
Joined: Wed Nov 08, 2017 4:32 pm
Projects: HSS

Combine imagebutton and text into one button?

#1 Post by Errilhl » Tue Nov 21, 2017 3:38 pm

Is that possible?

I can think of ways to work around this, of course, like creating a button-background which is wider than the actual image (character image), and just placing the text above it, but that seems like a hackish workaround.

What I would like is for a stats-screen to work with having both an image of the character, and the name of the character, and preferably both be clickable (like it was all one button), and open the same content (stats).

Is this easily possible using an already existing imagebutton?
Currently working on: Image

User avatar
Posts: 108
Joined: Thu Aug 31, 2017 11:47 am
Projects: Shattering Harmony, Project-HR
Organization: AlmosThere Studio

Re: Combine imagebutton and text into one button?

#2 Post by RicharDann » Tue Nov 21, 2017 4:58 pm

I asked a similar question some time ago:


I went with Remix's suggestion in the end because I needed the automatic image change on hover imagebutton provides, but if your character's image doesn't need to change and you only need button functionality then using Button is also a valid option.

User avatar
Posts: 362
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet
Projects: An un-named 3d anime based trainer game

Re: Combine imagebutton and text into one button?

#3 Post by Remix » Tue Nov 21, 2017 7:30 pm

The 'just stack all the stuff on top of each other in a fixed' approach, as suggested, would work fine, though you might also want to look at using text button.

From a quick 'rather untested' sleuth around the code, TextButton seems to sit on a scalable frame and actually changes the frame image on hover and unhover. It shouldn't be too tricky to track down the 'choice_button' styles in gui.rpy, make some new ones and add some hover/idle images to the game/gui folder (like the choice_ ones in there that are used for menu: blocks)
Then it would just be a case of:
... textbutton "{space=10}{image='icon.png'}{space=4}The Name{space=10}" style_prefix="whatever" action ... etc

Post Reply

Who is online

Users browsing this forum: No registered users