Page 1 of 1

[Solved]Add text in image in list

Posted: Tue Aug 03, 2021 7:47 am
by bonnie_641

Code: Select all

label renpy_:#(1,2)fc
    #scene receta_generico
    $ ren0 = ['{b}{size=+3}{u}Prueba Título {/u}{/size}{/b}',
        '{size=-2}\nTEXTTTTTT XD{/size}' 
        'More text',
        '\n{image=deco}\n', # <--- I add the image but it does not allow me to add text over it 
        '{u}subtitle nº 1{/u}: {a=lenguaje}see link content{/a}',
        ]

    call screen renpai

screen renpai():
    add "images/ren.png" pos (0,119)
    text "{b}{size=+5}Link content {/size}{/b}" pos (78,67)

    imagebutton:#
        idle "images/cerrar.png"
        hover "images/cerrar_h.png"
        pos (1051,60)
        focus_mask True
        #activate_sound 'click.wav'
        action Jump("renpy_")

    frame:#documentación renpy
        background None
        area (320, 147, 870, 550) #(x, y, w, h)
        viewport:
            id "ren_0"
            draggable True
            scrollbars "vertical"
            mousewheel True
            has vbox
            for i in ren0:
                text i

Code: Select all

$ ren0 
[...]
for i in ren0:
    text i
the 'for' goes through all the content of $ren0. However what I want to do is to add a text over the image in the $ren0 block.I want to reuse the image several times. Is it possible?

Thank you in advance

Re: [Help]Add text in image in list

Posted: Tue Aug 03, 2021 8:27 am
by hell_oh_world
Probably just make the list a list of displayables and use add instead.

Code: Select all

define disps = (
  Text("txt1"),
  Text("txt2"),
  Fixed("image name", Text("txt3"))
)

screen test():
  for d in disps:
    add d

Re: [Help]Add text in image in list

Posted: Tue Aug 03, 2021 1:44 pm
by bonnie_641
hell_oh_world wrote: Tue Aug 03, 2021 8:27 am Probably just make the list a list of displayables and use add instead.

Code: Select all

define disps = (
  Text("txt1"),
  Text("txt2"),
  Fixed("image name", Text("txt3"))
)

screen test():
  for d in disps:
    add d
It worked! :D
Thank you very much <3
I leave backup in case I forget this process XD (or for someone who needs it).

Code: Select all

# Added the missing variable to make the request work (: (by hell_oh_world)
define disps = (
    Text(""),
    Fixed("deco", Text("\n    Test text over image")) #<--- text over image (called deco) with line breaks and white spaces.
)

label renpy_:
    #scene receta_generico
    $ ren0 = ['{b}{size=+3}{u}Test Title {/u}{/size}{/b}',
        '{size=-2}\nTEXTTTTTT XD{/size}' 
        'More text',
        #'\n{image=deco}\n', 
        '{u}subtitle nº 1{/u}: {a=lenguaje}see link content{/a}',
        ]

    call screen renpai

screen renpai():
    add "images/ren.png" pos (0,119)
    text "{b}{size=+5}Link content {/size}{/b}" pos (78,67)

    imagebutton:
        idle "images/cerrar.png"
        hover "images/cerrar_h.png"
        pos (1051,60)
        focus_mask True
        #activate_sound 'click.wav'
        action Jump("renpy_")

    frame:
        background None
        area (320, 147, 870, 550) #(x, y, w, h)
        viewport:
            id "ren_0"
            draggable True
            scrollbars "vertical"
            mousewheel True
            has vbox
            for i in ren0:
                text i
            frame:
                background None
                for d in disps: #<------------- what you had on the screen of the previous post (thanks hell_oh_world)
                    add d         # <3
PD: This code is linked to a local search engine. I only put in the part of the code that didn't work at all.