I have this code that I want to turn into a function. I need function_text to be accessible outside the function.
function_text = TextClip(item_1, fontsize=main_text_size, font=main_font, color=corner_text_color, size=(w, text_size_60))
function_text = function_text.set_fps(fps)
function_text = function_text.set_duration(5)
function_text = function_text.margin(left=0, right=1300, top=950, opacity=0)
function_text = function_text.set_position(("center"))
I want to be able to enter a variable name(function_text), and margin attribute with values to that variable(4th line in the code)
This is where I am at right now:
def displayText(my_str):
global my_str
my_str = TextClip(item_1, fontsize=main_text_size, font=main_font, color=corner_text_color, size=(w, text_size_60))
my_str = my_str.set_fps(fps)
my_str = my_str.set_duration(5)
my_str = my_str.margin(left=0, right=1300, top=950, opacity=0)
my_str = my_str.set_position(("center"))
return
displayText("function_text")
The problem I get is that I can't set my parameter as global because I get this error:
SyntaxError: name 'my_str' is parameter and global