22-10-2020, 10:21 PM
No se bien como explicar esto pero... Cuando uso print junto con una variable en lugar de salir el contenido de dicha variable me sale PV_VAR y no se que hacer para corregirlo.
Código:
from tkinter import *
from tkinter import ttk, font
claves = ["XoesLN"]
class Main_App():
Login = False
def __init__(self):
self.ventana = Tk()
self.ventana.geometry("720x480")
self.ventana.title("Data Center")
self.boton1 = Button(self.ventana, text = "+", command = self.crear, height = 1, width = 5)
self.boton_Login = Button(self.ventana,text="Login",command=self.login)
self.boton_Login.pack(side=TOP)
self.boton1.place(x=620, y=20)
self.ventana.mainloop()
def crear(self):
self.name = StringVar()
self.Sec = StringVar()
self.Descip = StringVar()
self.Poner = Toplevel()
self.Poner.geometry("610x410")
self.Poner.title("Create Data")
self.Poner.resizable(0,0)
Etiqueta1 = Label(self.Poner, text="Name of the Data:")
Etiqueta2 = Label(self.Poner, text="Level of Security:")
self.botona = Button(self.ventana, text="Hola", command=quit)
self.Boton_A = Button(self.Poner, text = "Accept", command = self.Accept)
self.Put_Name = Entry(self.Poner, textvariable=self.name, width=30)
self.Level_Sec = Spinbox(self.Poner, from_= 1, to = 4, textvariable = self.Sec, wrap = True, state = "readonly")
self.Description = Entry(self.Poner, textvariable = self.Descip, width = 90)
self.botona.pack_configure(side=LEFT)
Etiqueta1.place(x=30,y=20)
Etiqueta2.place(x=30,y=40)
self.Put_Name.place(x=140,y=20)
self.Level_Sec.place(x=140,y=40)
self.Description.place(x=30,y=60)
self.Boton_A.pack(side= BOTTOM)
def login(self):
self.Enter = Toplevel()
self.Enter.geometry("250x300")
self.Enter.title("LOGIN")
self.Enter.resizable(0,0)
self.Clave = StringVar()
boton_Log = Button(self.Enter,text="Login",command=self.check)
boton_Log.pack(side=BOTTOM)
Etiqueta_Login = Label(self.Enter,text="Clave:")
Etiqueta_Login.place(x=10,y=80)
Entry_Clave = Entry(self.Enter,textvariable=self.Clave,width=30)
Entry_Clave.place(x=50,y=80)
def check(self):
if self.Clave == claves:
Main_App.Login = True
Main_App.Login = True
if Main_App.Login:
self.boton_Login.config(background="green")
self.Enter.destroy()
def Accept(self):
print(self.name) # Aquí
print(self.Sec)
print(self.Descip)
self.Poner.destroy()
def main():
myapp = Main_App()
return 0
if __name__ == "__main__":
main()