Dear Bob<br>Thank you very much for your detailed script. I could do my script using this.<br>Thank you once again<br>Vinu V.<br><br><div><span class="gmail_quote">On 3/30/07, <b class="gmail_sendername">Bob Greschke</b> <
<a href="mailto:bob@passcal.nmt.edu">bob@passcal.nmt.edu</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">#! /bin/env python2.3
<br><br>from Tkinter import *<br>from sys import exit<br><br>Root = Tk()<br><br>InputVar = StringVar()<br>OutputVar = StringVar()<br><br><br>######################<br># BEGIN: class Command<br># Pass arguments to functions from button presses and menu
<br>selections! Nice!<br># In your declaration: ...command = Command(func, args,...)<br># Also use in bind() statements<br># x.bind("<****>", Command(func, args...))<br>class Command:<br> def __init__(self, func, *args, **kw):
<br> self.func = func<br> self.args = args<br> <a href="http://self.kw">self.kw</a> = kw<br> def __call__(self, *args, **kw):<br> args = self.args+args<br> kw.update(<a href="http://self.kw">
self.kw</a>)<br> apply(self.func, args, kw)<br># END: class Command<br><br><br><br><br>###############################<br># BEGIN: XSqCalc(InVar, OutVar)<br>def XSqCalc(InVar, OutVar):<br> Value = InVar.get().strip()
<br> if Value == "":<br> OutVar.set("error")<br> return<br> Value = float(Value)<br> Value = Value*Value<br> OutVar.set(str(Value))<br> return<br># END: def XSqCalc<br>
<br><br><br><br>Label(Root, text = "Enter a value in the field\non the left, click the<br>\n\"X^2\"<br>button and see the\nanswer in the field on the right.").pack(side = TOP)<br>Sub = Frame(Root)<br>Entry(Sub, width = 10, textvariable = InputVar, bg = "white", \
<br> fg = "black").pack(side = LEFT)<br>Label(Sub, text = " ").pack(side = LEFT)<br>Button(Sub, text = "X^2", command = Command(XSqCalc, InputVar, \<br> OutputVar)).pack(side = LEFT)
<br>Label(Sub, text = " ").pack(side = LEFT)<br>Entry(Sub, width = 10, textvariable = OutputVar, bg = "white", \<br> fg = "black").pack(side = LEFT)<br>Sub.pack(side = TOP, padx = 5, pady = 5)
<br>Button(Root, text = "Quit", command = exit).pack(side = TOP)<br><br>Root.mainloop()<br><br><br>That python2.3 line at the beginning may need to be changed for your<br>system.<br>The text of that first Label() should all be on the same line.
<br><br>Bob<br><br>On Mar 30, 2007, at 11:35, Vinu Vikram wrote:<br><br>> Dear All<br>> I wrote a python script which will take values from a<br>> configuration file and perform some operation and give an answer. I
<br>> would like to make a gui for the script using Tkinter. Could<br>> anybody help me to do that? Suppose my script use a variable 'x' to<br>> calculate x^2. I would like to give the value x=2 through a GUI and
<br>> get the output in the same window. Please help me to find the<br>> solution.<br>> Thanking You<br>> Vinu V.<br>> --<br>> VINU VIKRAM<br>> <a href="http://iucaa.ernet.in/~vvinuv/">http://iucaa.ernet.in/~vvinuv/
</a><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">
http://mail.python.org/mailman/listinfo/tkinter-discuss</a><br><br></blockquote></div><br><br clear="all"><br>-- <br>VINU VIKRAM<br><a href="http://iucaa.ernet.in/~vvinuv/">http://iucaa.ernet.in/~vvinuv/</a>