<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from rtf -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<font face="Arial, sans-serif" size="2">
<div>Hi all</div>
<div> </div>
<div>I can’t seem to be able to make QFileSYstemWatcher work with a file (to see if it’s contents change).</div>
<div>At the end of this mail you’ll find a minimum example that doesn’t worked.</div>
<div>I tried several connections with different syntaxes but nothing works.</div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div>The versions I have:</div>
<div><font face="Calibri, sans-serif" size="2"> <font face="Arial, sans-serif" size="2">Linux Red Hat</font></font></div>
<div><font face="Calibri, sans-serif" size="2"> <font face="Arial, sans-serif" size="2">PyQt 4.4.2</font></font></div>
<div> Qt 4.4.0</div>
<div> Python 2.5.2</div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div>Thanks for your help.</div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div>A minimum example is:</div>
<div>#!/usr/bin/env python</div>
<div> </div>
<div>import sys</div>
<div>from PyQt4 import QtCore, QtGui</div>
<div>import codecs</div>
<div>import codecs</div>
<div>from os.path import isfile, exists</div>
<div> </div>
<div>class StartQT4(QtGui.QMainWindow):</div>
<div> def __init__(self, parent=None):</div>
<div> QtGui.QWidget.__init__(self, parent)</div>
<div> self.watcher = QtCore.QFileSystemWatcher(self)</div>
<div> QtCore.QObject.connect(self.watcher,QtCore.SIGNAL("fileChanged(const QString&)"), self.file_changed)</div>
<div> QtCore.QObject.connect(self.watcher,QtCore.SIGNAL("fileChanged(const QString)"), self.file_changed)</div>
<div> QtCore.QObject.connect(self.watcher,QtCore.SIGNAL("fileChanged(QString)"), self.file_changed)</div>
<div> QtCore.QObject.connect(self.watcher,QtCore.SIGNAL("fileChanged"), self.file_changed)</div>
<div> self.filename = '/home/to96665/toto'</div>
<div> if not exists:</div>
<div> print "merde"</div>
<div> self.watcher.addPath(self.filename)</div>
<div> </div>
<div> </div>
<div> def file_changed(self, path):</div>
<div> response = False</div>
<div> # buttons texts</div>
<div> SAVE = 'Save As'</div>
<div> RELOAD = 'Reload File'</div>
<div> CANCEL = 'Cancel'</div>
<div> message = QtGui.QMessageBox(self)</div>
<div> message.setText('Open file have been changed !')</div>
<div> message.setWindowTitle('Notepad')</div>
<div> message.setIcon(QtGui.QMessageBox.Warning)</div>
<div> message.addButton(SAVE, QtGui.QMessageBox.AcceptRole)</div>
<div> message.addButton(RELOAD, QtGui.QMessageBox.DestructiveRole)</div>
<div> message.addButton(CANCEL, QtGui.QMessageBox.RejectRole)</div>
<div> message.setDetailedText('The file "' + str(path) + '" have been changed or removed by other application. What do you want to do ?')</div>
<div> message.exec_()</div>
<div> response = message.clickedButton().text()</div>
<div> </div>
<div>if __name__ == "__main__":</div>
<div> app = QtGui.QApplication(sys.argv)</div>
<div> myapp = StartQT4()</div>
<div> myapp.show()</div>
<div> sys.exit(app.exec_())</div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div style="margin-top: 5pt; margin-bottom: 5pt; "><font face="Book Antiqua, serif"><b>__________________________________________________</b><font face="Arial, sans-serif" size="3"> </font></font></div>
<div style="margin-top: 5pt; margin-bottom: 5pt; "><font face="Book Antiqua, serif"><b>Rui NARCISO<br>
</b><i>Data for Handling Qualities<br>
</i><i>Aerodynamics Department - EDGADY - M01 N368<br>
</i><b>AIRBUS Operations S.A.S.</b><font face="Arial, sans-serif" size="3"> </font></font></div>
<div><font face="Book Antiqua, serif"><i>Phone: +33 (0)5 61 18 10 77<br>
</i><i>Fax: +33 (0)5 61 93 99 80<br>
</i><font color="#0000FF"><u><i><b><</b></i></u></font><a href="Mailto:rui.narciso@airbus.com"><font color="#0000FF"><u><i><b>Mailto:rui.narciso@airbus.com</b></i></u></font></a><font color="#0000FF"><u><i><b>></b></i></u></font><font face="Arial, sans-serif" size="2">
</font></font></div>
<div><font face="Webdings, serif" size="7" color="#008000">P<font face="Times New Roman, serif" size="3" color="#000000"> </font><font face="Tahoma, sans-serif" size="2">Before printing, think about ENVIRONMENTAL responsibility - ISO14001</font></font></div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
<div><font face="Calibri, sans-serif" size="2"> </font></div>
</font>
<PRE>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.
</PRE></body>
</html>