-1

I am trying to complete an ATM program using GUI in Python.

Problem:

At the start, my program generates a window of Tkinter that takes PIN as input from entry widgets using 0-9 buttons.Entry button takes Entry (root, textvariable=text_Input) while text_input=StringVar() program compares the entered PIN with the data available in the files.

If PIN matches, my program goes to another function through Enter button, destroys the previous root and opens a new one. Here I need to enter some amount to withdraw or deposit. I am using Entry widget here again by doing

inp= StringVar()
Entry (root1, textvarible=inp)

I used withdraw button which sends this (inp) to withdraw function. When I print that (inp), it gives PY_Var16, PY_Var22.

martineau
  • 119,623
  • 25
  • 170
  • 301
Ahsan Niaz
  • 19
  • 1
  • 6
  • 4
    To get the value from a tkinter Variable like StringVar, you need to use the `get()` method. Try `print(inp.get())`. – Novel May 23 '18 at 17:57
  • 1
    BTW, you should never have more than one root window (`Tk()` call) in your program. You need to clear out the old root and reuse it. Using a `Frame` would make that very easy. – Novel May 23 '18 at 17:59
  • 1
    Don't destroy the Tkinter root window and then create a new one. When you do `tk.Tk()` that doesn't just create a window, it also creates an instance of the Tcl interpreter that is the basis of Tkinter. If you need multiple windows take a look at the Toplevel widget. Also, the root window is the root of all the Tkinter objects you create. When you destroy it any widgets, StringVars, etc you created become invalid. – PM 2Ring May 23 '18 at 17:59
  • Possible duplicate of [Tkinter IntVar returning PY\_VAR0 instead of value](https://stackoverflow.com/questions/24768455/tkinter-intvar-returning-py-var0-instead-of-value) – fhdrsdg May 24 '18 at 07:59
  • This is the only thing i didn't try because im very new to iy. Thanx a lot i hope it works once i get back to it – Ahsan Niaz May 24 '18 at 18:46

1 Answers1

0

You should replace print(inp) with print(inp.get())

Juan Leni
  • 6,982
  • 5
  • 55
  • 87
Flaming_Dorito
  • 486
  • 3
  • 11