Python - Guardar un valor en una variable

 
Vista:
sin imagen de perfil
Val: 2
Ha disminuido su posición en 19 puestos en Python (en relación al último mes)
Gráfica de Python

Guardar un valor en una variable

Publicado por Aurora (1 intervención) el 30/12/2020 20:58:39
Hola, Estoy haciendo un cajero automático con GUI pero el problema es que no puedo pasar la operación que realice en una ventana a otra, es decir tengo $5000 de valor inicial y decido ir a la ventana de retirar y retiro $1000, pero cuando voy a la ventana de consultar no aparece el resultado de esa operación, en este caso no aparece $4000. El programa esta dentro de una función ya que esta concatenado a otros 2 codigos.
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
import tkinter as tk
from tkinter import *
 
def Atm():
    DINERO=5000
 
 
    #Consultar dinero
    def Consulta():
        def salir():
            root4.destroy()
            root.deiconify()
 
        root4 = tk.Toplevel()
        root4.title(" "*20 +"Consultar")
        root4.geometry("700x600")
        root4.resizable(False,False)
        root4.configure(background="#97BF10")
        root4.iconbitmap('dinero.ico')
 
        tk.Label(root4, text="ATM",fg='#FFFFFF',background='#000000',
                 font=("MV Boli", 25),height=2, width=40,justify="right").place(x=0, y=0)
 
        tk.Label(root4, text="Tu saldo es:",fg='#FFFFFF',background='#97BF10',
                 font=("MV Boli", 20),height=7, width=9,justify="right").place(x=30, y=150)
        resultadoN=StringVar()
        resN=Entry(root4,textvariable=DINERO).place(x=220,y=265)
        img = PhotoImage(file="flecha.png")
        BTAA2=Button(root4,command= lambda :[salir()],text="Regresar", width=100, height=100,image=img,justify="right").place(x=570,y=470)
 
        root4.mainloop()
 
      #El menu para ingresar (retirar o depositar)
    def Ingre():
 
        #Retirar dinero
        def Retiro():
 
            root.iconify()
            def ret():
                resultadoN.set("" + str(float(resultadoN.get()) - DINERO))
                messagebox.showwarning ("Finalizado"," Retiro realizado")
 
            def limpiar():
                resultadoN.set("  ")
 
            def salir():
                root2.destroy()
                root.deiconify()
 
            root2 = tk.Toplevel()
            root2.title(" "*20 +"Retirar")
            root2.geometry("700x600")
            root2.resizable(False,False)
            root2.configure(background="#97BF10")
            root2.iconbitmap('tarjeta2.ico')
 
            tk.Label(root2, text="ATM",fg='#FFFFFF',background='#000000',
                     font=("MV Boli", 25),height=2, width=40,justify="right").place(x=0, y=0)
 
            tk.Label(root2, text="¿Cuanto\ndeseas\nretirar?",fg='#FFFFFF',background='#97BF10',
                     font=("MV Boli", 20),height=7, width=7,justify="right").place(x=30, y=150)
 
            resultadoN=StringVar()
            resN=Entry(root2,textvariable=resultadoN).place(x=220,y=265)
 
            DTN22=Button(root2,command= lambda :[ret(),limpiar()],text="Retirar", padx=30, pady=30, background="#FFFFFF").place(x=450,y=300)
 
            img = PhotoImage(file="flecha.png")
            BTAA2=Button(root2,command= lambda :[salir()],text="Regresar", width=100, height=100,image=img,justify="right").place(x=570,y=470)
 
            root2.mainloop()
 
 
 
    #Depositar dinero
        def Depo():
            root.iconify()
            def ON():
                resultadoN.set("" + str(float(resultadoN.get()) + DINERO))
                messagebox.showwarning ("Finalizado"," Deposito realizado")
 
            def limpiar():
                resultadoN.set("  ")
 
            def salir():
                root1.destroy()
                root.deiconify()
 
            root1 = tk.Toplevel()
            root1.title(" "*20 +"Depositar")
            root1.geometry("700x600")
            root1.resizable(False,False)
            root1.configure(background="#97BF10")
            root1.iconbitmap('tarjeta1.ico')
 
            tk.Label(root1, text="ATM",fg='#FFFFFF',background='#000000',
                     font=("MV Boli", 25),height=2, width=40,justify="right").place(x=0, y=0)
 
            tk.Label(root1, text="¿Cuanto\ndeseas\ndepositar?",fg='#FFFFFF',background='#97BF10',
                     font=("MV Boli", 20),height=7, width=9,justify="right").place(x=30, y=150)
 
            resultadoN=StringVar()
            resN=Entry(root1,textvariable=resultadoN).place(x=220,y=265)
 
            DTN21=Button(root1,command= lambda :[ON(),limpiar()],text="Depositar", padx=30, pady=30, background="#FFFFFF").place(x=450,y=300)
            img = PhotoImage(file="flecha.png")
            BTAA1=Button(root1,command= lambda :[salir()],text="Regresar", width=100, height=100,image=img,justify="right").place(x=570,y=470)
 
            root1.mainloop()
 
 
        #La ventana donde se abrira el menu de ingresar
        root = tk.Toplevel()
        root.title(" "*20 +"Ingresar")
        root.geometry("700x600")
        root.resizable(False,False)
        root.configure(background="#97BF10")
        root.iconbitmap('cajero.ico')
 
 
 
        tk.Label(root, text="ATM",fg='#FFFFFF',background='#000000',
                 font=("MV Boli", 25),height=2, width=40,justify="right").place(x=0, y=0)
        DTN2=Button(root,command= Depo, text="Depositar", padx=50, pady=60, background="#FFFFFF").place(x=450,y=200)
        DTN1=Button(root,command= Retiro, text="Retirar", padx=65, pady=60, background="#FFFFFF").place(x=80,y=200)
        img = PhotoImage(file="flecha.png")
        BTAAP=Button(root,text="Regresar", width=100, height=100,image=img,justify="right").place(x=570,y=470)
        root.mainloop()
 
 
 
 
 
 
 
#Ventana prncipal donde  esta el meni de consultar o ingresar
    rootP = tk.Toplevel()
    rootP.title(" "*20 +"ATM")
    rootP.geometry("700x600")
    rootP.resizable(False,False)
    rootP.configure(background="#97BF10")
    rootP.iconbitmap('atm.ico')
 
 
 
    tk.Label(rootP, text="Bienvenido a la ATM",fg='#FFFFFF',background='#000000',
    font=("MV Boli", 25),height=2, width=40,justify="right").place(x=0, y=0)
    DTN2=Button(rootP, command=Ingre, text="Ingresar", padx=50, pady=60, background="#FFFFFF").place(x=450,y=200)
    DTN1=Button(rootP,command= Consulta, text="Consultar", padx=65, pady=60, background="#FFFFFF").place(x=80,y=200)
    img = PhotoImage(file="casa.png")
    BTAA=Button(rootP,text="Regresar", width=100, height=100,image=img,justify="right").place(x=570,y=470)
 
 
 
 
 
    rootP.mainloop()
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder