-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAlPythonPackageInstaller.py
128 lines (109 loc) · 5.11 KB
/
AlPythonPackageInstaller.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
122
123
124
125
126
127
128
import subprocess
from tkinter import Tk, END, Frame, SUNKEN, Button, X, Text
from tkinter import font, Label, Entry, BOTH
import pyttsx3
from PIL import ImageTk, Image
import os
cwd = os.path.dirname(os.path.realpath(__file__))
class AlPythonPackageInstaller():
def __init__(self):
root = Tk(className=" ALPYTHONPACKAGEINSTALLER ")
root.geometry("400x200+1500+815")
root.resizable(0, 0)
root.iconbitmap(os.path.join(cwd + '\\UI\\icons',
'alpythonpackageinstaller.ico'))
root.config(bg="#0d4b98")
root.overrideredirect(1)
color = '#0d4b98'
def callback(event):
root.geometry("500x750+1410+300")
def showScreen(event):
root.deiconify()
root.overrideredirect(1)
def screenAppear(event):
root.overrideredirect(1)
def hideScreen():
root.overrideredirect(0)
root.iconify()
def speak(audio):
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[0].id)
engine.say(audio)
engine.runAndWait()
def install():
text.delete(1.0, END)
package = pythonPackage.get()
check = subprocess.getoutput('pip install ' + package)
if '==' in package:
package = package.split('==')[0]
alreadyInstalled = 'Requirement already satisfied: ' + package
nowInstalled = 'Successfully installed ' + package
errorInstalling = 'ERROR: Could not find a version that satisfies'\
'the requirement ' + package
someError = 'ERROR: '
var = check.split('\n')
if nowInstalled in var[-1]:
text.insert(1.0, var[-1])
speak('Successfully installed ' + package)
elif len(var) >= 3 and nowInstalled in var[-3]:
text.insert(1.0, var[-3])
speak('Successfully installed ' + package)
elif alreadyInstalled in var[0]:
text.insert(1.0, var[0])
speak(package + 'already installed')
elif errorInstalling in check or someError in check:
text.insert(1.0, check)
speak('Error installing ' + package)
textHighlightFont = font.Font(family='OnePlus Sans Display', size=12)
appHighlightFont = font.Font(family='OnePlus Sans Display', size=12,
weight='bold')
titleBar = Frame(root, bg='#141414', relief=SUNKEN, bd=0)
icon = Image.open(os.path.join(cwd + '\\UI\\icons',
'alpythonpackageinstaller.ico'))
icon = icon.resize((30, 30), Image.ANTIALIAS)
icon = ImageTk.PhotoImage(icon)
iconLabel = Label(titleBar, image=icon)
iconLabel.photo = icon
iconLabel.config(bg='#141414')
iconLabel.grid(row=0, column=0, sticky="nsew")
titleLabel = Label(titleBar, text='ALPYTHONPACKAGEINSTALLER',
fg='#909090', bg='#141414', font=appHighlightFont)
titleLabel.grid(row=0, column=1, sticky="nsew")
closeButton = Button(titleBar, text="x", bg='#141414', fg="#909090",
borderwidth=0, command=root.destroy,
font=appHighlightFont)
closeButton.grid(row=0, column=3, sticky="nsew")
minimizeButton = Button(titleBar, text="-", bg='#141414', fg="#909090",
borderwidth=0, command=hideScreen,
font=appHighlightFont)
minimizeButton.grid(row=0, column=2, sticky="nsew")
titleBar.grid_columnconfigure(0, weight=1)
titleBar.grid_columnconfigure(1, weight=75)
titleBar.grid_columnconfigure(2, weight=1)
titleBar.grid_columnconfigure(3, weight=1)
titleBar.pack(fill=X)
pythonPackage = Label(root, text="PACKAGE NAME")
pythonPackage.pack()
pythonPackage.config(bg=color, fg="#fcf2f0", font=textHighlightFont)
pythonPackage = Entry(root, bg="#ffdf14", fg='#0e3b74',
highlightbackground=color, highlightcolor=color,
highlightthickness=3, bd=0,
font=appHighlightFont)
pythonPackage.pack(fill=X)
install = Button(root, borderwidth=0, highlightthickness=3,
text="INSTALL", command=install)
install.config(bg=color, fg="#fcf2f0", font=textHighlightFont)
install.pack(fill=X)
text = Text(root, font="sans-serif", relief=SUNKEN,
highlightbackground=color, highlightcolor=color,
highlightthickness=5, bd=0)
text.config(bg="#ffdf14", fg='#0e3b74', height=2,
font=appHighlightFont)
text.pack(fill=BOTH, expand=True)
titleBar.bind("<B1-Motion>", callback)
titleBar.bind("<Button-3>", showScreen)
titleBar.bind("<Map>", screenAppear)
root.mainloop()
if __name__ == "__main__":
AlPythonPackageInstaller()