This is the first article posted. I would appreciate it if you could let me know if there are any improvements.
At first I thought I would call it "Password Management Tool", but due to security and versatility, it ended up like this ...
If you come up with a good name or explanation, please let me know!
It will be the following image. The color of the button is noisy and it looks like ...
When you press each button, the set character string is saved in the clipboard. I think it is convenient to set a password and frequently used character strings.
Seeing is believing, so please try it.
The following image has a directory structure. I think that it can be executed if you place the file as shown.
main.py
#Standard library
import configparser
import tkinter as tk
#Third party library
import pyperclip
#Application class
class Application(tk.Frame):
def __init__(self, master):
super().__init__(master)
master.geometry('388x310')
master.title('Password Tools')
self.Username, self.Password, self.Color = Config().Get_Data()
self.create_button(master)
def create_button(self, master):
for i in range(0, 6):
button = tk.Button(text=self.Username[i], width=50, height=2, bg=self.Color[i])
button.bind('<Button-1>', self.click_button)
button.place(x=13, y=5+i*50)
def click_button(self, event):
index = self.Username.index(event.widget['text'])
pyperclip.copy(self.Password[index])
#Config operation class
class Config():
def __init__(self):
self.config = configparser.ConfigParser()
self.config.read(r'.\UserSetting\config.ini', encoding='UTF-8')
def Get_Data(self):
Username = []
Password = []
Color = []
for i in range(1, 7):
Username.append(self.config.get('P-{}'.format(i), 'Username'))
Password.append(self.config.get('P-{}'.format(i), 'Password'))
Color.append(self.config.get('P-{}'.format(i), 'Color'))
return Username, Password, Color
def main():
App = Application(master=tk.Tk())
App.mainloop()
if __name__ == '__main__':
main()
My environment is windows10. For "MacOS" or "Linux", change the following statement before executing.
main.py
#For Mac or Linux, an error will occur if you do not execute after rewriting the path part.
# windows
self.config.read(r'.\UserSetting\config.ini', encoding='UTF-8')
↓
# Mac or Linux
self.config.read(r'./UserSetting/config.ini', encoding='UTF-8')
The user sets it in "config.ini". Username ← Button title name Password ← Character string saved in the clipboard when clicked Color ← Button color (color code) setting
config.ini
[P-1]
Username = 1u
Password = 1p
Color = #c0c0c0
[P-2]
Username = 2u
Password = 2p
Color = #c0c0c0
[P-3]
Username = 3u
Password = 3p
Color = #c0c0c0
[P-4]
Username = 4u
Password = 4p
Color = #c0c0c0
[P-5]
Username = 5u
Password = 5p
Color = #c0c0c0
[P-6]
Username = 6u
Password = 6p
Color = #c0c0c0
You can use pyinstaller or cx_freeze to create an exe file, so if you like, please use it as an exe file!
I think it's easier to save commands and fixed phrases that you type well.
I would be happy if you could get a request. I would like to post as much as I can.
I also uploaded it to GitHub, so by all means → https://github.com/Ryo-icy/ClipboardTool
Recommended Posts