-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCOPIKANA_1.1.py
121 lines (99 loc) · 3 KB
/
COPIKANA_1.1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import pykakasi
import pyperclip
import base64
import os
import tkinter as tk
from tkinter import ttk
import webbrowser
def to_hira(): # Convert kanji to hiragana
kks = pykakasi.kakasi()
clipboard_text = pyperclip.paste() # Get text from clipboard
result = kks.convert(clipboard_text)
hira_text = ""
for item in result: # Keep hiragana only from result
hira_text += item["hira"] + " "
label.config(text=hira_text)
def to_hepburn(): # Convert kanji to hiragana
kks = pykakasi.kakasi()
clipboard_text = pyperclip.paste() # Get text from clipboard
result = kks.convert(clipboard_text)
hepburn_text = ""
for item in result: # Keep hiragana only from result
hepburn_text += item["hepburn"] + " "
label.config(text=hepburn_text)
def to_mode(x=None): # Mode switch
if int(toggle.get()) == 0:
to_hira() # Convert to hiragana
elif int(toggle.get()) == 1:
to_hepburn() # Convert to Hepburn romanization
return
def update_label():
clipboard_text = str(pyperclip.paste())
label_text = str(label.cget("text"))
if clipboard_text != label_text:
to_mode()
else:
pass
root.after(500, update_label)
def change_size(x):
size = int(float(x))
label.config(font=("MS PGothic", size))
# Creat a window
root = tk.Tk()
root.title("COPIKANA 1.0")
root.geometry("+100+100")
root.attributes("-topmost", True)
style = ttk.Style()
style.theme_use("winnative")
style.configure("Horizontal.TScale")
try:
from COPIKANA_logo import img
temp = open("temp.ico", "wb+") # Create a temp file to hold icon
temp.write(base64.b64decode(img))
temp.close()
root.iconbitmap("temp.ico")
os.remove("temp.ico")
except ModuleNotFoundError:
def open_link(event):
webbrowser.open("https://ko-fi.com/s/b8e4f06daa")
alt = tk.Tk()
alt.title("❤︎ COPIKANA?")
alt.geometry("+100+10")
alt.attributes("-topmost", True)
shop = tk.Label(
alt,
font=(
"",
16,
),
text="𝐒𝐮𝐩𝐩𝐨𝐫𝐭 𝐦𝐞 𝐚𝐧𝐝 𝐫𝐞𝐜𝐞𝐢𝐯𝐞 𝐭𝐡𝐞 𝐞𝐱𝐜𝐥𝐮𝐬𝐢𝐯𝐞 𝐥𝐨𝐠𝐨! 🎁",
)
shop.pack()
kofi = tk.Label(
alt,
font=("", 18, "underline"),
text="👉 𝐆𝐨 𝐭𝐨 𝐦𝐲 𝐊𝐨-𝐟𝐢 𝐬𝐡𝐨𝐩",
fg="#F05312",
cursor="hand2",
)
kofi.pack()
kofi.bind("<Button-1>", open_link)
# Creat frames
frame1 = tk.Frame(root)
frame2 = tk.Frame(root)
# Creat a scale to change mode
toggle = ttk.Scale(frame1, to=1, length=15, orient="horizontal", command=to_mode)
# Creat a scale to change size
scale = ttk.Scale(
frame1, from_=17, to=51, length=225, orient="horizontal", command=change_size
)
# Create a label
label = tk.Label(frame2, font=("MS PGothic", 17), wraplength=720)
update_label()
# Position the widgets
frame1.pack(fill="x")
toggle.pack(side="left")
scale.pack(fill="x")
frame2.pack()
label.pack()
root.mainloop()