title: Creating a popup message box with an Entry field
body: <p>I want to create a popup message box which prompts user to enter an input. I have this method inside a class. I am basing my code on <a href="http://www.java2s.com/Code/Python/GUI-Tk/Getinputvaluefromadialog.htm" rel="noreferrer">this guide by java2s</a>.</p>
  
  <pre><code>class MyDialog:
      def __init__(self, parent):
          top = self.top = Toplevel(parent)
  
          Label(top, text="Value").pack()
  
          self.e = Entry(top)
          self.e.pack(padx=5)
  
          b = Button(top, text="OK", command=self.ok)
          b.pack(pady=5)
  
      def ok(self):
          print "value is", self.e.get()
          self.top.destroy()
  
  root = Tk()
  d = MyDialog(root)
  
  root.wait_window(d.top)
  </code></pre>
  
  <p>But in this, <code>top = self.top = Toplevel(parent)</code> doesn't work for me.</p>
  
  <p>I have a mockup of what I am trying to accomplish. </p>
  
  <p><img src="https://i.stack.imgur.com/XEE2s.png" alt="GUI mockup"></p>
  
  <p>My program structure looks something like this:</p>
  
  <pre><code>class MainUI:
     def__int__(self):
         ...
         self.initUI()
  
     def initUI(self):
         .......
         Popup = Button(self, text="Enter Value", command=self.showPopup)
  
     def showPopup(self):
         #create the popup with an Entry here
  </code></pre>
  
  <p>How can I create a message box in Python which accepts user input?</p>