threads __init__, pyside6->pyqt6

This commit is contained in:
WorldTeacher
2024-05-07 15:33:35 +02:00
parent 24eefd9473
commit e999c51863
34 changed files with 972 additions and 985 deletions

View File

@@ -2,7 +2,7 @@ import os
import sys
from omegaconf import OmegaConf
from PySide6 import QtCore, QtGui, QtWidgets
from PyQt6 import QtCore, QtGui, QtWidgets
from src.ui.dialogs.Ui_mail_preview import Ui_eMailPreview as Ui_Dialog
@@ -38,13 +38,23 @@ class Mail_Dialog(QtWidgets.QDialog, Ui_Dialog):
self.prof_name.setText(prof_name)
self.mail_name.setText(self.prof_mail)
self.load_mail_templates()
# if default_mail is not None:
# # get the nearest match to the default mail
# for i in range(self.comboBox.count()):
# if default_mail in self.comboBox.itemText(i):
# default_mail = self.comboBox.itemText(i)
# break
# self.comboBox.setCurrentText(default_mail)
# if none of the radio buttons is checked, disable the accept button of the dialog
if (
self.gender_female.isChecked()
or self.gender_male.isChecked()
or self.gender_male.isChecked()
):
self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(True)
else:
self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(False)
if default_mail is not None:
# get the nearest match to the default mail
for i in range(self.comboBox.count()):
if default_mail in self.comboBox.itemText(i):
default_mail = self.comboBox.itemText(i)
break
self.comboBox.setCurrentText(default_mail)
self.gender_female.clicked.connect(self.set_mail)
self.gender_male.clicked.connect(self.set_mail)
@@ -66,12 +76,13 @@ class Mail_Dialog(QtWidgets.QDialog, Ui_Dialog):
self.comboBox.addItem(template)
def get_greeting(self):
prof = self.profname
if self.gender_male.isChecked():
return "Sehr geehrter Herr"
return f"Sehr geehrter Herr {prof.split(' ')[-1]},"
elif self.gender_female.isChecked():
return "Sehr geehrte Frau"
return f"Sehr geehrte Frau {prof.split(' ')[-1]},"
elif self.gender_non.isChecked():
return "Guten Tag"
return f"Guten Tag {prof},"
def set_mail(self):
email_template = self.comboBox.currentText()
@@ -97,6 +108,7 @@ class Mail_Dialog(QtWidgets.QDialog, Ui_Dialog):
)
self.mail_body.setHtml(mail_html)
self.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).setEnabled(True)
def createAndSendMail(self):
import smtplib
@@ -176,3 +188,10 @@ if __name__ == "__main__":