Hi, ich soll für die Schule in Informatik ein Verschlüsselungsprogramm schreiben. Ich habe hier die Caeser verschlüsselung genommen. Der Code hat ohne Tkinter Super Funktioniert:
def Code():
code = input("Code: ")
Verschiebung = int(input("Verschiebungsfaktor: "))
coded = "".join(chr((ord(char) + Verschiebung) % 256) for char in code)
print("Verschlüsselter Code:", coded)
def Encode():
code = input("Verschlüsselung: ")
x = int(input("Verschiebungsfaktor: "))
Verschiebung = -x
encoded = "".join(chr((ord(char) + Verschiebung) % 256) for char in code) print("Entschlüsselter Code:", encoded)
Hier ist der Code mit Tkinter:
from tkinter import *
def Code():
code = input(b.get())
Verschiebung = int(input(d.get()))
coded = "".join(chr((ord(char) + Verschiebung) % 256) for char in code)
h.config(text=coded)
def Encode():
code = input(b.get())
x = int(input(d.get()))
Verschiebung = -x
encoded = "".join(chr((ord(char) + Verschiebung) % 256) for char in code)
h.config(text=encoded)
F = Tk()
F.title('Coding')
F.geometry('500x500')
F.config(bg='gray')
a = Label(master=F, text='Eingabe:', fg='white', bg='black', font=('Arial',16))
a.place(x=50, y=50, width=200, height=50)
b = Entry(master=F, text='', font=('Arial',16))
b.place(x=275, y=50, width=200, height=50)
c = Label(master=F, text='Schlüssel:', fg='white', bg='black', font=('Arial',16))
c.place(x=50, y=125, width=200, height=50)
d = Entry(master=F, text='', font=('Arial',16))
d.place(x=275, y=125, width=200, height=50)
e = Button(master=F, text='Verschlüsseln', fg='white', bg='black', font=('Arial',16), command=Code)
e.place(x=50, y=200, width=200, height=50)
g = Button(master=F, text='Entschlüsseln', fg='white', bg='black', font=('Arial',16), command=Encode)
g.place(x=275, y=200, width=200, height=50)
h = Label(master=F, text='', font=('Arial',16))
h.place(x=50, y=275, width=425, height=50)
F.mainloop()
Das Problem ist, das sich Tkinter aufhängt und abstürtzt wenn ich einen Button drücke