so, I'm now in a personal project (just to try myself) with python + tkinter. It is a encrypter, which means that it gets a piece of text and encrypts it using some famous cyphers (like the numerical cypher, the caesar's cypher, and others).
Now, I wanted to give the user the option to save the text he encrypted, and also the encrypted text generated by the program. For that, I created two checkbutton on the program's menu: one for "save text" and the other for "save encrypted text". My question is, I tried to attach a function as it's command option, so, I guess it should run that function when the option is clicked. But it isn't happening.
I'll just explain what the funcitions shouls do before passing the code.
They should prompt a question, asking the user if he/she really wants to create a text file with the text and the encrypted text (This isn't a database, it's just something for the user to be able to read later the text's he/she encrypted and the encrypted version, if he/she wants to).
So, to the code:
encryptermenu = Menu(menubar, tearoff=0)
encryptermenu.add_checkbutton(label="Save Text", variable=v, command=saveText)
encryptermenu.add_checkbutton(label="Save Encrypted Text", variable=w, command=saveEncryptedText)
menubar.add_cascade(label="Encrypter", menu=encryptermenu)
The checkbutton options, and now the functions:
def saveText():
sdtst = messagebox.askyesno(title="Save Text", message="A .txt file will be created at the same directory as this program to save the text you decided to encrypt. Is it ok?")
def saveEncryptedText():
sdtset = messagebox.askyesno(title="Save Encrypted Text", message="A .txt file will be created at the same directory as this program to save the encrypted text generated by this program. Is it ok?")
Should the checkbutton really run the function on-click or am I just making confusion? Anyway, hope someone will help me.
add_checkbuttoninstead ofadd_command?