MouseTooltip - how to usage image with solid color?

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
User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

MouseTooltip - how to usage image with solid color?

#1 Post by namastaii »

I borrowed this: viewtopic.php?t=47205

I am wondering if I can use a solid color square for this? I'm doing something wrong I think (unless it's just not possible)

I put the default and also defined the image for the solid color in case I couldn't put it directly in

Code: Select all

default mtt = MouseTooltip(Text(" "), padding={"x": 10, "y": -10})

Code: Select all

default currentcolor_image = Image(Solid(currentcolor, xysize=(50,50)))

Code: Select all

                          
                                imagebutton:
                                    idle Solid(currentcolor, xysize=(100,180))
                                    clicked mtt.Action(Image(currentcolor_image))
Error:

Code: Select all

While running game code:
  File "renpy/common/00start.rpy", line 185, in script
    python:
  File "renpy/common/00start.rpy", line 185, in script
    python:
  File "renpy/common/00start.rpy", line 186, in <module>
    renpy.execute_default_statement(True)
  File "game/setup.rpy", line 67, in set_default
    default currentcolor_image = Image(Solid(currentcolor, xysize=(50,50)))
  File "game/setup.rpy", line 67, in <module>
    default currentcolor_image = Image(Solid(currentcolor, xysize=(50,50)))
Exception: Expected an image, but got a general displayable.
I've also tried image currentcolor_image = Solid(currentcolor, xysize=(50,50))

And I do want the tooltip to stay displayed until I click on something specific to take it off but yeah I can only get it to work with text and I'm sure a normal image would work fine

User avatar
bonnie_641
Regular
Posts: 133
Joined: Sat Jan 13, 2018 10:57 pm
Projects: Código C.O.C.I.N.A.
Deviantart: rubymoonlily
Contact:

Re: MouseTooltip - how to usage image with solid color?

#2 Post by bonnie_641 »

In one project, I saw an example of how to use tooltip.
Give me a few minutes to copy and paste the code.
I speak and write in Spanish. I use an English-Spanish translator to express myself in this forum. If I make any mistakes, please forgive me.
I try my best to give an answer according to your question. :wink:

User avatar
bonnie_641
Regular
Posts: 133
Joined: Sat Jan 13, 2018 10:57 pm
Projects: Código C.O.C.I.N.A.
Deviantart: rubymoonlily
Contact:

Re: MouseTooltip - how to usage image with solid color?

#3 Post by bonnie_641 »

In "screen main_menu":

Code: Select all

    imagebutton auto "gui/main_start_%s.png" xpos 760 ypos 60 focus_mask True action Start() hovered [ Play ("test_one", "sfx/click.wav"), Show("gui_tooltip", my_picture="gui/tooltip_main_menu_start.png", my_tt_xpos=19, my_tt_ypos=680) ] unhovered [Hide("gui_tooltip")] at main_eff1 
where:
# auto - is used to automatically define the images used by this button. We could also use:
# imagebutton idle "main_start_idle.png" hover "main_start_hover.png"

# xpos X ypos Y - are used set the coordinates to position the button (X,Y)

# focus_mask True ensures that only non-transparent areas of the button can be focused. focus_mask defines which parts of the image can be focused, and hence clicked on. http://www.renpy.org/doc/html/style.htm ... properties

# action - action to run when the button is activated. This also controls if the button is sensitive, and if the button is selected.

# hovered - action to run when the button gains focus. Square brackets are used to run multiple actions. In this case we play a sound effect and show a tooltip.

# unhovered - action to run when the button loses focus. In this case we hide a tooltip.

The Tooltip Screen:

Code: Select all

screen gui_tooltip:
    add my_picture xpos my_tt_xpos ypos my_tt_ypos 

REF:
http://www.renpy.org/doc/html/screens.html#imagebutton

You can use the code and adapt it to your needs.

PD: I got this code from viewtopic.php?f=51&t=22565&start=75#p455107
Attachments
tooltip_main_menu_start.png
Last edited by bonnie_641 on Wed Aug 14, 2019 6:08 pm, edited 1 time in total.
I speak and write in Spanish. I use an English-Spanish translator to express myself in this forum. If I make any mistakes, please forgive me.
I try my best to give an answer according to your question. :wink:

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3785
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: MouseTooltip - how to usage image with solid color?

#4 Post by Imperf3kt »

