code: def saveToFile(self):
          
          filename = self.codeEditor.dialog.getSaveFileName()
          if filename and filename != '.':
              with open(filename, 'w') as f:
                  f.write(self.toPlainText())
              print('saved script under %s' % filename)
docs: Save the current text to file