Hello,<br><br>I modified your code to make it work:<br><br><a href="http://paste-it.net/public/m46ae5d/">http://paste-it.net/public/m46ae5d/</a><br><br>Certainly, to be able to re-write the code, I made some assumptions and guesses about your original intentions. Just check the code to see if it is close to what you want.<br>
<br>Firat<br><br><div class="gmail_quote">2010/9/21 Devred, Emmanuel <span dir="ltr">&lt;<a href="mailto:Emmanuel.Devred@dfo-mpo.gc.ca">Emmanuel.Devred@dfo-mpo.gc.ca</a>&gt;</span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">







<div>


<p><font face="Arial" size="2">Hello,</font>

<br><font face="Arial" size="2">I am a total beginner with python and tkinter and I am having a hard time getting my program working, I think the problem come from passing variables.</font></p>

<p><font face="Arial" size="2">I would like to have a menu that would with three main buttons, the first one (LUT) let me chosse between two files, the second button (rrs) opens a browser to choose a file and the third button would run a program (or function) that makes some computation between the two files open with button 1 and button 2, </font></p>


<p><font face="Arial" size="2">Here is what I have written</font>
</p>

<p><font face="Arial" size="2">from Tkinter import *</font>

<br><font face="Arial" size="2">from tkFileDialog   import askopenfilename</font>

<br><font face="Arial" size="2">import numpy as np</font>
</p>
<br>

<p><font face="Arial" size="2">class openfile():</font>

<br><font face="Arial" size="2">    def __init__(self, yn):</font>

<br><font face="Arial" size="2">        if yn == 0 : self.lut = np.loadtxt(&quot;C:\python26\LUTnpdi_chile&quot;,dtype=np.float,skiprows=1)</font>

<br><font face="Arial" size="2">        if yn == 1 : self.lut = np.loadtxt(&quot;C:\python26\LUTnpdi_nwa&quot;,dtype=np.float,skiprows=1)</font>

<br><font face="Arial" size="2">        if yn == 2 : filename = askopenfilename(filetypes=[(&quot;allfiles&quot;,&quot;*&quot;),(&quot;pythonfiles&quot;,&quot;*.py&quot;)])</font>

<br><font face="Arial" size="2">        if yn == 2 : self.lut = np.loadtxt(filename,dtype=np.float,skiprows=1)</font>
</p>

<p><font face="Arial" size="2">Class rrs_file(self,rrs):</font>

<br><font face="Arial" size="2">    filename = askopenfilename(filetypes=[(&quot;allfiles&quot;,&quot;*&quot;),(&quot;pythonfiles&quot;,&quot;*.py&quot;)])</font>

<br><font face="Arial" size="2">    rrs = np.loadtxt(filename,dtype=np.float,skiprows=1)</font>

<br><font face="Arial" size="2">    </font>

<br><font face="Arial" size="2">def make_comp():</font>

<br><font face="Arial" size="2">    result = self.lut[1,2] * rrs[1,2]</font>

<br><font face="Arial" size="2">    print result</font>

<br><font face="Arial" size="2">    </font>

<br><font face="Arial" size="2">def callback():</font>

<br><font face="Arial" size="2">    print &quot;called the callback!&quot;</font>
</p>

<p><font face="Arial" size="2">root = Tk()</font>
</p>

<p><font face="Arial" size="2"># create a menu</font>

<br><font face="Arial" size="2">menu = Menu(root)</font>

<br><font face="Arial" size="2">root.config(menu=menu)</font>
</p>

<p><font face="Arial" size="2">filemenu = Menu(menu)</font>

<br><font face="Arial" size="2">menu.add_cascade(label=&quot;LUT&quot;, menu=filemenu)</font>

<br><font face="Arial" size="2">filemenu.add_command(label=&quot;East Pacific&quot;, command=lambda:openfile(0))</font>

<br><font face="Arial" size="2">filemenu.add_command(label=&quot;NW Atlantic&quot;, command=lambda:openfile(1))</font>
</p>
<br>

<p><font face="Arial" size="2">image_menu = Menu(menu)</font>

<br><font face="Arial" size="2">menu.add_cascade(label=&quot;Rrs&quot;, command=rrs_file)</font>
</p>

<p><font face="Arial" size="2">run_menu = Menu(menu)</font>

<br><font face="Arial" size="2">menu.add_cascade(label=&quot;Run&quot;, command = make_comp)</font>
</p>

<p><font face="Arial" size="2">quitmenu = Menu(menu)</font>

<br><font face="Arial" size="2">menu.add_cascade(label=&quot;Quit&quot;, command=root.destroy)</font>
</p>

<p><font face="Arial" size="2">#x = openfile(2)</font>
</p>

<p><font face="Arial" size="2">mainloop()</font>
</p>
<br>

<p><font face="Arial" size="2">I can not figure out how to pass get the lut and rrs parameters that I have defined in the class objects?</font>
</p>

<p><font face="Arial" size="2">I need help !!!</font>
</p>

<p><font face="Arial" size="2"> Thank you very much in advance.</font>
</p>

<p><font face="Arial" size="2">    Emmanuel</font>
</p>

</div>
<br>_______________________________________________<br>
Tkinter-discuss mailing list<br>
<a href="mailto:Tkinter-discuss@python.org">Tkinter-discuss@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/tkinter-discuss" target="_blank">http://mail.python.org/mailman/listinfo/tkinter-discuss</a><br>
<br></blockquote></div><br>