Hi lemmasoft, and PyTom! if you see this
I'd like to make a data table screen...
the info will be based on the values of a list.
My renpy game saves player's scores into a database.
I manage to do requests and post data, but now I need to output it properly.
The data to be shown is affected by the players who registered.
I have this code that gets data,
The SQL codes return the info of the players, so a player can use the renpy game to see a "Leaderboard".
the return values look a little like this.
[{"id":"74","email":"zankizuna@yahoo.com.ph","username":"Zan","gender":"Male","gamelevel":"5","gamescore":"523","studentnum":13001253600"},{"id":"87","email":"breezetheeraser@gmail.com","username":"Breeze","gender":"Female","gamelevel":"10","gamescore":"13868","studentnum":"17004883647"},{"id":"102","email":"raseruuu@gmail.com","username":"Raseru","gender":"Male","gamelevel":"3","gamescore":"24","studentnum":"15001401912"}]
Do I have to dissect this as a string so I can print them into the screen?
I want it to look kinda like this...
and if the data is too long, a scrollbar will be useful.
I know renpy kinda did it in tutorial.rpy, but it was hard for me to understand.
If possible, I'd like to use it with a for loop.
Thanks in advance!!
Data Table Screen with looped output + scrollbar
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.
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.
- 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: Data Table Screen with looped output + scrollbar
I'm assuming you've already turned the JSON into python objects (using json.loads). So then you just do:
Note that since people can grab the raw data, so sending emails, ids, studentnums, etc might be a bad idea.
Code: Select all
screen leaderboard(data):
vbox:
hbox:
text "Username" xsize 200
text "Score" xsize 100
text "Level" xsize 100
text "Rank" xsize 100
for i, u in enumerate(data):
$ rank = i + 1
hbox:
text "[u[username]]" xsize 200
text "[u[gamescore]]" xsize 100
text "[u[gamelevel]]" xsize 100
text "[rank]" xsize 100
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
Who is online
Users browsing this forum: No registered users