[PyQt] How to add ftp put function in PyQT network ftp demo
Robert Kent
rob at gulon.co.uk
Tue Jul 1 11:50:24 BST 2014
You need to keep the handle to your QFile object in scope. The put() method
returns straight away and the data to be put is added to a queue and
uploaded in the background. Your selectFile() method returns straight away
therefore your upload_file object goes out of scope before it can be sent.
Simply changing upload_file to self.upload_file will solve your problem.
Hope this helps ;o)
Rob
From: 不坏阿峰 <onlydebian at gmail.com>
Date: Tuesday, 1 July 2014 03:30
To: <pyqt at riverbankcomputing.com>
Subject: [PyQt] How to add ftp put function in PyQT network ftp demo
I want to modify the pyqt network ftp demo to include an upload function,
but I am failing. Could someone can show me how to do this? I have tried to
add this code, but it does not work. [Orignal
Demo]https://github.com/Werkov/PyQt4/blob/master/examples/network/ftp/ftp.py
buttonBox.addButton(self.uploadButton,
QtGui.QDialogButtonBox.ActionRole)
self.uploadButton = QtGui.QPushButton("upload")
self.uploadButton.clicked.connect(self.selectFile)def selectFile(self):
self.filename =QtGui.QFileDialog.getOpenFileName()
up_fname = re.sub(r".*/","",self.filename)
upload_file = QtCore.QFile(self.filename)
self.ftp.put(upload_file, up_fname)
_______________________________________________ PyQt mailing list
PyQt at riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20140701/921b83ae/attachment.html>
More information about the PyQt
mailing list