Pysimplegui multiline

Hi. Need some help with multiline.

I have a def function that create an interface and uses multiline to populate the file contents into it.

def LoginScreen():
global …
sg.theme(‘LightBlue1’)
loginlayout = [


[sg.Frame(’’,[[sg.Multiline(key=’-ml-’+sg.WRITE_ONLY_KEY, size=(131,15)) ]] )]
]
window = sg.Window(‘Login’, loginlayout, size=(1000,600))

def ViewFileinMultiFileArea():
global …
line = ‘ABCDEFGH’
window[’-ml-’+sg.WRITE_ONLY_KEY].print(line)

def main():
LoginScreen
ViewFileinMultiFileArea

the problem is: if I put this line
window[’-ml-’+sg.WRITE_ONLY_KEY].print(line)
within the loginscreen, it works and populates the mainline.
But the same line in ViewFileinMultiFileArea does not work.

it gives error like:
TclError: Invalid command name “.!toplevel134.!frame8.!labelframe.!frame.!frame.!scrolledtext”

and it gives error pointing at this line itself:
window[’-ml-’+sg.WRITE_ONLY_KEY].print(line)

Any help is really much appreciated.

I found the solution.

I was calling both the functions above (LoginScreen and ViewFileinMultiFileArea) from main function. Instead I called ViewFileinMultiFileArea from LoginScreen and it worked. In fact, now I do not need this line:
window[’-ml-’+sg.WRITE_ONLY_KEY].print(line)
just print(line) works and it display in the multiline area