-
Notifications
You must be signed in to change notification settings - Fork 3
/
trial.py
executable file
·148 lines (109 loc) · 4.88 KB
/
trial.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import tkinter as tk
from tkinter import font as tkfont
from tkinter import filedialog
from tkinter import ttk
from tkinter.filedialog import askopenfilename
import test
def OpenFile():
name = askopenfilename(initialdir="C:/Users/Batman/Documents/Programming/tkinter/",
filetypes =(("Wheel", "*.whl"),("All Files","*.*")),
title = "Choose a file."
)
message=test.whl_install(name)
self.text.set(message)
print(message)
class SampleApp(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
self.title_font = tkfont.Font(family='Helvetica', size=14, weight="bold", slant="italic")
container = ttk.Frame(self)
container.pack(side="top", fill="both", expand=True)
container.grid_rowconfigure(0, weight=1)
container.grid_columnconfigure(0, weight=1)
self.frames = {}
for F in (StartPage, PageOne, PageTwo ,PageThree):
page_name = F.__name__
frame = F(parent=container, controller=self)
self.frames[page_name] = frame
frame.grid(row=0, column=0, sticky="nsew")
self.show_frame("StartPage")
def show_frame(self, page_name):
'''Show a frame for the given page name'''
frame = self.frames[page_name]
frame.tkraise()
class StartPage(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
label = ttk.Label(self, text="pip installer GUI", font=controller.title_font)
label.pack(side="top", fill="x", pady=10)
button1 = ttk.Button(self, text="Install via pip",
command=lambda: controller.show_frame("PageOne"))
button2 = ttk.Button(self, text="Install from a file",
command=lambda: controller.show_frame("PageTwo"))
button3 = ttk.Button(self, text="Install via easy_install",
command=lambda: controller.show_frame("PageThree"))
button1.pack()
button2.pack()
button3.pack()
class PageOne(tk.Frame):
def __init__(self, parent, controller):
self.package = tk.StringVar()
ttk.Frame.__init__(self, parent)
self.controller = controller
label = ttk.Label(self, text="Install via Pip", font=controller.title_font)
label.pack(side="top", fill="x", pady=10)
textBox=ttk.Entry(self,textvariable=self.package)
textBox.pack()
buttoncommit=ttk.Button(self,text="Search", command=self.valinput)
buttoncommit.pack()
self.text = tk.StringVar()
self.label2 = tk.Label(self, text="", textvariable=self.text)
self.label2.pack(side="top", fill="x", pady=10)
button = ttk.Button(self, text="Go to the start page",
command=lambda: controller.show_frame("StartPage"))
button.pack()
def valinput(self):
message=test.install_pip(self.package.get())
print(message)
self.text.set(message)
class PageTwo(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.controller = controller
label = ttk.Label(self, text="Install via Whl File", font=controller.title_font)
label.pack(side="top", fill="x", pady=10)
self.text = tk.StringVar()
self.label2 = ttk.Label(self, text="", textvariable=self.text)
self.label2.pack(side="top", fill="x", pady=10)
button_l = ttk.Button(self, text="Browse",
command=OpenFile)
button = ttk.Button(self, text="Go to the start page",
command=lambda: controller.show_frame("StartPage"))
button_l.pack()
button.pack()
class PageThree(tk.Frame):
def __init__(self, parent, controller):
self.package = tk.StringVar()
tk.Frame.__init__(self, parent)
self.controller = controller
label = ttk.Label(self, text="Install via Easy_Install", font=controller.title_font)
label.pack(side="top", fill="x", pady=10)
textBox=ttk.Entry(self,textvariable=self.package)
textBox.pack()
buttoncommit=ttk.Button(self,text="Search", command=self.valinput)
buttoncommit.pack()
self.text = tk.StringVar()
self.label2 = ttk.Label(self, text="", textvariable=self.text)
self.label2.pack(side="top", fill="x", pady=10)
button = ttk.Button(self, text="Go to the start page",
command=lambda: controller.show_frame("StartPage"))
button.pack()
def valinput(self):
inputValue=self.package.get()
print(inputValue)
self.text.set(test.install_ei(inputValue))
if __name__ == "__main__":
app = SampleApp()
app.title("Package Installer")
app.mainloop()