
Actualizar ventana usando Tkinter
Publicado por C (17 intervenciones) el 18/11/2014 14:40:23
Buenas! Estoy usando Tkinter para hacer un programa que simula un sistema de reserva de asientos para vuelos. Anda todo muy bien pero lo que estoy tratando de hacer ahora es que, cuando cancelo o reservo un vuelo, que me refresque la ventana en el momento (por ahora aparece modificada cuando vuelvo a abrir). Se apreciaría un poco de ayuda. Gracias!
Este es el módulo principal:
Este es el módulo principal:
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
from tkinter import *
from extras import *
import winsound
win = Tk()
win.title("BLA Airlines")
asientosVuelo = cargaDeVuelo()
asientosVentanilla = ventanilla(asientosVuelo)
asientosPasillo = pasillo(asientosVuelo)
asientosLibresJuntos = asientosLibresJuntos(asientosLibres(asientosVuelo))
def main():
frame1 = Frame(win)
frame1.pack()
Label(frame1, text="Fila").grid(row=0, column=0, sticky=W)
filaVar = IntVar()
filaPos = Entry(frame1, textvariable=filaVar)
filaPos.grid(row=0, column=1, sticky=W)
Label(frame1, text="Asiento").grid(row=1, column=0, sticky=W)
asientoVar = IntVar()
asientoPos = Entry(frame1, textvariable=asientoVar)
asientoPos.grid(row=1, column=1, sticky=W)
frame2 = Frame(win)
frame2.pack()
b0 = Button(frame2,text="Guardar Cambios",command= lambda: guardarCambios(asientosVuelo))
b1 = Button(frame2,text="Reservar",command= lambda: reservar(asientosVuelo,int(filaVar.get()),int(asientoVar.get())))
b2 = Button(frame2,text="Cancelar",command= lambda: cancelar(asientosVuelo,int(filaVar.get()),int(asientoVar.get())))
b3 = Button(frame2,text="Asientos Libres Juntos",command= lambda: pintarALJ(asientosLibresJuntos))
b1.pack(side=LEFT); b0.pack(side=LEFT)
b2.pack(side=LEFT)
b3.pack(side=LEFT)
frame11 = Frame(win)
frame11.pack()
for fila in range(len(asientosVuelo)):
for asiento in range(len(asientosVuelo[fila])):
Label(frame11, text=asientosVuelo[fila][asiento], relief=RIDGE,width=15).grid(row=fila,column=asiento)
for elem in asientosVentanilla:
Label(frame11, bg='blue', text=asientosVuelo[elem[0]][elem[1]], relief=RIDGE,width=15).grid(row=elem[0],column=elem[1])
for elem in asientosPasillo:
Label(frame11, bg='green', text=asientosVuelo[elem[0]][elem[1]], relief=RIDGE,width=15).grid(row=elem[0],column=elem[1])
def pintarALJ(matriz):
for elem in matriz:
Label(frame11, bg='red', text=asientosVuelo[elem[0]][elem[1]], relief=RIDGE,width=15).grid(row=elem[0],column=elem[1])
messagebox.showinfo("Reserva","Mostrando asientos libres juntos (a partir de 2)")
winsound.PlaySound("sonido.wav",winsound.SND_FILENAME)
return
main()
win.mainloop()
Valora esta pregunta


0