title: Tkinter store filename through menubar button
body: <p>I have created functions that can display graphs and tables of csv files in a GUI I am making with tkinter.</p>
  
  <p>I have a <code>menubar</code> with an <em>import</em> button, a <em>plot</em> button, and a <em>table</em> button. The <em>plot</em> and <em>table</em> button can successfully plot graphs and tables of csv  files respectively.</p>
  
  <p>What I'd like to do, is when the user selects the <em>import</em> button, they select a file of their choice. Then, if they happen to select the <em>plot</em> button, the plot function works on the file they chose from <em>import</em>. Moreover, if they happen to select the <em>table</em> button, the table function works on the file they chose from <em>import</em>.</p>
  
  <p>I have created a file opening function called <code>openfile()</code> which remembers the name of the file opened. </p>
  
  <p>The problem is that I don't know how to use <code>menubar</code> and <code>openfile()</code> such when the <em>import</em> button is clicked, my application stores  the filename. </p>
  
  <p>Any tips on how I would go about doing this? </p>
  
  <p>Here's the code I've written for the <code>menubar</code> and <code>openfile()</code>:</p>
  
  <pre><code>def openfile():
      name= askopenfilename() 
      return (name[19:])
  
  class MyApp(tk.Tk):
  
      def __init__(self, *args, **kwargs):
  
          tk.Tk.__init__(self, *args, **kwargs)
  
          tk.Tk.wm_title(self, "MyApp")
          # main frame
          container = tk.Frame(self)
          container.pack(side="top", fill="both", expand = True)
          container.grid_rowconfigure(0, weight=1)
          container.grid_columnconfigure(0, weight=1)
  
          container = tk.Frame(self)
          container.pack(side="top", fill="both", expand = True)
          container.grid_rowconfigure(0, weight=1)
          container.grid_columnconfigure(0, weight=1)
  
          # creates the menubar at the top of the window
          menubar = tk.Menu(container)
  
          # import menu for importing csv files, initializes a file opening function (tbd)
          filemenu = tk.Menu(menubar, tearoff=0)
          filemenu.add_command(label="Import a CSV File", command = file_openerfunction)
          menubar.add_cascade(label= "Import", menu=filemenu)
  
          # plot menu for creating graphs and figures
          Plot = tk.Menu(menubar, tearoff =0 )
          Plot.add_command(label="Plot My CSV File", command= popupgraph)
          menubar.add_cascade(label="Plot", menu=Plot)
  
          # table menu for viewing data in a table
          table = tk.Menu(menubar, tearoff = 0)
          table.add_command(label="View MY CSV File", command = table)
          table.add_cascade(label = "View Data", menu = table)
  
          tk.Tk.config(self, menu=table)
          ....
          ....
  </code></pre>