Help from Facebook

import sys
from PyQt6.QtWidgets import QApplication, QWidget, QPlainTextEdit, QMainWindow, QPushButton, QVBoxLayout, QHBoxLayout, QLabel

class Beispielfenster(QMainWindow):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        central_widget = QWidget()
        self.setCentralWidget(central_widget)

        layout = QVBoxLayout(central_widget)

        self.input_text = QPlainTextEdit()
        layout.addWidget(QLabel("Eingabetext:"))
        layout.addWidget(self.input_text)

        self.output_text = QPlainTextEdit()
        self.output_text.setReadOnly(True)
        layout.addWidget(QLabel("Übersetzter Text:"))
        layout.addWidget(self.output_text)

        button_ok = QPushButton("Text übersetzen")
        cancel_button = QPushButton("Abbrechen")
        clear_button = QPushButton("Text löschen")
        copy_button = QPushButton("Text kopieren")
        button_layout = QHBoxLayout()
        button_layout.addWidget(button_ok)
        button_layout.addWidget(cancel_button)
        button_layout.addWidget(clear_button)
        button_layout.addWidget(copy_button)
        layout.addLayout(button_layout)

        

        self.setGeometry(300, 300, 400, 400)
        self.setWindowTitle('Übersetzung von englisch in Deutsch')

        button_ok.clicked.connect(self.on_ok_clicked)
        cancel_button.clicked.connect(self.on_cancel_clicked)
        clear_button.clicked.connect(self.clear_text)  # Verbinden Sie den Clear-Button mit der Methode
        copy_button.clicked.connect(self.copy_to_clipboard)  # Verbinden Sie den neuen Button

    def on_ok_clicked(self):
        input_text = self.input_text.toPlainText()
        input_text = input_text.lower()
        ersetzungen = {
            "Сhangе the сolоr tо ":"zur Farbe wechseln",
            "Fastеn, сut the thread. Wе knit the sеcоnd оnе in the sаmе waу, οnly wе do not cυt thе thread, but we knіt fυrther.":"Befestigen, Faden abschneiden. Den zweiten fertigen wir auf die gleiche Weise, nur schneiden wir den Faden nicht ab, sondern stricken weiter.",
            "Fastеn, сut the thread.":"Befestigen, Faden abschneiden.",
            "do not cυt thе thread,":"den Faden nicht abschneiden",
            "break yarn and leave enough yarn ": "Garn abreißen und genügend Garn übrig lassen",
            "in each stitch*":"in jede Masche*",
            "crochet the two sides together with slip stitches":"Die beiden Seiten mit Kettmaschen zusammenhäkeln",
            "Fold the legs":"Falte die Beine",
            "in back of chaіn":"ins hintere Maschenglied",
            
            "shield ":"Panzer ",
            "(10 sc, dec) х 5, ": "(10 fM,Abn) x 5",
            "not cυt thе thread, ": "den Faden nicht abschneiden",
            "(1 sc, іnc) х 6": "(1 fM, Zun) х 6)",
            "break yarn":"Garn abschneiden",
            "(6 sc, dес) х 5": "6 fM, Abn) x 5",
            "dec, (4 sс, dеc) x 5": "Abn, (4 fM; Abn) x 5",
            " (7 sc, deс) х 6 (48)": "(7 fM, Abn) x 6",
            " (4 sс, dеc) x 5,": "(4 fM, Abn) x 5",
            "сut the thread.": "Faden abschneiden",
            "сhangе the сolоr tо gray.": "zur Farbe grau wechseln",
            " іn ka ": "in den Maschenring",
            "we stаrt knіttіng with whіtе уаrn.": "wir beginnen mit weissem Garn.",
            "runde 3: (1 fm, zun) * 6 = 18": "round 3: (1 sc, inc) * 6 = 18",
            "runde 4: (2 fm, zun) * 6 = 24": "round 4: (2 sc, inc) * 6 = 24",
            "runde 5: (3 fm, zun) * 6 = 30": "round 5: (3 sc, inc) * 6 = 30",
            "runde 6: (4 fm, zun) * 6 = 36": "round 6: (4 sc, inc) * 6 = 36",
            "runde 7: (5 fm, zun) * 6 = 42": "round 7: (5 sc, inc) * 6 = 42",
            "runde 8: (6 fm, zun) * 6 = 48": "round 8: (6 sc, inc) * 6 = 48",
            "runde 9: (7 fm, zun) * 6 = 54": "round 9: (7 sc, inc) * 6 = 54",
            "runde 10: (8 fm, zun) * 6 = 60": "round 10: (8 sc, inc) * 6 = 60",
            "runde 11: (9 fm, zun) * 6 = 66": "round 11: (9 sc, inc) * 6 = 66",
            "runde 12: (10 fm, zun) * 6 = 72": "round 12: (10 sc, inc) * 6 = 72",
            " after increases,": "Nach den Zunahmen",
            "slip stitches":"Kettmasche",
            "back legs":"Hinterbeine",
            "back Beine":"Hinterbeine",
            " sc ": " fM",
            " іnс ":" Zun ",
            " inc ": " Zun",
            " dec ": " Abn",
            "dec,": "Abn,",
            "slst": "KM",
            "black": "schwarz",
            "round": "Runde",
            "row": "Reihe",
            "rounds": "Runden",
            "Cut and fasten off the yarn,": "Den Faden abschneiden und vernähen,",
            "leg": "Bein",
            "legs": "Beine",
            "вοdу":"Körper",
            " inc)":"Zun)",
            "arm": "Arm",
            "arms": "Arme",
            "head": "Kopf",
            "body": "Körper",
            "(make 2)": "(2 anfertigen)",
            "inc,": "Zun,",
            "Row": "Reihe",
            " sc ": " fM ",
            "dеc,":"Abn, ",
            " sc":" fM",
            "іnс) ":"Zun) ",
            "blue": "blau",
            "we рut а markеr.":"wir bringen einen Markierer an",
            "dec)": "Abn)",
            "Left Hand": "linke Hand",
            "row":"Reihe",
            "Fingers": "Finger",
            "on the first finger,": "am ersten Finger,",
            "finger,": "Finger",
            "tail": "Schwanz",
            "inc in each stitch around ": "Zun in jede Masche",
            "in the amigurumi ring, ": "in den Amigurumi Ring,",
            "in the amigurumi ring ": "in den Ammigurumi Ring",
            "in each stitch aRunde ": "in jede Masche ringsherum",
            "(2 parts)": "2 Teile",
            " inc ": " Zun ",
            " sc ": " fM ",
            " abfMhneiden": "abschneiden",
            "Beins": "Beine",
            " іn ka": " in den Maschenring",
            "сh,": "LM, ",
            "sc, ": "fM, ",
            "dec, ": "Abn, ",
            " sс": " fM",
            "dес) x 6 ": "Abn) x 6",
            "inc) x 6": "Zun) x 6",
            "inc) x 5": "Zun) x 5",
            "legs": "Beine",
            " leg ": " Bein",
            "row:": "Reihe:",
            "inc) x5,":"Zun) x 5",
            "yellow":"gelb",
            "green":"grün",
            "gray.":"grau.",
            "gray":"grau",
            "row:":"Reihe",
            " іnс,":"Zun,",
            "rοw:":"Reihe:",
            "sbn":"fM",
            "in magic ring " :"in den Maschenring",
            "*inc*":"*Zun*",
            "sts) ":"Maschen)",
            "inc*":"Zun",
            "dec,":"Abn,",
            "inc,":"Zun,",
            "inc* 5x,":"Zun * 5",
            "in each stitch":"in jede Masche",
            "MafMhe*":"Masche",
            "јoіn with Bein 1,": "mit dem ersten Bein verbinden", 

        }
        uebersetzung = input_text
        for alt, neu in ersetzungen.items():
            uebersetzung = uebersetzung.replace(alt, neu)
        self.output_text.setPlainText(uebersetzung)

    def on_cancel_clicked(self):
        print("Abbrechen wurde geklickt")
        self.close()

    def clear_text(self):
        # Funktion zum Löschen des Textes
        self.input_text.clear()
        self.output_text.clear()
        print("Text wurde gelöscht")

    def copy_to_clipboard(self):
        # Kopiert den übersetzten Text in die Zwischenablage
        clipboard = QApplication.clipboard()
        clipboard.setText(self.output_text.toPlainText())
        print("Text wurde in die Zwischenablage kopiert")

            

if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = Beispielfenster()
    ex.show()
    sys.exit(app.exec())

Schreibe einen Kommentar