Hi all
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
PyQt 4.4.2
Qt 4.4.0
Python 2.5.2
Thanks for your help.
A minimum example is:
#!/usr/bin/env python
import sys
from PyQt4 import QtCore, QtGui
import codecs
import codecs
from os.path import isfile, exists
class StartQT4(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
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)
QtCore.QObject.connect(self.watcher,QtCore.SIGNAL("fileChanged(QString)"),
self.file_changed)
QtCore.QObject.connect(self.watcher,QtCore.SIGNAL("fileChanged"),
self.file_changed)
self.filename = '/home/to96665/toto'
if not exists:
print "merde"
self.watcher.addPath(self.filename)
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.setWindowTitle('Notepad')
message.setIcon(QtGui.QMessageBox.Warning)
message.addButton(SAVE, QtGui.QMessageBox.AcceptRole)
message.addButton(RELOAD, QtGui.QMessageBox.DestructiveRole)
message.addButton(CANCEL, QtGui.QMessageBox.RejectRole)
message.setDetailedText('The file "' + str(path) + '" have been
changed or removed by other application. What do you want to do ?')
message.exec_()
response = message.clickedButton().text()
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
myapp = StartQT4()
myapp.show()
sys.exit(app.exec_())
__________________________________________________
Rui NARCISO
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:[email protected]>
* 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.
_______________________________________________
PyQt mailing list [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt