[PyQt] qftp, qtreewidget

lucaberto at libero.it lucaberto at libero.it
Thu Oct 28 11:03:47 BST 2010


Hello i have a problem when i list a dir i do as follow:

if i.isDir() :
            self.e_dir = True
            valor_nome = QtGui.QTreeWidgetItem()
            valor_nome.setText(1, i.name())
            valor_nome.setText(2, str(i.size()))
            valor_nome.setText(3, str(i.lastModified().toString("MMM,dd,
yyyy")))
            icona = QtGui.QPixmap('Directory-32.png')
            icona_b = QtGui.QIcon(icona)
            icona_b.setThemeName('direct')
            valor_nome.setIcon(1,icona_b)
            valore = valor_nome
else :
            self.e_dir = False
            valor_nome = QtGui.QTreeWidgetItem()
            valor_nome.setText(1, i.name())
            icona = QtGui.QPixmap('file.png')
            icona_b = QtGui.QIcon(icona)
            icona_b.setThemeName('file')
            valor_nome.setIcon(1,icona_b)
            valor_nome.setText(2, str(i.size()))
            valor_nome.setText(3, str(i.lastModified().toString("MMM,dd,
yyyy")))
            valore = valor_nome
        self.treeWidget.insertTopLevelItem(0, valore)

than i try this for decide if download a file or list a dir:

def on_treeWidget_doubleClicked(self, index):
        """
        Slot documentation goes here.
        """
        # TODO: not implemented yet
        #raise NotImplementedError
        self.nuova_dir = self.treeWidget.currentItem().text(1)
        self.icona = self.treeWidget.currentItem().icon(1)
        nome_icona = str(self.icona.themeName())
        print 'nome icona : ',  nome_icona
        #if self.e_dir == True or (self.nuova_dir == '') :
        if self.nuova_dir =='' or (nome_icona == 'direct'):
            self.chiedo_lista()
else:
            #print 'chiedo _file'
            self.chiedo_file()

but i some case when i a dir i have :

folder
file
folder

i get for all the three object that nome icona is 'direct', when in the file 
the icon is file icon

Thanks

Luca


More information about the PyQt mailing list