python persistance

if i create a UI using python.
then load a level. or change the current level. leaving my UI open.
all my python variables and instances associated with the UI get garbage collected.

for example… the button to call a function to load a level is still in the UI but not functional.

how do i avoid this?