So, I made an encryption program a while back, and I want to give it a UI using Tkinter. What I'm doing is using three entry fields and a button; the first field is for the plaintext, and the result of encrypting it is put into the other two fields. The process is activated by a button at the bottom. The function crypt()
returns an array with the crypted string and key.
Here's a part of the source code:
class App(Frame):
def createWidgets(self):
self.quitButton = Button(self, text='Quit', command= self.quit())
self.quitButton.grid(row = 5, column = 2)
self.crypter_lab = Label(self, text = "Text to Encrypt").grid(row = 0, column = 0)
self.to_crypt = Entry(self)
self.to_crypt.grid(row = 0, column = 1)
self.crpt_lab = Label(self, text = "Crypted Text")
self.crpt_lab.grid(row = 1, column = 0)
self.outcrpt = Entry(self, state = DISABLED)
self.outcrpt.grid(row = 1, column = 1)
self.key_lab = Label(self, text = "Encryption Key")
self.key_lab.grid(row = 2, column = 0)
self.outkey = Entry(self, state = DISABLED)
self.outkey.grid(row = 2, column = 1)
def return_to_forms(self):
result = crypt(self.to_crypt.get())
self.outcrpt.insert(0,result[0])
self.outkey.insert(0,result[1])
print(result)
self.cryptbut = Button(self, text = "Encrypt", command = return_to_forms(self))
self.cryptbut.grid(row = 3, column = 1)
def __init__(self, master = None):
Frame.__init__(self,master)
self.grid()
self.createWidgets()
application = App()
application.master.title('Crypter')
application.mainloop()
The issue is that for whatever reason, crypt
runs automatically and prints ['',''] to the console.