Software that saves the set character string to the clipboard when you click the [Python] button

Introduction

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!

What I created this time

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.

image.png

Source code

The following image has a directory structure. I think that it can be executed if you place the file as shown.

ディレクトリ構造.png

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

Finally

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

Software that saves the set character string to the clipboard when you click the [Python] button
Python version (PHP to Python) that deletes the subsequent character string from the specified character string (extension)
A Python script that saves a clipboard (GTK) image to a file.
[Python] Programming to find the number of a in a character string that repeats a specified number of times.
[Introduction to Python] How to split a character string with the split function
Python Note: When you want to know the attributes of an object
[Introduction to Python] How to write a character string with the format function
[Introduction to Python] Thorough explanation of the character string type used in Python!
Move the turtle to the place where you click the mouse with turtle in Python
[Python] How to invert a character string
[Pandas] Expand the character string to DataFrame
[Python3] Code that can be used when you want to change the extension of an image at once
[Python] Solution to the problem that elements are linked when copying a list
What you want to memorize with the basic "string manipulation" grammar of python
When you can't uninstall the python library. Can't uninstall'hogehoge'. No files were found to uninstall.
When you want to update the chrome driver.
Python Note: When assigning a value to a string
A story that failed when trying to remove the suffix from the string with rstrip
A story that got stuck when trying to upgrade the Python version on GCE
[Ansible] Example of playbook that adds a character string to the first line of the file
[Introduction to Python] Basic usage of the library scipy that you absolutely must know
[Python] Leave only the elements that start with a specific character string in the array
[Linux] When you want to search for a specific character string from multiple files
[Python] How to expand variables in a character string
# Function that returns the character code of a string
Specifies the function to execute when the python program ends
[Introduction to Udemy Python3 + Application] 30. How to use the set
I felt that I ported the Python code to C ++ 98.
What to do when you can't bind CaboCha to Python
I tried to summarize the string operations of Python
Jedi-vim shortcut command that allows you to refer to the definition source and definition destination in Python
How to quickly count the frequency of appearance of characters from a character string in Python?
[Python3] Code that can be used when you want to resize images in folder units
[Python] When you want to import and use your own package in the upper directory
When a character string of a certain series is in the Key of the dictionary, the character string is converted to the Value of the dictionary.
A Python script that allows you to check the status of the server from your browser