Professional Documents
Culture Documents
Importar Librerias PR
Importar Librerias PR
import random
#Definicion de la pantalla
pant = Tk()
pant.resizable(0,0)
pant.geometry("1200x900")
pant.title("Juego de la ignorancia-BD")
fon=PhotoImage(file=r"./imagenes/patio.png")
seleccion=()
str_preg=StringVar()
str_res1=StringVar()
str_res2=StringVar()
str_res3=StringVar()
str_res4=StringVar()
str_sig=StringVar()
correcto=0
x1=10
x2=10
x3=10
x4=10
turno=1
def avanza_jug():
global x1,x2,x3
if turno==1:
x1=x1+100
j1.place(x=x1, y=252)
elif turno==2:
x2=x2+100
j2.place(x=x2, y=363)
elif turno==3:
x3=x3+100
j3.place(x=x3, y=475)
def opc1():
global turno, x4
r1.config(state=DISABLED)
r2.config(state=DISABLED)
r3.config(state=DISABLED)
r4.config(state=DISABLED)
if correcto==1:
avanza_jug()
else:
x4=x4+100
j4.place(x=x4, y=585)
turno=turno+1
if turno>3:
turno=1
str_sig.set('jugador '+str(turno))
def opc2():
global turno, x4
r1.config(state=DISABLED)
r2.config(state=DISABLED)
r3.config(state=DISABLED)
r4.config(state=DISABLED)
if correcto==2:
avanza_jug()
else:
x4=x4+100
j4.place(x=x4, y=585)
turno=turno+1
if turno>3:
turno=1
str_sig.set('jugador '+str(turno))
def opc3():
global turno, x4
r1.config(state=DISABLED)
r2.config(state=DISABLED)
r3.config(state=DISABLED)
r4.config(state=DISABLED)
if correcto==3:
avanza_jug()
else:
x4=x4+100
j4.place(x=x4, y=585)
turno=turno+1
if turno>3:
turno=1
str_sig.set('jugador '+str(turno))
def opc4():
global turno, x4
r1.config(state=DISABLED)
r2.config(state=DISABLED)
r3.config(state=DISABLED)
r4.config(state=DISABLED)
if correcto==4:
avanza_jug()
else:
x4=x4+100
j4.place(x=x4, y=585)
turno=turno+1
if turno>3:
turno=1
str_sig.set('jugador '+str(turno))
def sel_preg():
tam=len(seleccion)
if tam!=0:
n=random.randint(0, tam-1)
print(n)
str_preg.set(seleccion[n][1])
str_res1.set(seleccion[n][2])
str_res2.set(seleccion[n][3])
str_res3.set(seleccion[n][4])
str_res4.set(seleccion[n][5])
correcto=seleccion[n][6]
print(correcto)
r1.config(state=NORMAL)
r2.config(state=NORMAL)
r3.config(state=NORMAL)
r4.config(state=NORMAL)
else:
str_res1.set('')
str_res2.set('')
str_res3.set('')
str_res4.set('')
r1.config(state=DISABLED)
r2.config(state=DISABLED)
r3.config(state=DISABLED)
r4.config(state=DISABLED)
#pantalla.update()
def preguntas(event):
global seleccion
cat=event.widget.get()
#los espacios en blanco del combo tkinter agregan llaves en los contenidos
#por guion bajo _ para hacer la busqueda en la base de datos necesitamos ahora
cat=str(cat).replace("_"," ")
seleccion=recupera_preguntas(cat)
#print(preg)
sel_preg()
def pregunta_sig():
global seleccion
cat=categorias.get()
#los espacios en blanco del combo tkinter agregan llaves en los contenidos
#por guion bajo _ para hacer la busqueda en la base de datos necesitamos ahora
cat=str(cat).replace("_"," ")
seleccion=recupera_preguntas(cat)
#print(preg)
sel_preg()
def edita_categorias():
manipula_categoria()
l_cats=recupera_categoria()
#los espacios en blanco del combo tkinter agregan llaves en los contenidos
cats=[]
cat2=str(cat[0]).replace(" ","_")
print(cat2)
cats.append(cat2)
eti.place(x=10, y=10)
categorias['values']=cats
categorias.place(x=150, y=10)
categorias.bind("<<ComboboxSelected>>", preguntas)
siguiente=PhotoImage(file=r"./imagenes/siguiente.png")
sig.place(x=680 ,y=6)
carpeta=PhotoImage(file=r"./imagenes/catalogo.png")
str_sig.set('jugador 1')
sig_jug.place(x=500, y=10)
eti.place(x=10, y=60)
str_preg.set("")
pre.place(x=150, y=60)
str_res1.set("")
r1.place(x=100, y=110)
str_res2.set("")
r2.place(x=360, y=110)
str_res3.set("")
r3=Button(pant,textvariable=str_res3, command=opc3, font='helvetica 10 bold', bg='blue',
fg="white", width=30, height=3, state=DISABLED)
r3.place(x=620, y=110)
str_res4.set("")
r4.place(x=880, y=110)
ju1=PhotoImage(file=r"./imagenes/lap.png")
j1.place(x=10, y=252)
ju2=PhotoImage(file=r"./imagenes/gom.png")
j2.place(x=10, y=363)
ju3=PhotoImage(file=r"./imagenes/sca.png")
j3.place(x=10, y=475)
ju4=PhotoImage(file=r"./imagenes/bur.png")
j4.place(x=10, y=585)
pant.mainloop()