Page 1 of 1

[SOLVED] how to grab and manipulate renpy elements by their IDs

Posted: Sun Oct 30, 2022 1:36 am
by The Historian
Hello!
I'm having trouble finding docs on how to grab and manipulate elements by their IDs.

The parts I'm having trouble with are the ones I marked with ###

Code: Select all

init python:
	def example_function(id_fixed, id_imagebutton, id_fixed_new):
		###Delete imagebutton with id_imagebutton, and add new imagebutton to id_fixed_new
		# OR, ALTERNATIVELY
		###Move imagebutton with id_imagebutton to id_fixed_new, and change the id and action of imagebutton with id_imagebutton to a new id and action

 
label start:
	screen my_example_screen:
    		fixed id "id_fixed":
      			imagebutton id "id_imagebutton":
				#idle, hover, etc.
        			action example_function("id_fixed", "id_imagebutton", "id_fixed_new") #wanna move this button to fixed below, and change its id and action
 
		fixed id "id_fixed_new":
		#properties, style, whatever, etc.

	show screen my_example_screen

This is a simplified example code block that shows the relevant parts. I can't use manual solutions like having the other button already in place but hidden, etc.

In short, I haven't been able to find how to grab elements by their IDs, or how to manipulate them afterwards.

Thank you in advance for any help!

Re: how to grab and manipulate renpy elements by their IDs

Posted: Sun Oct 30, 2022 5:02 am
by Ocelot
In short: that would ne useless, since all changes would disappear when screen would reevaluate and redraw itself in the next instant.

You can conditionally create buttons from data contained in some container and your functions would just manipulate those containers.

Re: how to grab and manipulate renpy elements by their IDs

Posted: Sun Oct 30, 2022 5:36 am
by The Historian
Ocelot wrote:
Sun Oct 30, 2022 5:02 am
In short: that would ne useless, since all changes would disappear when screen would reevaluate and redraw itself in the next instant.

You can conditionally create buttons from data contained in some container and your functions would just manipulate those containers.
Those changes shouldn't be permanent, they're only for when the current screen is displayed.

If I call the screen again, I don't want the screen with the updated state.

Re: how to grab and manipulate renpy elements by their IDs

Posted: Mon Oct 31, 2022 2:39 pm
by The Historian
Not sure about grabbing and manipulating by IDs, but Ocelot (^ post #2) explained how to achieve result I wanted in alternative way here:
viewtopic.php?f=8&t=65589

I didn't quite get post #2 of this forum cause i'm fairly new to renpy and I didn't realize screen refreshes so often (on every interaction, I think?)