2006年05月23日 星期二 11:20
python,大家好!
  我用PyQt做界面,做了一个显示数据库表的表格窗口。但是当我关闭这个表格时,内存并不释放。据说python有自己的内存回收功能,不用程序员操心。但如果python不释放,我该怎么办?多谢指教!下面是我的程序:
...
self.connect(self.applyBtn,SIGNAL("clicked()"),self.showAll)
...
def showAll(self):
        if self.filename:
            self.a=Form1(self,value=self.filename)
            self.a.show()
 
class Form1(QDialog):            
    def __init__(self, parent=None, value=None):
        QDialog.__init__(self, parent, "View Whole Table")
        self.value=value
        self.table1 = QTable(self,"table1")
        self.table1.setGeometry(QRect(0,0,800,560))
        self.table1.setMinimumWidth(200)
          
        mydb=MySQLdb.Connect(host="localhost", db="test",user="root",passwd="root")
        mycursor=mydb.cursor()
        stmt="select max(index) from %s"% str(self.value)
        mycursor.execute(stmt)
        result = mycursor.fetchone()
        numEx=result[0]
        self.table1.setNumRows(numEx)
        
        stmt="describe %s"% str(self.value)
        mycursor.execute(stmt)
        result = mycursor.fetchall()
        numCo=len(result);
        self.table1.setNumCols(numCo)
                
        
        self.languageChange()
        hheader=self.table1.horizontalHeader()
        
        stmt="select * from %svartype"% str(self.value)
        mycursor.execute(stmt)
        result = mycursor.fetchall()
        i=0
        jj=0
        for record in result:
            if jj==0:
                for nam in record:
                    clonam=nam
                    hheader.setLabel(i, unicode(clonam,'MBCS'))
                    i +=1
                jj +=1
        
        
        j=0
        while(jhttp://lists.exoweb.net/pipermail/python-chinese/attachments/20060523/63e29038/attachment-0001.htm
 2006年05月23日 星期二 19:43
看看qt的文档吧,反正我用wxpython的时候是可以自己销毁的 -- 云电清华同方小民工
Zeuux © 2025
京ICP备05028076号