[Solved]Scrollable gallery

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
Doeny
Regular
Posts: 26
Joined: Wed Sep 07, 2022 8:28 pm
Contact:

[Solved]Scrollable gallery

#1 Post by Doeny » Thu Oct 06, 2022 6:49 pm

I wanted to create an inage gallery and make it scrollable to avoid creating pages. I've created an frame but can't get it to move. Any ideas how to fix it?

Code: Select all

screen gallery():
    add "gallery_img"
    frame:
        xpos 250 ypos 150
        side ("c r"):
            area (1,0,1540,770)
            viewport id "gallery_viewport":
                draggable True mousewheel True
                add "gallery_img2"
                #images here
            vbar value YScrollValue("gallery_viewport")
Last edited by Doeny on Sat Oct 08, 2022 11:53 am, edited 1 time in total.

User avatar
_ticlock_
Veteran
Posts: 391
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Scrollable gallery

#2 Post by _ticlock_ » Thu Oct 06, 2022 11:19 pm

It looks ok. I believe your images are less than the size of the viewport. You can add some empty elements to change the child_size of the viewport. You also should consider using vbox or grid to simplify adding elements in the viewport.

Code: Select all

screen gallery():
    add "gallery_img"
    frame:
        xpos 250 ypos 150
        side ("c r"):
            area (1,0,1540,770)
            viewport id "gallery_viewport":
                draggable True mousewheel True
                vbox:
                    add "gallery_img2"
                    null height 3000

            vbar value YScrollValue("gallery_viewport")
null height 3000 - is basically empty spacing to increase child_size of the viewport to test viewport scrolling

Doeny
Regular
Posts: 26
Joined: Wed Sep 07, 2022 8:28 pm
Contact:

Re: Scrollable gallery

#3 Post by Doeny » Fri Oct 07, 2022 12:57 am

_ticlock_ wrote:
Thu Oct 06, 2022 11:19 pm
It looks ok. I believe your images are less than the size of the viewport. You can add some empty elements to change the child_size of the viewport. You also should consider using vbox or grid to simplify adding elements in the viewport.

Code: Select all

screen gallery():
    add "gallery_img"
    frame:
        xpos 250 ypos 150
        side ("c r"):
            area (1,0,1540,770)
            viewport id "gallery_viewport":
                draggable True mousewheel True
                vbox:
                    add "gallery_img2"
                    null height 3000

            vbar value YScrollValue("gallery_viewport")
null height 3000 - is basically empty spacing to increase child_size of the viewport to test viewport scrolling
Could you please run it and test if it works for you? Apparently there are no function improvement on my side after correcting the code.

User avatar
_ticlock_
Veteran
Posts: 391
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Scrollable gallery

#4 Post by _ticlock_ » Fri Oct 07, 2022 3:03 pm

Doeny wrote:
Fri Oct 07, 2022 12:57 am
Could you please run it and test if it works for you? Apparently there are no function improvement on my side after correcting the code.
Works for me:

Code: Select all

screen gallery():
    frame:
        xpos 250 ypos 150
        side ("c r"):
            area (1,0,1540,770)
            viewport id "gallery_viewport":
                draggable True mousewheel True
                vbox:
                    textbutton "Test"
                    null height 3000

            vbar value YScrollValue("gallery_viewport")

label start:
    call screen gallery

Doeny
Regular
Posts: 26
Joined: Wed Sep 07, 2022 8:28 pm
Contact:

Re: Scrollable gallery

#5 Post by Doeny » Sat Oct 08, 2022 11:53 am

_ticlock_ wrote:
Fri Oct 07, 2022 3:03 pm
Doeny wrote:
Fri Oct 07, 2022 12:57 am
Could you please run it and test if it works for you? Apparently there are no function improvement on my side after correcting the code.
Works for me:

Code: Select all

screen gallery():
    frame:
        xpos 250 ypos 150
        side ("c r"):
            area (1,0,1540,770)
            viewport id "gallery_viewport":
                draggable True mousewheel True
                vbox:
                    textbutton "Test"
                    null height 3000

            vbar value YScrollValue("gallery_viewport")

label start:
    call screen gallery
No idea what i did wrong but it works perfectly now. Thank you very much!

Post Reply

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot]