[PyQt] Problem with QFileSystemWatcher
RUI.NARCISO at airbus.com
Thu Dec 9 12:26:40 GMT 2010
I can't seem to be able to make QFileSYstemWatcher work with a file (to see if it's contents change).
At the end of this mail you'll find a minimum example that doesn't worked.
I tried several connections with different syntaxes but nothing works.
The versions I have:
Linux Red Hat
Thanks for your help.
A minimum example is:
from PyQt4 import QtCore, QtGui
from os.path import isfile, exists
def __init__(self, parent=None):
self.watcher = QtCore.QFileSystemWatcher(self)
QtCore.QObject.connect(self.watcher,QtCore.SIGNAL("fileChanged(const QString&)"), self.file_changed)
QtCore.QObject.connect(self.watcher,QtCore.SIGNAL("fileChanged(const QString)"), self.file_changed)
self.filename = '/home/to96665/toto'
if not exists:
def file_changed(self, path):
response = False
# buttons texts
SAVE = 'Save As'
RELOAD = 'Reload File'
CANCEL = 'Cancel'
message = QtGui.QMessageBox(self)
message.setText('Open file have been changed !')
message.setDetailedText('The file "' + str(path) + '" have been changed or removed by other application. What do you want to do ?')
response = message.clickedButton().text()
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
myapp = StartQT4()
Data for Handling Qualities
Aerodynamics Department - EDGADY - M01 N368
AIRBUS Operations S.A.S.
Phone: +33 (0)5 61 18 10 77
Fax: +33 (0)5 61 93 99 80
<Mailto:rui.narciso at airbus.com>
* Before printing, think about ENVIRONMENTAL responsibility - ISO14001
The information in this e-mail is confidential. The contents may not be disclosed or used by anyone other than the addressee. Access to this e-mail by anyone else is unauthorised.
If you are not the intended recipient, please notify Airbus immediately and delete this e-mail.
Airbus cannot accept any responsibility for the accuracy or completeness of this e-mail as it has been sent over public networks. If you have any concerns over the content of this message or its Accuracy or Integrity, please contact Airbus immediately.
All outgoing e-mails from Airbus are checked using regularly updated virus scanning software but you should take whatever measures you deem to be appropriate to ensure that this message and any attachments are virus free.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the PyQt