Fun ui.image behaviour

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
jack_norton
Lemma-Class Veteran
Posts: 4086
Joined: Mon Jul 21, 2008 5:41 pm
Completed: Too many! See my homepage
Projects: A lot! See www.winterwolves.com
Tumblr: winterwolvesgames
Contact:

Fun ui.image behaviour

#1 Post by jack_norton »

I'm not sure if I'm missing something, but look at the code below:

Code: Select all

label relaxmenu:
    python:
        i=0
        for name,min,max in relaxT:
            #check if enough money
            if attributes[Awea]>0 or i==0:
                layout.button(u"", None, clicked=ui.jumps("relax"+str(i)),ypos=585,xpos=5+i*204,xminimum=200,yminimum=180,yalign=0.0)
                ui.image("gfx/relax"+str(i)+".png",ypos=618,xpos=105+i*204,xalign=0.5)
                ui.text("{size=22}"+name+"{/size}", ypos=590,xpos=105+i*204,xalign=0.5,drop_shadow=[(1,1),(-1,-1),(1,-1),(-1,1)])
                if i==0:
                    ui.text("{size=20}Free{/size}", ypos=735,xpos=105+i*204,xalign=0.5,drop_shadow=[(1,1),(-1,-1),(1,-1),(-1,1)])
                else:
                    ui.text("{size=20}Cost ("+str(min)+"-"+str(max)+"){/size}", ypos=735,xpos=105+i*204,xalign=0.5,drop_shadow=[(1,1),(-1,-1),(1,-1),(-1,1)])
            else:
                layout.button(u"", None, clicked=None,ypos=585,xpos=5+i*204,xminimum=200,yminimum=180,yalign=0.0)
                ui.image(im.Sepia("gfx/relax"+str(i)+".png"),ypos=618,xpos=105+i*204,xalign=0.5)
                ui.text("{size=22}"+name+"{/size}", ypos=590,xpos=105+i*204,xalign=0.5,drop_shadow=[(1,1),(-1,-1),(1,-1),(-1,1)])
                ui.text("{size=18}Not enough money{/size}", ypos=735,xpos=105+i*204,xalign=0.5,drop_shadow=[(1,1),(-1,-1),(1,-1),(-1,1)])
            i+=1
    $ layout.button(u"Cancel And Go Back", None, clicked=ui.jumps("status"),ypos=530,xalign=0.5)
    $ ui.interact()
the first ui.image works fine, while the second, the one that produces im.Sepia images, shows the pictures all aligned on the upper-left corner. Why? it's a bug ?
follow me on Image Image Image
computer games

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Fun ui.image behaviour

#2 Post by PyTom »

ui.Image ignores the keyword arguments when its first argument is a displayable. So what you really need to do is to write:

ui.image(im.Sepia("gfx/relax"+str(i)+".png",ypos=618,xpos=105+i*204,xalign=0.5))
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
jack_norton
Lemma-Class Veteran
Posts: 4086
Joined: Mon Jul 21, 2008 5:41 pm
Completed: Too many! See my homepage
Projects: A lot! See www.winterwolves.com
Tumblr: winterwolvesgames
Contact:

Re: Fun ui.image behaviour

#3 Post by jack_norton »

I tried copy/pasting your line but I got this error:
TypeError: Sepia() got an unexpected keyword argument 'ypos'
follow me on Image Image Image
computer games

User avatar
jack_norton
Lemma-Class Veteran
Posts: 4086
Joined: Mon Jul 21, 2008 5:41 pm
Completed: Too many! See my homepage
Projects: A lot! See www.winterwolves.com
Tumblr: winterwolvesgames
Contact:

Re: Fun ui.image behaviour

#4 Post by jack_norton »

Nevermind, found a workaround:

Code: Select all

                ui.frame(ypos=618,xpos=105+i*204,xalign=0.5,style='default')
                ui.image(im.Sepia("gfx/relax"+str(i)+".png"))
and now the disabled options are correctly "sepiated"! 8)
Attachments
screenshot0001.jpg
follow me on Image Image Image
computer games

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Fun ui.image behaviour

#5 Post by PyTom »

Nice.

As a suggestion, you may want to use yminimum on the "Relationship" and "Current Activity" frames, so that they're the same height as the Money and Age frames. (At least, I find a design more attractive when things that are close to the same height line up.)
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
jack_norton
Lemma-Class Veteran
Posts: 4086
Joined: Mon Jul 21, 2008 5:41 pm
Completed: Too many! See my homepage
Projects: A lot! See www.winterwolves.com
Tumblr: winterwolvesgames
Contact:

Re: Fun ui.image behaviour

#6 Post by jack_norton »

Yes I know about yminimum, I had used that height because thought was too tall compared to the inside texts, but indeed probably would be better if was aligned with the other two frames :)
follow me on Image Image Image
computer games

Post Reply

Who is online

Users browsing this forum: Google [Bot], Ocelot, Semrush [Bot]