'Create a new file - Untitled
fname=None --> fname will be \'untitledXX.py\' but do not create file
fname=<basestring> --> create file'

@Slot()
@Slot(str)
def new(self, fname=None, editorstack=None, text=None):

    if (text is None):
        default_content = True
        (text, enc) = encoding.read(self.TEMPLATE_PATH)
        enc_match = re.search('-*-    coding:    ?([a-z0-9A-Z\\-]*)    -*-', text)
        if enc_match:
            enc = enc_match.group(1)
        username = encoding.to_unicode_from_fs(os.environ.get('USERNAME', ''))
        if (not username):
            username = encoding.to_unicode_from_fs(os.environ.get('USER', '-'))
        VARS = {'date': time.ctime(), 'username': username}
        try:
            text = (text % VARS)
        except:
            pass
    else:
        default_content = False
        enc = encoding.read(self.TEMPLATE_PATH)[1]
    create_fname = (lambda n: (to_text_string(_('untitled')) + ('%d.py' % n)))
    if (editorstack is None):
        current_es = self.get_current_editorstack()
    else:
        current_es = editorstack
    created_from_here = (fname is None)
    if created_from_here:
        while True:
            fname = create_fname(self.untitled_num)
            self.untitled_num += 1
            if (not osp.isfile(fname)):
                break
        basedir = getcwd()
        if (self.main.projects.get_active_project() is not None):
            basedir = self.main.projects.get_active_project_path()
        else:
            c_fname = self.get_current_filename()
            if ((c_fname is not None) and (c_fname != self.TEMPFILE_PATH)):
                basedir = osp.dirname(c_fname)
        fname = osp.abspath(osp.join(basedir, fname))
    else:
        fname = osp.abspath(to_text_string(fname))
        index = current_es.has_filename(fname)
        if (index and (not current_es.close_file(index))):
            return
    finfo = self.editorstacks[0].new(fname, enc, text, default_content)
    finfo.path = self.main.get_spyder_pythonpath()
    self._clone_file_everywhere(finfo)
    current_editor = current_es.set_current_filename(finfo.filename)
    self.register_widget_shortcuts(current_editor)
    if (not created_from_here):
        self.save(force=True)
