-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTokenGUI.py
65 lines (52 loc) · 1.48 KB
/
TokenGUI.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
import getpass
import json
import tkinter as tk
from getpass import getuser
def getToken():
root = tk.Tk()
root.config(width=15)
# root.geometry("500x150")
frame = tk.Frame(master=root, relief=tk.RAISED, borderwidth=1, bg="White")
frame.pack(fill=tk.X)
label = tk.Label(
master=frame,
text="Podaj osobisty token ClickupAPI",
font=("SEGOEUIL", "15", "bold"),
bg="White",
)
label.pack()
text = tk.Text(
master=root,
bg="White",
relief=tk.RIDGE,
borderwidth=1,
height=1,
width=75,
font=("SEGOEUIL", "15"),
)
text.pack(fill=tk.BOTH)
global succes
succes = False
def saveToken():
token = text.get(0.0, tk.END)
token = token.replace("\n", "")
if str(token).startswith("pk_"):
user = getuser()
js = {"Authorization": token}
with open(
f"C:\\Users\\{user}\\AppData\\Local\\ClickupWidget\\tk.json", "w"
) as file:
json.dump(js, file)
print("Token Saved")
label["text"] = "Zapisano Token"
global succes
succes = True
root.destroy()
root.quit()
else:
label["text"] = "Nieprawidłowy token, podaj inny"
Button = tk.Button(
master=root, text="Zapisz token", font=("SEGOEUIL", "15"), command=saveToken
).pack(fill=tk.X)
root.mainloop()
return succes