gui.py 文件源码

python
阅读 16 收藏 0 点赞 0 评论 0

项目:stopgo 作者: notklaatu 项目源码 文件源码
def NewFile(self,e):

        wcd='All files(*)|*'
        dest = 'stopgo_project_'
        destid = int(time.time())

        try:
            dirname = self.clargs['project']
        except OSError:
            dirname = os.path.expanduser('~')
        except:
            dirname = os.path.join(os.path.expanduser('~'),self.myprefs['dir'])

        sd = wx.FileDialog(self, message='Save file as...', 
            defaultDir=dirname, defaultFile='stopgo_project_' + str(destid),
            wildcard=wcd, 
            style=wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT)

        if sd.ShowModal() == wx.ID_OK:
            projnam = sd.GetFilename()
            projpath= os.path.join(sd.GetPath(),projnam)

            # make the directory 
            # the OS does this for us but just in case..
            #if not os.path.exists( os.path.dirname(projpath) ):
                #os.makedirs( os.path.dirname(projpath))
            # make image dir
            os.makedirs( os.path.join(os.path.dirname(projpath),'images'))


        dbfile = projpath
        self.imgdir = os.path.join(os.path.dirname(projpath), 'images')
        logging.exception(dbfile)
        logging.exception(projpath)
        logging.exception(self.imgdir)

        self.con = sq.connect(dbfile, isolation_level=None )

        self.cur = self.con.cursor()
        self.cur.execute("CREATE TABLE IF NOT EXISTS Project(Id INTEGER PRIMARY KEY, Path TEXT, Name TEXT, [timestamp] timestamp)")
        self.cur.execute("CREATE TABLE IF NOT EXISTS Timeline(Id INTEGER PRIMARY KEY, Image TEXT, Blackspot INT)")
        self.cur.execute("INSERT INTO Project(Path, Name, timestamp) VALUES (?,?,?)", ("images", "StopGo Project", datetime.now() ))
        #self.con.close()
        self.BindKeys(dbfile)

        sb = self.GetStatusBar()
        stat = os.path.basename(projpath) + ' created'
        sb.SetStatusText(stat, 0)
        sb.SetStatusText('', 1)
        sd.Destroy()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号