TKINTER FORMULARIO (NECESITO REGISTAR NOMBRE, APELLIDO Y DNI Y LUEGO MOSTRARLOS en ventana con btm
Publicado por JESUS (1 intervención) el 15/02/2021 17:13:25
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
import tkinter
from tkinter import messagebox
from tkinter import*
class FrmLogin(tkinter.Frame):
def __init__(self):
global obj_ventana
obj_ventana = tkinter.Tk()
super().__init__(obj_ventana)
obj_ventana.title("REGISTRAR Y LISTAR: !!!!")
obj_ventana.geometry("500x300")
obj_ventana.configure(background="blue")
self.iniciarComponentes()
def iniciarComponentes(self):
btnregistrar=tkinter.Button(obj_ventana,text="Registrar" ,command=self.registrar)
btnregistrar.place(x=100,y=100)
btnlistar = tkinter.Button(obj_ventana, text="Listar", command=self.listar)
btnlistar.place(x=100, y=200)
def registrar(self):
obj_ventana.withdraw()
nuevaventana=FrmRegistrar()
nuevaventana=mainloop()
def listar(self):
obj_ventana.withdraw()
nuevaventana=FrmListar()
nuevaventana=mainloop()
class FrmRegistrar(tkinter.Frame):
def __init__(self):
global nombre1
global apellido1
global dni1
global obj_ventana
obj_ventana = tkinter.Tk()
super().__init__(obj_ventana)
obj_ventana.title("REGISTRAR !!!!")
obj_ventana.geometry("500x300")
obj_ventana.configure(background="red")
lblnombre = tkinter.Label(obj_ventana, text="nombre:")
lblnombre.place(x=90, y=50)
lblapellido = tkinter.Label(obj_ventana, text="apellido:")
lblapellido.place(x=90, y=100)
lbldni = tkinter.Label(obj_ventana, text="dni:")
lbldni.place(x=90, y=150)
self.nombre1 = tkinter.Entry(obj_ventana, width=40)
self.nombre1.place(x=200, y=50)
self.apellido1 = tkinter.Entry(obj_ventana, width=40)
self.apellido1.place(x=200, y=100)
self.dni1 = tkinter.Entry(obj_ventana, width=40)
self.dni1.place(x=200, y=150)
btnregresar = tkinter.Button(obj_ventana, text="REGRESAR ", command=self.regresar)
btnregresar.place(x=120, y=270)
btngrabar = tkinter.Button(obj_ventana, text="grabar ", command=self.regresar)
btngrabar.place(x=250, y=270)
def grabar(self):
nombre_1 = nombre1.get()
apellido_1 = apellido1.get()
dni_1 = dni1.get()
file = open(nombre_1,"w")
file.write(apellido_1+"\n")
file.write(dni_1)
file.close()
nombre1.delete(0,END)
apellido1.delete(0,END)
dni1.delete(0,END)
if (nombre_1 == "" and apellido_1 == "" and dni_1 == ""):
messagebox.showinfo("", "Ningun campo rellenado")
elif (len(nombre_1) == 0):
messagebox.showinfo(message="Ingrese el nombre", title="Mensaje")
self.nombre1.focus()
elif (len(apellido_1) == 0):
messagebox.showinfo(message="Ingrese el apellido", title="Mensaje")
self.apellido1.focus()
elif (len(dni_1) == 0):
messagebox.showinfo(message="Ingrese el dni", title="Mensaje")
self.dni1.focus()
else:
obj_ventana.withdraw()
nuevaventana=FrmLogin()
nuevaventana=mainloop()
def regresar(self):
obj_ventana.withdraw()
nuevaventana=FrmLogin()
nuevaventana=mainloop()
class FrmListar(tkinter.Frame):
def __init__(self):
global obj_ventana
obj_ventana = tkinter.Tk()
super()._init_(obj_ventana)
obj_ventana.title("LISTAR !!!!")
obj_ventana.geometry("500x500")
obj_ventana.configure(background="red")
btnregresar = tkinter.Button(obj_ventana, text="REGRESAR", command=self.regresar)
btnregresar.place(x=220, y=140)
def regresar(self):
obj_ventana.withdraw()
nuevaventana=FrmLogin()
nuevaventana=mainloop()
objeto= FrmLogin()
objeto.mainloop()
Valora esta pregunta


0