Lemma Soft Forums

Supporting creators of visual novels and story-based games since 2003.


Visit our new games list, blog aggregator, IRC, and wiki.
Activation problem? Email [email protected]
It is currently Sat May 25, 2013 9:21 am

All times are UTC - 5 hours [ DST ]


Forum rules


Ask questions about one topic per thread, and use a descriptive subject. "NotImplemented error in script.rpy" is a good subject, "Tom's problems" is not. Remember to include all of traceback.txt or error.txt when reporting a problem, as well as the relevant lines of script. Use the [code] tag to format scripts.



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Thu Feb 03, 2011 12:13 pm 
Newbie

Joined: Thu Feb 03, 2011 8:05 am
Posts: 6
I'd like to make a grid of drag and drop displayables of dynamically generated text, with background images.

The following doesn't work:

Code:
init python:
    from string import ascii_letters

    caps = ascii_letters[26:]
   
    def puzzle_screen(grid_size=8, **kwargs):
        ui.grid(grid_size, grid_size, id='puzzle_grid')
        for i in caps[0:grid_size]:
            for j in range(grid_size):
                drag_id = i + str(j)
                drag_child = ui.textbutton(drag_id, id='_' + drag_id, xminimum=50, yminimum=50, xpadding=0, background='rectangle.png')
                ui.drag(d=drag_child, drag_name=drag_id, id=drag_id)
        ui.close()
    renpy.define_screen('puzzle_screen', puzzle_screen)


Code:
Exception: Widget <renpy.display.dragdrop.Drag object at 0x03441230> expects a child.


How should I pass a child to ui.drag()?

And, is there a better way to create a displayable of text with background then ui.textbutton()? Should I create a custom displayable?


Top
 Profile Send private message  
 
PostPosted: Thu Feb 03, 2011 4:54 pm 
Ren'Py Creator
User avatar

Joined: Mon Feb 02, 2004 10:58 am
Posts: 10780
Location: Kings Park, NY
Completed: Moonlight Walks
Projects: Ren'Py
1) You're not going to be able to put ui.drags inside a grid. Well, it will work, but it'll be pointless. Drags position themselves relative to the enclosing area, which are the cells of the grid - so a drag in a grid won't move. You want to create a drag, and then call snap on it to put it into the grid.

2) For ui.drag, you want to omit the d parameter, and call ui.textbutton directy. So the code would look like:

Code:
    drag = ui.drag(drag_name=drag_id, id=drag_id)
    drag.snap(x, y)
    ui.window(xminimum=50, yminimum=50, xpadding=0, background='rectangle.png')
    ui.text(drag_id)

_________________
Another Old-Fashioned Bishoujo Gamer
Supporting creators since 2004; Code > Drama
(When was the last time you backed up your game?)
"It is not the critic who counts; not the man who points out how the strong man stumbles, or where the doer of deeds could have done them better. The credit belongs to the man who is actually in the arena, whose face in marred by dust and sweat and blood; who strives valiantly; who errs, who comes short again and again, because there is no effort without error and shortcoming" - Theodore Roosevelt


Top
 Profile Send private message  
 
PostPosted: Thu Feb 03, 2011 9:24 pm 
Newbie

Joined: Thu Feb 03, 2011 8:05 am
Posts: 6
Thanks so much! It works great.


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: Google [Bot]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Protected by Anti-Spam ACP
Powered by phpBB® Forum Software © phpBB Group