当我尝试在文本浏览器中打开文本文件时出现此错误
def cari(self, event=None):
#open dialog
filename = QtGui.QFileDialog.getOpenFileName(self, 'Open File', '*.xml')
if filename:
self.ui.lineFile.delete(0, END)
self.ui.lineFile.insert(END, filename)
#call isi data
self.isiDataFile(filename)
def isiDataFile(self, nmfile):
#open with read mode
teksFile = open(nmfile, 'r').read()
self.ui.textFile.delete('1.0', END)
self.ui.textFile.insert('1.0', teksFile)
错误:
Traceback (most recent call last):
File "C:\Users\Mr.Pakde/.qgis2/python/plugins\latih\latihdialog.py", line 44, in cari
self.ui.lineFile.delete(0, END)
'QLineEdit' object has no attribute 'delete'
有人能帮助我吗?
答案 0 :(得分:0)
如果您看到docs,QLineEdit
(代码中为self.ui.lineFile
)没有delete
方法,但有del_
方法和backspace
方法。您可能想要使用其中一个。