[PyKDE] Autorefresh in file manager

Andreas Pakulat apaku at gmx.de
Wed Nov 1 16:33:47 GMT 2006

On 31.10.06 16:28:32, Reza Salari wrote:
> I wrote a simple file manager for my program and thus I dug  some filesystem  classes of Qt.  Now I have two question:
> 1-Is there a way to provide file manager an "auto-refresh" capability? I mean something like Konq in which when I create some file from Konsole, Konq will instantly show it. Do I have to implement a loop for constantly checking current directory or there is a simpler way?

Konqueror probably does that via the KDirWatch class (somewhere in kio
IIRC). This classes uses various means to detect changes to the
file-system, among them a tool like fam/gamin, a kernel interface called
inotify and last but not least the polling method (the last one is what
you had in mind). If you can depend on PyKDE check out KDirWatch, if not
you may be able to find a python interface for fam/gamin.

> 2- I found Qt has lots of useful classes for filesystem related tasks (QDir,QFile,...), while python has methods of similar functionalities. I used both of them (Qt's and python's) and found no major difference in my simple program from speed aspect (although working with Qt's was simpler). I ask my question in general, which one better to use as a habit? Which one do you use for your serious programs? or it doesn't really matter? 

Well, I use QFile for reading files with Qt's stream operators, i.e. if
the content goes into some Qt (based) classes. For working on
paths/files I find the python os.path stuff easier to use and I use
simple file() whenever I feed the data to some python classes...


You are scrupulously honest, frank, and straightforward.  Therefore you
have few friends.

More information about the PyQt mailing list