Lift() de tkinter no funciona como debería
Publicado por Antonio (6 intervenciones) el 19/03/2021 16:48:47
Según lo que vi en algunos sitios y hasta en un video de "locademy" (no se si está bien escrito), este comando
lo que hace es cambiar el orden en que reciben el foco algunos widgets, pero no funciona con este código:
En este código tengo un Entry que llamé txtSerie, y recibe el foco al iniciar la aplicación, después según
lo que pongo un poco más arriba, debería ir al botón btnSalir, pero va al DateEntry fdesde. No está funcionando
según como lo definí. ¿ Cual es el error ?
Antonio
Sistemas
Resipol
lo que hace es cambiar el orden en que reciben el foco algunos widgets, pero no funciona con este código:
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
from tkinter import *
from tkcalendar import *
root=Tk()
root.title("Prueba de orden de los widgets")
root.geometry("550x550")
varfr = IntVar()
varfr.set("1")
vartdj = IntVar()
vartdj.set("2")
varfe = IntVar()
varfe.set("2")
fra1 = Frame(root)
fra1.pack(side="top", expand="Y", fill="both")
fra2 = Frame(fra1)
fra2.pack(side="bottom", expand="Y", fill="both")
fra3 = Frame(fra2)
fra3.pack(side="bottom", expand="Y", fill="both")
fra4 = Frame(fra3)
fra4.pack(side="bottom", expand="Y", fill="both")
fra5 = Frame(fra4)
fra5.pack(side="bottom", expand="Y", fill="both")
panerev = LabelFrame(fra1, text=" Label Frame 1 ", labelanchor="nw")
panerev.pack(side="left", expand="false", padx=10, pady=10, fill="both", ipadx=27)
panetdj = LabelFrame(fra1, text=" Label Frame 2 ", labelanchor="nw")
panetdj.pack(side="left", expand="false", padx=10, pady=10, fill="both", ipadx=14)
panefecha = LabelFrame(fra2, text=" Fechas ", labelanchor="nw")
panefecha.pack(side="left", expand="false", padx=10, pady=10, fill="both")
panefe = LabelFrame(fra2, text=" Forma de emisión ", labelanchor="n")
panefe.pack(side="left", expand="false", padx=10, pady=10, fill="both")
paneserie = LabelFrame(fra3, borderwidth=0, highlightthickness=0)
paneserie.pack(side="left", expand="false", padx=10, pady=10, fill="both")
panebutton = LabelFrame(fra4, borderwidth=0, highlightthickness=0)
panebutton.pack(side="left", expand="false", padx=10, pady=10, fill="both")
paneacier = LabelFrame(fra5, borderwidth=0, highlightthickness=0)
paneacier.pack(side="left", expand="false", padx=10, pady=10, fill="both")
radind = Radiobutton(panerev, text="Individual", variable=varfr, value="1")
radind.grid(row=1, column=0, sticky="w")
radgen = Radiobutton(panerev, text="General", variable=varfr, value="2")
radgen.grid(row=2, column=0, sticky="w")
radlot = Radiobutton(panetdj, text="radlot", variable=vartdj, value="1")
radlot.grid(row=1, column=0, sticky="w")
radqui = Radiobutton(panetdj, text="radqui", variable=vartdj, value="2")
radqui.grid(row=2, column=0, sticky="w")
lblDesde = Label(panefecha, text="Desde")
lblDesde.grid(row=1, column=0)
fdesde = DateEntry(panefecha, date_pattern="dd/mm/yyyy")
fdesde.grid(row=1, column=1, padx=10, pady=5)
lblHasta = Label(panefecha, text="Hasta")
lblHasta.grid(row=2, column=0)
fhasta = DateEntry(panefecha, date_pattern="dd/mm/yyyy")
fhasta.grid(row=2, column=1, padx=10, pady=5)
radres = Radiobutton(panefe, text="Resumido", variable=varfe, value="1")
radres.grid(row=1, column=0, sticky="w")
radeta = Radiobutton(panefe, text="Detallado", variable=varfe, value="2")
radeta.grid(row=2, column=0, sticky="w")
lblSerie = Label(paneserie, text="Serie")
lblSerie.grid(row=1, column=0)
txtSerie = Entry(paneserie, width=12)
txtSerie.grid(column=1, row=1, padx=5, pady=5)
btnSalir = Button(panebutton, text="Salir", width=10, command=root.destroy)
btnSalir.pack(side="left", padx=10)
widgets = [txtSerie, btnSalir, radind, radgen, radlot, radqui, fdesde, fhasta, radres, radeta]
for w in widgets:
w.lift()
txtSerie.focus_set()
root.mainloop()
En este código tengo un Entry que llamé txtSerie, y recibe el foco al iniciar la aplicación, después según
lo que pongo un poco más arriba, debería ir al botón btnSalir, pero va al DateEntry fdesde. No está funcionando
según como lo definí. ¿ Cual es el error ?
Antonio
Sistemas
Resipol
Valora esta pregunta


0