namastaii wrote: Wed Aug 14, 2019 12:04 pm I borrowed this: viewtopic.php?t=47205

I am wondering if I can use a solid color square for this? I'm doing something wrong I think (unless it's just not possible)

I put the default and also defined the image for the solid color in case I couldn't put it directly in

Code: Select all

default mtt = MouseTooltip(Text(" "), padding={"x": 10, "y": -10})

Code: Select all

default currentcolor_image = Image(Solid(currentcolor, xysize=(50,50)))

Code: Select all

                          
                                imagebutton:
                                    idle Solid(currentcolor, xysize=(100,180))
                                    clicked mtt.Action(Image(currentcolor_image))
Error:

Code: Select all

While running game code:
  File "renpy/common/00start.rpy", line 185, in script
    python:
  File "renpy/common/00start.rpy", line 185, in script
    python:
  File "renpy/common/00start.rpy", line 186, in <module>
    renpy.execute_default_statement(True)
  File "game/setup.rpy", line 67, in set_default
    default currentcolor_image = Image(Solid(currentcolor, xysize=(50,50)))
  File "game/setup.rpy", line 67, in <module>
    default currentcolor_image = Image(Solid(currentcolor, xysize=(50,50)))
Exception: Expected an image, but got a general displayable.
I've also tried image currentcolor_image = Solid(currentcolor, xysize=(50,50))

And I do want the tooltip to stay displayed until I click on something specific to take it off but yeah I can only get it to work with text and I'm sure a normal image would work fine
The error message says expected an image, but got a general displayable instead. I assume that means you can't use Solid like that.
Have you tried defining an image with solid, and use that?
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: MouseTooltip - how to usage image with solid color?

#5 Post by namastaii »

Yes that's why it's image whatever = solid() so I'm not sure what to do

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3785
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: MouseTooltip - how to usage image with solid color?

#6 Post by Imperf3kt »

Ah, didn't even realise I was suggesting you do what you're already doing.

Could it perhaps be because you're trying to dynamically assign the color?
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: MouseTooltip - how to usage image with solid color?

#7 Post by namastaii »

well I tried just a straight color as well just "#ffffff" and it's still giving me an error. But yes eventually I would be using variables that change and if this can't change with those then I'll stop trying now anyway.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3785
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: MouseTooltip - how to usage image with solid color?

#8 Post by Imperf3kt »

If Solid() won't work, how about Tile?
Create an image with solid, use it in the Tile as the image it fills a VBox or Frame with.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: MouseTooltip - how to usage image with solid color?

#9 Post by namastaii »

Same error unfortunately, just happens at the time I try to press the button instead of at launch now haha

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: MouseTooltip - how to usage image with solid color?

#10 Post by namastaii »

I might try a small image and if I can get away with colorize with color matrix ... haha other than that, at least an image will be fine I guess

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: MouseTooltip - how to usage image with solid color?

#11 Post by namastaii »

So, matrix color over a png works fine. BUT I can't get the color on the mousetooltip image to update until I click the button again that reassigns the color. I even included a renpy restart interaction inside the function so like... why D: haha

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: MouseTooltip - how to usage image with solid color?

#12 Post by namastaii »

Just in case anyone sees something I don't, I'm just going to show the whole picture.

Image

Code: Select all

                hbox:
                    if len(custom_swatch) < 1:
                        text "You haven't added any colors yet"
                    else:
                        for i in custom_swatch:
                            if i == currentcolor:
                                imagebutton:
                                    idle Solid(i, xysize=(150,180))
                                    action [Function(copy_color, i), mtt.Action(Image(im.MatrixColor("ui/square.png", im.matrix.colorize(currentcolor,currentcolor))))]

                            else:
                                imagebutton:
                                    idle Solid(i, xysize=(100,180))
                                    action [Function(copy_color, i), mtt.Action(Image(im.MatrixColor("ui/square.png", im.matrix.colorize(currentcolor,currentcolor))))]

Code: Select all

    def copy_color(x):
        store.currentcolor = x
        renpy.restart_interaction()

    def input_color(newstring):
        store.addcolor = newstring
        renpy.restart_interaction()
        
    def add_swatch(x):
        global custom_swatch
        match = re.search(r'^#(?:[0-9a-fA-F]{3}){1,2}$', x)
        if match:
            if x not in custom_swatch:
                custom_swatch.append(x)        
        

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]