[Tutor] calling functions with buttons - why doesn't this work??

wheelege wheelege@tsn.cc
Sun, 29 Oct 2000 13:28:10 +1100


This is a multi-part message in MIME format.

------=_NextPart_000_001A_01C041AC.14FBCAC0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

There are alot of things I don't understand about Tkinter.

I was trying to call a function from a button, and it wouldn't work.  So =
I wrote this little thing and even it doesn't work.  When it is run it =
executes hi() but not when the button is pressed.  Help?  As a side =
note, why isn't my window title 'yo'?

Here is the code...

from Tkinter import *
root =3D Tk()
root.title =3D 'yo'

def hi():
    print 'hi'

f =3D Frame(root)
b =3D Button(text=3D'hi', command=3Dhi())
f.pack()
b.pack()


------=_NextPart_000_001A_01C041AC.14FBCAC0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4134.600" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV>There are alot of things I don't understand about Tkinter.</DIV>
<DIV>&nbsp;</DIV>
<DIV>I was trying to call a function from a button, and it wouldn't =
work.&nbsp;=20
So I wrote this little thing and even it doesn't work.&nbsp; When it is =
run it=20
executes hi() but not when the button is pressed.&nbsp; Help?&nbsp; As a =
side=20
note, why isn't my window title 'yo'?</DIV>
<DIV>&nbsp;</DIV>
<DIV>Here is the code...</DIV>
<DIV>&nbsp;</DIV>
<DIV>
<DIV>
<DIV>
<DIV>from Tkinter import *<BR>root =3D Tk()<BR>root.title =3D 'yo'</DIV>
<DIV>&nbsp;</DIV>
<DIV>def hi():<BR>&nbsp;&nbsp;&nbsp; print 'hi'</DIV>
<DIV>&nbsp;</DIV>
<DIV>f =3D Frame(root)<BR>b =3D Button(text=3D'hi',=20
command=3Dhi())<BR>f.pack()<BR>b.pack()<BR></DIV></DIV></DIV></DIV></BODY=
></HTML>

------=_NextPart_000_001A_01C041AC.14FBCAC0--