How do I change material render preview? by using Python

I want to to create a new panel using Python that contains a small window consisting of two layers of images:
1- A fixed image layer that does not change (the background that will appear behind the material ball)
2- An image layer for the material sphere (or any other shape) that changes according to the material properties change, with a transparent background so that the first layer appears behind the material sphere.
I think that the second layer will not change directly nor the properties of the material associated with the model, but rather the properties of the material must be specified first, then pressing a button that performs the submit function to replace the second layer of the image of the material with the old properties with image of the material with the new properties and apply the new properties to the material associated with the object, as it will appear on the surface of the material sphere reflection of light, or HDRI (reflection of the illumination of the surrounding “world”).
I am trying to adjust the settings and the user interface in Blender, for