-2

def file_open(self): fname, _ = QFileDialog.getOpenFileName(self, 'Open', 'Desktop', 'Text documents (.txt);;Word documents (.docx)') self.setWindowTitle(fname) with open(fname, 'r') as f: if fname.endswith('.txt'): fileText = f.read() Plain_Text=(self.mytext.setPlainText(fileText)) #print(fileText) is ok print(str(Plain_Text))

       # elif fname.endswith('.docx'):
            #doc = docx.Document(fname)
            #data=""
            #fileText=[]
            #for para in doc.paragraph:
               # fileText.append(para.text)
               # data="\n".join(fileText)
            #fileText = '\n'.join([para.text for para in doc.paragraphs])
            #self.textdata.toPlainText(data)
            #self.current_path = fname
def findletter(self,fileText):
    #print(fileTextil)
    myletter=str(self.tbox.text())
    lines = fileText.split('\n')
    for line in lines:
     words = line.split()
     for i in words:
        for letter in i:
            if(letter==myletter):
                k=k+1
            print("Occurrences of the letter:")
            print(k)
            
  • 1
    What are you asking ? Can you give us an indication of what you've tried and why it's not working as deisred? Please edit the question and title. Try to include a [mre], if possible. Have a look at [ask]. – Hoodlum Aug 03 '23 at 06:29
  • print(str(Plain_Text)) Plain_Text there is no data show.... – Imdad Ullah Aug 04 '23 at 06:15

0 Answers0