From 2fc2e692ffc8efa813c10144a3890782f7102c2d Mon Sep 17 00:00:00 2001 From: SeydEf Date: Mon, 28 Aug 2023 00:21:44 +0330 Subject: [PATCH] In the Folder Locker & Hider script: 1-An eye button was added to the password fields to show the password 2-The file name bug with spaces was fixed --- Folder Locker & Hider/application.pyw | 34 +++++++++++++++++++++++---- Folder Locker & Hider/locker.py | 9 +++---- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/Folder Locker & Hider/application.pyw b/Folder Locker & Hider/application.pyw index e5bcbbc..7138dc8 100644 --- a/Folder Locker & Hider/application.pyw +++ b/Folder Locker & Hider/application.pyw @@ -87,9 +87,20 @@ class Application(tk.Frame): self.elabel['text'] = 'Enter Password' self.elabel.grid(row=1, column=0, pady=20) - self.entry = tk.Entry(self.body) + self.entry = tk.Entry(self.body, show="*") self.entry['textvariable'] = self.password - self.entry.grid(row=1, column=1, columnspan=2, pady=20) + self.entry.grid(row=1, column=1, columnspan=1, pady=20) + + def toggle_password_visibility(): + if self.entry['show'] == "": + self.entry['show'] = "*" + self.eye_button['text'] = "👁" + else: + self.entry['show'] = "" + self.eye_button['text'] = "👁" + + self.eye_button = tk.Button(self.body, text="👁", width=2, command=toggle_password_visibility) + self.eye_button.place(x=315, y=86) self.lock =tk.Button(self.body, bg='green', width=20) self.lock['text'] = f'Lock Folder' @@ -128,9 +139,20 @@ class Application(tk.Frame): self.elabel['text'] = 'Enter Password' self.elabel.grid(row=1, column=0, columnspan=2, pady=(1,1)) - self.entry = tk.Entry(self.body) + self.entry = tk.Entry(self.body, show="*") self.entry['textvariable'] = self.password - self.entry.grid(row=2, column=0, columnspan=2) + self.entry.place(x=53, y=96) + + def toggle_password_visibility(): + if self.entry['show'] == "": + self.entry['show'] = "*" + self.eye_button['text'] = "👁" + else: + self.entry['show'] = "" + self.eye_button['text'] = "👁" + + self.eye_button = tk.Button(self.body, text="👁", width=2, command=toggle_password_visibility) + self.eye_button.place(x=180, y=92.5) self.unlock =tk.Button(self.body, bg='green', width=20) self.unlock['text'] = f'Unlock Folder' @@ -210,8 +232,10 @@ class Application(tk.Frame): if __name__ == '__main__': root = tk.Tk() - root.geometry('400x305') root.title('Folder Locker/Unlocker') + x = (root.winfo_screenwidth() - 400) // 2 + y = (root.winfo_screenheight() - 300) // 2 + root.geometry(f"{400}x{300}+{x}+{y}") root.resizable(0,0) lock_icon = PhotoImage(file='icons/lock.png').subsample(2,2) diff --git a/Folder Locker & Hider/locker.py b/Folder Locker & Hider/locker.py index 7d19a35..643bfa1 100644 --- a/Folder Locker & Hider/locker.py +++ b/Folder Locker & Hider/locker.py @@ -1,9 +1,10 @@ -import os import json -import shelve +import os import random +import shelve import subprocess + def read_json(): json_file = 'files/locked_folders.json' if os.path.exists(json_file): @@ -35,7 +36,7 @@ def lock(fpath, password): fname = os.path.basename(fpath) cwd = '/'.join(fpath.split('/')[:-1]) + '/' - command1 = 'ren ' + fname + ' "Control Panel.{21EC2020-3AEA-1069-A2DD-' + key + '}"' + command1 = 'ren "' + fname + '" "Control Panel.{21EC2020-3AEA-1069-A2DD-' + key + '}"' command2 = 'attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-' + key + '}"' dct = read_json() @@ -61,7 +62,7 @@ def unlock(fpath, password, key): fname = os.path.basename(fpath) cwd = '/'.join(fpath.split('/')[:-1]) + '/' command1 = 'attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-' + key + '}"' - command2 = 'ren "Control Panel.{21EC2020-3AEA-1069-A2DD-' + key + '}" ' + fname + command2 = 'ren "Control Panel.{21EC2020-3AEA-1069-A2DD-' + key + '}" "' + fname + '"' with shelve.open('files/pwd') as pwd_manager: pass_ = pwd_manager[fname]