Skip to content

Commit

Permalink
Disable save and copy buttons when multiple files are encrypted
Browse files Browse the repository at this point in the history
  • Loading branch information
Yilmaz4 committed Jul 1, 2022
1 parent ff68d91 commit cc2fd9c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion main.pyw
Original file line number Diff line number Diff line change
Expand Up @@ -540,14 +540,16 @@ class Cryptography(object):
root.lastEncryptedFile = root.fileEntryVar.get() if bool(root.dataSourceVar.get()) else None

failure = False
root.mainNotebook.encryptionFrame.outputFrame.saveOutputButton.configure(state=DISABLED)
root.mainNotebook.encryptionFrame.outputFrame.saveOutputButton.configure(state=NORMAL)
root.mainNotebook.encryptionFrame.outputFrame.copyOutputButton.configure(state=NORMAL)
if len(datas) != 1 and bool(root.dataSourceVar.get()):
# If multiple files were encrypted, don't show the result (because how are we supposed to show anyway)
root.mainNotebook.encryptionFrame.outputFrame.outputText.configure(foreground="gray", wrap=WORD)
root.mainNotebook.encryptionFrame.outputFrame.outputText.replace("Encrypted data is not being displayed because multiple files were selected to be encrypted.")
if hasattr(root, 'lastEncryptionResult'):
del root.lastEncryptionResult
root.mainNotebook.encryptionFrame.outputFrame.saveOutputButton.configure(state=DISABLED)
root.mainNotebook.encryptionFrame.outputFrame.copyOutputButton.configure(state=DISABLED)
elif hasattr(root, "lastEncryptionResult") and len(root.lastEncryptionResult) > 15000:
# If one file was chosen or a plain text was entered to be encrypted, but the result is over 15.000 characters, don't show the result
root.mainNotebook.encryptionFrame.outputFrame.outputText.configure(foreground="gray", wrap=WORD)
Expand Down Expand Up @@ -733,6 +735,8 @@ class Cryptography(object):
self.update_status("Ready")
return

root.mainNotebook.decryptionFrame.decryptSaveButton.configure(state=NORMAL)
root.mainNotebook.decryptionFrame.decryptCopyButton.configure(state=NORMAL)
self.update_status("Displaying the result...")
try:
root.lastDecryptionResult = root.lastDecryptionResult.decode("utf-8")
Expand All @@ -748,6 +752,8 @@ class Cryptography(object):
except AttributeError:
root.mainNotebook.decryptionFrame.decryptOutputText.configure(foreground="gray")
root.mainNotebook.decryptionFrame.decryptOutputText.replace("Decrypted data is not being displayed because multiple files were selected to be decrypted.")
root.mainNotebook.decryptionFrame.decryptSaveButton.configure(state=DISABLED)
root.mainNotebook.decryptionFrame.decryptCopyButton.configure(state=DISABLED)
else:
if not len(root.lastDecryptionResult) > 15000:
root.mainNotebook.decryptionFrame.decryptOutputText.configure(foreground="black")
Expand Down

0 comments on commit cc2fd9c

Please sign in to comment.