-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestapp.py
186 lines (151 loc) · 4.05 KB
/
testapp.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
from random import randint
from requests import get
from tkinter.ttk import Progressbar
from tkinter import Label, Button, Tk, ttk, Frame
from bs4 import BeautifulSoup
from io import BytesIO
from PIL import ImageTk, Image
import time
List_main = []
pro = ttk.Progressbar
w = Tk()
url = 'https://www.imdb.com/chart/top'
img = ''
def start():
global List_main
if len(List_main)==0:
response = get(url)
html = response.text
soup = BeautifulSoup(html,'html.parser')
movietags = soup.select ('td.titleColumn')
List_main = movietags
def out():
movietag0 = List_main[randint(1,249)]
moviesplit = movietag0.text.split()
moviesplit.pop(0)
a = ' '.join(moviesplit)
return a
def click():
label0 = Label(w,text='{}'.format(out()),bg= '#488ddb',font = ('Tahoma','11'))
label0.pack()
width_of_window = 427
height_of_window = 250
screen_width = w.winfo_screenwidth()
screen_height = w.winfo_screenheight()
x_coordinate = (screen_width/2)-(width_of_window/2)
y_coordinate = (screen_height/2)-(height_of_window/2)
w.geometry("%d x %d + %d + %d" %(
width_of_window,
height_of_window,
x_coordinate,
y_coordinate)
)
w.overrideredirect(1)
s = ttk.Style()
s.theme_use('clam')
s.configure(
"red.Horizontal.TProgressbar",
foreground ='red',
background ='#07fa18'
)
progress= pro(
w,
style ="red.Horizontal.TProgressbar",
orient ='horizontal',
length =500,
mode ='determinate',
)
####################### progressbar 33333333333333333333333333333
def new_win():
root = Tk()
root.minsize(300, 200);
root.maxsize(500, 400);
root.title('Movie Suggester')
##background##
#imgf()
#backpanel = Label(root, image=img)
#backpanel.pack(side="bottom", fill="both")
##background##
label0 = Label(
root,
text = 'Click the button to get a movie suggestion..!',
font = ('Ariel','15'),
fg = 'orange'
)
label0.pack();
button0 = Button(
root,
activeforeground = 'red',
activebackground = 'blue',
width = 42,
height = 2,
text = "Click me",
command = click,
fg = 'white',
bg = 'black',
font = ('Helvetica','10')
)
button0.pack();
root.mainloop()
def bar():
l4 = Label(
w,
text= 'Loading...',
fg = 'white',
bg = a
)
lst4 = (
'Calibri (Body)',
10
)
l4.config(font=lst4)
l4.place(x=18,y=210)
r = 0
for i in range(100):
progress['value'] = r
w.update_idletasks()
if len(List_main) == 0:
start()
if len(List_main) != 0:
pass;
time.sleep(0.03)
r = r+1
w.destroy()
progress.place(x=-10,y=235)
a='#0a52f0'
Frame(w,width=427,height=241,bg=a).place(x=0,y=0) #249794
b1=Button(
w,
width = 10,
height = 1,
text = 'Get Started',
command = bar,
border = 0,
fg = a,
bg = 'white'
)
b1.place(x = 170, y = 200)
######## Label #########
l1 = Label(w,text='Movie',fg='white',bg=a)
lst1 = ('Calibri (Body)',18,'bold')
l1.config(font=lst1), l1.place(x=50,y=80);
l2 = Label(w,text='Suggester',fg='white',bg=a)
lst2 =(
'Calibri (Body)',
18,
'bold'
)
l2.config(font=lst2), l2.place(x=123,y=80);
l3 = Label(w,
text = '',
fg = 'white',
bg = a
)
lst3=(
'Calibri(Body)' ,
13
)
l3.config(font = lst3)
l3.place(x = 50,y = 110)
w.mainloop()
new_win()