title: Using a GUI to input variables and run a script in python
body: <p>I am currently writing a CFD program in python, the script uses a lot of predefined global variables in the calculations.</p>
  
  <p>I would like to produce a GUI which allows the user to input all these variables, then runs the script and returns the results in the main console. I have tried using Tkinter to do this but can't seen to find a way to set global variables.</p>
  
  <p>Below is a simple GUI I have tried designing to complete a much simpler calculation that also needs the global variables to be set.</p>
  
  <pre><code>'''GUI 2'''
  import Tkinter
  factor = 10
  
  def GUIrun(n):
      return n * factor
  
  class simpleGUI(Tkinter.Tk):
      def __init__(self,parent):
          Tkinter.Tk.__init__(self,parent)
          self.parent=parent
  
      def initialize(self):
          self.grid()
  
          self.entryVariable = Tkinter.StringVar()
          self.entry = Tkinter.Entry(self,textvariable=self.entryVariable)
          self.entry.grid(column=0,row=0,sticky='EW')
          self.entry.bind("&lt;Return&gt;",self.OnPressEnter)
          self.entryVariable.set("n")
  
          button=Tkinter.Button(self,text="Run",command=self.OnButtonClick)
          button.grid(column=1,row=0)
  
          self.labelVariable = Tkinter.StringVar()
          label=Tkinter.Label(self,textvariable=self.labelVariable,
          anchor="w",fg="white",bg="blue")
          label.grid(column=0,row=1,columnspan=2,sticky='EW')
          self.labelVariable.set("Hello!")
  
          self.grid_columnconfigure(0,weight=1)
          self.resizable(True,False)
          self.entry.focus_set()
          self.entry.selection_range(0, Tkinter.END)
  
      def OnPressEnter(self,event):
          n = self.entryVariable.get()
          self.labelVariable.set("n = " +self.entryVariable.get())
          self.entry.focus_set()
          self.entry.selection_range(0, Tkinter.END)
  
  
      def OnButtonClick(self):
          n=self.entryVariable.get()
          return GUIrun(n)
  
  
  if __name__=="__main__":
      app=simpleGUI(None)
      app.title('poster')
      app.initialize()
      app.mainloop()
  </code></pre>
  
  <p>I would appreciate any help
  Thank you</p>