<br><br><div class="gmail_quote">---------- Yönlendirilmiş ileti ----------<br>Kimden: <b class="gmail_sendername">Yaşar Arabacı</b> <span dir="ltr"><<a href="mailto:yasar11732@gmail.com">yasar11732@gmail.com</a>></span><br>
Tarih: 23 Temmuz 2011 08:07<br>Konu: Re: [PyQt] QFileDialog error<br>Kime: Martin Airs <<a href="mailto:camberwell@gmail.com">camberwell@gmail.com</a>><br><br><br>What happens when you assign it to its own string. Do you get error while assigning it to string or when using that string with file dialog?<div>
<div></div><div class="h5"><br><br><div class="gmail_quote">2011/7/23 Martin Airs <span dir="ltr"><<a href="mailto:camberwell@gmail.com" target="_blank">camberwell@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Good day all,<br>
<br>
In this test case script I have added at the bottom, It bombs with this error...<br>
<br>
[martin@desktop python]$ python testcase.py<br>
Traceback (most recent call last):<br>
File "testcase.py", line 17, in pressed<br>
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file', os.path.split(self.lineedit.text())[0], "logs")<br>
File "/usr/lib64/python2.7/posixpath.py", line 83, in split<br>
i = p.rfind('/') + 1<br>
AttributeError: 'QString' object has no attribute 'rfind'<br>
<br>
<br>
I cant quite work out why, if I take the *os.path.split(self.lineedit.text())* out and put it on a seperate line assigning it to its own<br>
string it still doesn't work<br>
<br>
I wonder if anyone could show me how to get round this, please<br>
<br>
Thanks in advance<br>
<br>
Martin Airs<br>
<br>
------------------------------------------------------<br>
import sys, os<br>
from PyQt4 import QtCore, QtGui<br>
<br>
class Window(QtGui.QWidget):<br>
def __init__(self, parent=None):<br>
QtGui.QMainWindow.__init__(self, parent)<br>
self.hbox = QtGui.QHBoxLayout()<br>
self.lineedit = QtGui.QLineEdit("", self)<br>
self.lineedit.setText("/var/log/test.log")<br>
self.button = QtGui.QPushButton("open file", self)<br>
self.hbox.addWidget(self.lineedit)<br>
self.hbox.addWidget(self.button)<br>
self.setLayout(self.hbox)<br>
self.button.clicked.connect(self.pressed)<br>
<br>
def pressed(self):<br>
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open file', os.path.split(self.lineedit.text())[0], "logs")<br>
<br>
app = QtGui.QApplication(sys.argv)<br>
window = Window()<br>
window.show()<br>
app.exec_()<br>
------------------------------------------------------<br>
_______________________________________________<br>
PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com" target="_blank">PyQt@riverbankcomputing.com</a><br>
<a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" target="_blank">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br>
</blockquote></div><br>
</div></div></div><br>