2004年03月24日 星期三 19:29
请问:我用wxpython编的gui,当窗体有效时打开(新建)一个zodb库,我想在关闭窗体时关闭数据库, 如:def OnWxframe1Activate(self, event): storage = FileStorage.FileStorage('record.fs') db = DB(storage) conn = db.open() dbroot = conn.root() dbname = 'recordlist' dbroot[dbname]=OOBTree() list = dbroot[dbname] class record(Persistent): def OnWxframe1Close(self, event): db.close() self.Close() self.Destroy() 为何说db这个变量不是全局变量,那我又如何调用db这个变量呢 ________________________________ Upgrade Your Email - Click here! <http://promos.hotbar.com/promos/promodll.dll?RunPromo&El;=hotbar%5felement%3bst%3b&SG;=&RAND;=56517&partner;=hotbar> -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20040324/698b1f94/attachment.htm
2004年03月24日 星期三 19:51
Hello Nature.Liu, self.db = DB(storage) .... self.db.close() 是也乎? === [ 19:29 ; 04-03-24 ] you wrote: NL> 请问:我用wxpython编的gui,当窗体有效时打开(新建)一个zodb库,我想在关闭窗体时关闭数据库, NL> 如:def OnWxframe1Activate(self, event): NL> storage = FileStorage.FileStorage('record.fs') NL> db = DB(storage) NL> conn = db.open() NL> dbroot = conn.root() NL> dbname = 'recordlist' NL> dbroot[dbname]=OOBTree() NL> list = dbroot[dbname] NL> class record(Persistent): NL> def OnWxframe1Close(self, event): NL> db.close() NL> self.Close() NL> self.Destroy() NL> 为何说db这个变量不是全局变量,那我又如何调用db这个变量呢 NL> ________________________________ NL> Upgrade Your Email - Click here! NL> <http://promos.hotbar.com/promos/promodll.dll?RunPromo&El;=hotbar%5felement%3bst%3b&SG;=&RAND;=56517&partner;=hotbar> === === === === === === === === === === -- Best regards, Zoom.Quiet /=======================================\ ]Time is unimportant, only life important![ \=======================================/
Zeuux © 2024
京ICP备05028076号