-2

I am trying to get user input using a Toplevel widget in order to create an order but the submit button does not work as expected please assist.

def spawn_window(self):
    top = Toplevel()
    top.title("Available Electronics")
    self.entrytext = StringVar()
    Entry(top, textvariable=self.entrytext).pack()
    button = Button(top, text="Dismiss", command=top.destroy)
    button.pack(side='right')
    submit = Button(top, text ="Submit", command = self.datainput)
    submit.pack(side='left')



def datainput(self):
    input_var = self.entrytext.get()
    self.devices.append(input_var)
dmn8
  • 19
  • 5

1 Answers1

0

"wanted the text box to turn blank as soon as the submit button was clicked in order to create room for another entry" now its clear what you really want!

In your datainput-method just clear your stringvar at the end, like this:

def datainput(self):
    input_var = self.entrytext.get()
    self.devices.append(input_var)
    self.entrytext.set("") 
VRage
  • 1,458
  • 1
  • 15
  • 27