Moving or delete Blender Python Buttons

Hi,

I created a python script which needs some dynamic buttons. I need the possibility to move buttons or delete buttons while the script is running. Creating a widget is easy, but how could I move it after initial display or destroy it? I searched in the docs, but found nothing about it. Is this impossible?

regards
Andreas

No no impossible, hard to understand maybe?
Dynamic buttons start with dynamic data. This mean all from the “data” of the button to the size and location should be stored in global variables.

-Creating the button is the same. Create()
-Moving/scaling is a matter of changing the value between a redraw. The way GUI work right now in blender is: after Register(), blender will check for windows event. and call function to do so, event, bevent, draw. The draw function is called each time a blender do a draw event on the rest of the screen and also when some function ask for a redraw of the windows. So the idea is: to draw the GUI of a script, blender run the draw function each time, this mean he redo the button, the text and all stuff again and again. So change one variable and the stuff blender draw will not be the same :slight_smile: .
-Deleting is then very easy to understand: just put the button() call in an if statement to see if you need to draw it.

So more complex UI work this way like tab ui, where you select “tab” that reveal a screen full of dozen of buttons. All other button from other tab still exist, but they are “skipped”.

Hope it help

Yep,

actually you can have a look at many of my scripts, I have dinamic GUIs made only via if statements in the draw routine

Stefano

Great idea! Now I played some time with Blender widgets and see they’re a little more “basic” then other toolkits (e.g. compared to GTK2). But I could work around most things and create what I need :wink:

regards
Andreas