0
I’m having trouble getting the button to run a def and make a simple encryption and then display on the screen.
import tkinter as tk
from tkinter import *
class Application():
def __init__(self, toplevel):
toplevel.title('teste')
self.fr1 = Frame(toplevel)
self.fr1.pack()
self.fr2 = Frame(toplevel)
self.fr2.pack()
self.fr3 = Frame(toplevel)
self.fr3.pack()
self.fr4 = Frame(toplevel,pady=10)
self.fr4.pack()
self.fr5 = Frame(toplevel,pady=10)
self.fr5.pack()
Label(self.fr1,
text='Msg corpo ',
fg='darkblue',font=('Verdana','12','bold'), heigh=5).pack()
Label(self.fr1,
text='msg instrução',
fg='darkblue',font=('Verdana','8','bold'), heigh=5).pack()
fonte1=('Verdana','10','bold')
Label(self.fr2,text='Digite a mensagem: ',font=fonte1,width=20).pack(side=LEFT)
self.nome=Entry(self.fr2,width=50,font=fonte1)
self.nome.focus_force()
self.nome.pack(side=LEFT)
Label(self.fr3,text='Chave: ', font=fonte1, width=20).pack(side=LEFT)
self.cifra=Entry(self.fr3, width=15, font=fonte1)
self.cifra.pack()
self.travar=Button(self.fr4, text='Cripitografar', fg='black', )
self.destravar=Button(self.fr4, text='Descriptografar', fg='black', )
self.travar.pack(side=LEFT)
self.destravar.pack(side=RIGHT)
Label(self.fr5,text=' = ', font=fonte1, width=20).pack(side=LEFT)
self.msg=Label(self.fr5, width=50, font=fonte1)
self.msg.pack()
def travar():
nomes = self.nome.get()
cifras = self.cifra.get()
for i in range(len(nome)):
print(chr(ord(nome[i]) + cifra), end='')
print('')
root = tk.Tk()
app = Application(root)
root.mainloop()
#raiz=Tk()
##Janela(raiz)
#raiz.mainloop()