'Whenever i add a file , it shuts down my Gui without throwing any error , i dont know what to do

def attach_sth(self):
    options = QFileDialog.Options()
    filenames, _ = QFileDialog.getOpenFileNames(self, "Open File", "", "All Files 
      (*.*)", options=options)
    if filenames != []:
        for filename in filenames:
            attachment = open(filename, 'rb')

            filename = filename[filename.rfind("/") + 1:]

            p = MIMEBase('application', 'octet-stream')
            p.set_payload(attachment.read())
            encoders.encode_base64(p)
            p.add_header("Content-Disposition", f"attachment; filename={filename}")
            self.msg.attach(p)
            if not self.label10.text().endswith(":"):
                self.label10.setText(self.label10.text() + ",")
            self.label10.setText(self.label10.text + " " + filename)

just don't know what's wrong with this code!!! plz help me whats the error indespite i really dont know whats the error



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source