-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterface.py
More file actions
434 lines (306 loc) · 12.1 KB
/
Copy pathInterface.py
File metadata and controls
434 lines (306 loc) · 12.1 KB
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
from distutils import command
from tkinter import *
import time
import Validacion
import Datos
import os
import shutil
from tkinter import messagebox
from tkinter import ttk
from tkinter.filedialog import askopenfilename
from tkinter import filedialog
from distutils import command
import shutil
from tkinter import messagebox
from tkinter import ttk
from tkinter.filedialog import askopenfilename
from tkinter import Label,Tk
from PIL import Image, ImageTk
from tkinter import filedialog
objeto_validacion=Validacion.validacion()
global lista_de_textbox
lista_de_textbox = list()
def llenarcampodescrip():
valordes=cajadescripcion.get()
return valordes
def finalizar():
Datos.crerar_archivo(jugador, proceso, imnom, fecha)
Datos.ventana(jugador, imnom, proceso, fecha, "you lost")
time.after_cancel(proceso)
toggle_entry()
def autores():
messagebox.showinfo("Autores","Sebastián Guandinango: sguandinangod@est.ups.edu.ec \n Fausto Borja: fborjav@est.ups.edu.ec \n Fabián Garrido: fgarridom@est.ups.edu.ec")
#SELECCION DE IMAGEN
def probar():
global proceso
a=cajanombre.get()
b=cajares.get()
if ( cajanombre.get()==cajares.get()):
time.after_cancel(proceso)
Datos.ventana(cajaju.get(), cajanombre.get(), proceso, fecha, "Winner")
toggle_entry()
else:
etiquetaintente = Label(ventana, text="INTENTE OTRA VEZ :)", bg="BLACK",
fg="white", width=40, height=1)
etiquetaintente.place(x=450, y=610)
def toggle_entry():
global hidden
if hidden:
cajanombre.place(x=450, y=120)
cajadescripcion.place(x=450, y=180)
else:
cajanombre.place_forget()
cajadescripcion.place_forget()
hidden = not hidden
def imagen1():
llenarcampodescrip()
etiqueta1.place_forget()
def imagen2():
etiqueta2.place_forget()
def imagen3():
etiqueta3.place_forget()
def imagen4():
etiqueta4.place_forget()
def imagen5():
etiqueta5.place_forget()
fecha=str(time.strftime("%d/%m/%y"))
def iniciar(contador=30):
global proceso
nombre_imagen = cajanombre.get()
jugarcaja = cajaju.get()
global jugador
global imnom
jugador = cajaju.get()
imnom = cajanombre.get()
Datos.crerar_archivo(jugador, "4", imnom, fecha)
proceso = 30
variable=""
if (nombre_imagen!=variable and jugarcaja != variable ):
if(nombre_imagen.isalpha() and jugarcaja.isalpha() ):
cadena = ""
nombre_imagen = cajanombre.get()
global etiquetasobre
objeto_validacion.set_nombre_imagen(nombre_imagen)
texto = objeto_validacion.return_tamanio_de_palabra()
for i in range(texto):
cadena += "_ "
if (contador == 30):
anadir_descripcion()
txtdesi = Frame(ventana, borderwidth=1, relief="sunken")
txtodesi = Text(txtdesi, wrap=NONE, height=1, width=34, borderwidth=1)
vscrolldei = Scrollbar(txtdesi, orient=HORIZONTAL, command=txtodesi.xview)
vscrolldei01 = Scrollbar(txtdesi, orient=VERTICAL, command=txtodesi.yview)
txtodesi['xscrollcommand'] = vscrolldei.set
txtodesi['yscrollcommand'] = vscrolldei01.set
vscrolldei.pack(side="bottom", fill="x")
vscrolldei01.pack(side="right", fill="y")
txtodesi.pack(side="left", fill="both", expand=True)
txtodesi.insert(INSERT, objeto_validacion.get_descripcion_imagen())
txtdesi.place(x=450, y=455)
txtodesi.tag_add("here", "1.0", "7.4")
txtodesi.tag_add("start", "1.8", "1.13")
txtodesi.tag_config("here", background="black", foreground="white")
txtodesi.config(state=DISABLED)
var = objeto_validacion.get_descripcion_imagen()
mostrar_imagenes()
toggle_entry()
global etiquetaTitulo
etiquetaTitulo = Label(ventana, text=cadena,bg="teal", fg=colorFondo, width=30, font=("", "18"))
etiquetaTitulo.place(x=20, y=10)
time['text'] = contador
proceso = time.after(1000, iniciar, (contador - 1))
if (contador == 0):
toggle_entry()
Datos.crerar_archivo(jugador, proceso, imnom, fecha)
Datos.ventana(jugador, imnom, proceso, fecha, "you lost")
cadena = ""
for l in nombre_imagen:
cadena += l
etiquetaTitulo.config(text=cadena)
# eliminar_text_boxs()
time.after_cancel(proceso)
if (contador == 25):
imagen1()
cadena = ""
for i in range(texto):
if i == 0:
cadena += nombre_imagen[i]
else:
cadena += " _ "
etiquetaTitulo.config(text=cadena)
# if (contador==15):
if (contador == 20):
imagen2()
cadena = ""
for i in range(texto):
if i == 0:
cadena += nombre_imagen[i]
elif i == 1:
cadena += nombre_imagen[i]
else:
cadena += " _ "
etiquetaTitulo.config(text=cadena)
if (contador == 10):
imagen3()
cadena = ""
for i in range(texto):
if i == 0:
cadena += nombre_imagen[i]
elif i == 1:
cadena += nombre_imagen[i]
elif i == 2:
cadena += nombre_imagen[i]
else:
cadena += " _ "
etiquetaTitulo.config(text=cadena)
if (contador == 3):
imagen4()
if (contador == 1):
imagen5()
cadena = ""
for i in range(texto):
if i == 0:
cadena += nombre_imagen[i]
elif i == 1:
cadena += nombre_imagen[i]
elif i == 2:
cadena += nombre_imagen[i]
elif i == 3:
cadena += nombre_imagen[i]
else:
cadena += " _ "
etiquetaTitulo.config(text=cadena)
else:
messagebox.showerror("Error", "Por favor solo ingrese letras en los campos nombre del jugador y nombre imagen")
else:
messagebox.showerror("Error", "Por favor llene todos los campos")
def mostrar_imagenes():
etiqueta1.place(x=20, y=470)
etiqueta2.place(x=20, y=60)
etiqueta3.place(x=241, y=470)
etiqueta4.place(x=241, y=60)
etiqueta5.place(x=20, y=265)
def chose():
Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
path = filedialog.askopenfilename(filetypes=[("Image File", '.jpg .png .jpeg')])
im = Image.open(path)
imh = ImageTk.PhotoImage(file=path)
w.configure(image=imh)
w.image=imh
#CENTRAR VENTANA
def center(win):
"""
centers a tkinter window
:param win: the root or Toplevel window to center
"""
win.update_idletasks()
width = win.winfo_width()
frm_width = win.winfo_rootx() - win.winfo_x()
win_width = width + 2 * frm_width
height = win.winfo_height()
titlebar_height = win.winfo_rooty() - win.winfo_y()
win_height = height + titlebar_height + frm_width
x = win.winfo_screenwidth() // 2 - win_width // 2
y = win.winfo_screenheight() // 2 - win_height // 2
win.geometry('{}x{}+{}+{}'.format(width, height, x, y))
win.deiconify()
def anadir_descripcion():
descripcion_imagen = cajadescripcion.get()
objeto_validacion.set_descripcion_imagen(descripcion_imagen)
#INTERFAZ
hidden = False
ventana = Tk()
#############Objeto validacion
imh12 = PhotoImage(file="azules.png")
fo = Label(ventana, image=imh12, width=980, height=675)
fo.image=imh12
fo.place(x=0, y=0)
genero = StringVar()
titulo = StringVar()
descripcion = StringVar()
duracion = StringVar()
anio = StringVar()
conteliminar = StringVar()
colorFondo = "orange"
colorLetra = "BLACK"
colorBotones = "SpringGreen3"
ventana.title("Image Play")
ventana.geometry("770x675")
ventana.configure(background = colorFondo)
etiquetaTitulo= Label(ventana, text=" Aquí se muestra una pista de la Palabrita",
bg="teal", fg=colorFondo,width=38,font=("", "14")).place(x=20,y=10)
etiquetajug = Label(ventana, text="NOMBRE DEL JUGADOR", bg=colorFondo,
fg=colorLetra,width=40, height=1).place(x=450, y=210)
#---->
cajaju = Entry(ventana, width=47)
cajaju.place(x=450, y=240)
botonInIma = Button(ventana, text="INSERTAR UNA IMAGEN DE TU PC", command=chose, bg=colorBotones, width=39, height=1,
fg=colorLetra).place(x=450, y=60)
etiquetaT1 = Label(ventana, text="NOMBRE DE LA IMAGEN", bg=colorFondo,
fg=colorLetra,width=40, height=1).place(x=450, y=90)
#---->
global cajanombre
cajanombre = Entry(ventana, width=47)
cajanombre.place(x=450, y=120)
etiquetaT2 = Label(ventana, text="DESCRIPCIÓN DE LA IMAGEN", bg=colorFondo,
fg=colorLetra,width=40, height=1).place(x=450, y=150)
#---->
cajadescripcion = Entry(ventana, width=47 )
cajadescripcion.place(x=450, y=180)
etiquetaQUE = Label(ventana, text="¿QUE SE DEBE HACER?", bg=colorFondo,
fg=colorLetra,width=40, height=1).place(x=450, y=290)
#ayuda para jugar básica
txtFrameinstruc = Frame(ventana, borderwidth=1, relief="sunken")
txtinstruc = Text(txtFrameinstruc, wrap = NONE, height = 4, width = 34, borderwidth=1)
vscroll = Scrollbar(txtFrameinstruc, orient=HORIZONTAL, command=txtinstruc.xview)
vscroll01 = Scrollbar(txtFrameinstruc, orient=VERTICAL, command=txtinstruc.yview)
txtinstruc['xscrollcommand'] = vscroll.set
txtinstruc['yscrollcommand'] = vscroll01.set
vscroll.pack(side="bottom", fill="x")
vscroll01.pack(side="right", fill="y")
txtinstruc.pack(side="left", fill="both", expand=True)
txtinstruc.insert(INSERT, "Complete en la parte de abajo el nombre :)\nde la imagen correspondiente para que así vaya\ndestapando la imagen poco a poco :) :) \n\n")
txtFrameinstruc.place(x=450, y=330)
txtinstruc.tag_add("here", "1.0", "7.4")
txtinstruc.tag_add("start", "1.8", "1.13")
txtinstruc.tag_config("here", background="black", foreground="white")
txtinstruc.config(state=DISABLED)
etiquetaT3 = Label(ventana, text="DESCRIPCIÓN DE LA IMAGEN: ", bg=colorFondo,
fg=colorLetra,width=40, height=1)
etiquetaT3.place(x=450, y=430)
#Descripcion de la imagen
etiquetaT4 = Label(ventana, text="ADIVINA: ", bg=colorFondo,
fg=colorLetra,width=40, height=1).place(x=450, y=530)
cajares = Entry(ventana, width=47)
cajares.place(x=450, y=560)
#ADIVINA LA PALABRA
botoFinaliza = Button(ventana, text="FINALIZAR", bg=colorBotones,width=17, height=1,
fg=colorLetra,command=finalizar).place(x=610, y=650)
botoIntentar = Button(ventana, text="INICIAR JUEGO", bg=colorBotones,width=20, height=1,
fg=colorLetra,command=iniciar).place(x=450, y=650)
botonprobar = Button(ventana, text="PROBAR PALABRA INGRESADA", command=probar, bg=colorBotones,width=40, height=1,
fg=colorLetra).place(x=450, y=588)
botonautores = Button(ventana, text="AUTORES", command=autores, bg=colorBotones,width=40, height=1,
fg=colorLetra).place(x=450, y=615)
#REEMPLAZO DE IMAGEN
label_principal=Label(ventana,width=60,height=70)
label_principal.place(x=20,y=60)
label_principal.pack
#imh = PhotoImage(file="descarga.png")
cron = Label(ventana, text="Time:",
fg=colorFondo,font=("", "18")).place(x=590, y=10)
time = Label(ventana, fg='red', width=5, font=("", "18"))
time.place(x=660, y=10)
im=PhotoImage(file="nula.png")
w = Label(ventana,image=im, width=423, height=610)
w.place(x=20, y=60)
im1 = PhotoImage(file="nula.png")
etiqueta1 = Label(ventana, image=im1, width=225, height=200)
etiqueta2 = Label(ventana, image=im1, width=225, height=205)
etiqueta3 = Label(ventana, image=im1, width=200, height=200)
etiqueta4 = Label(ventana, image=im1, width=200, height=200)
etiqueta5 = Label(ventana, image=im1, width=225, height=205)
# this removes the maximize button
ventana.resizable(0,0)
center(ventana)
mainloop()