[Tutor] tkinter newbie problem
wheelege
wheelege@tsn.cc
Sat, 28 Oct 2000 13:05:08 +1000
This is a multi-part message in MIME format.
------=_NextPart_000_0037_01C040DF.B2E04220
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi all. This is probably so mind-numbingly simple but hey - I'm a =
newbie.
can anyone see any problems with this?
from Tkinter import *
root =3D Tk()
root.title("I'm a Tkinter Program !")
mBar =3D Frame(root, relief=3DRAISED, borderwidth=3D2)
mBar.pack(fill=3DX)
CmdBtn =3D makeCommandMenu()
mBar.tk_menuBar(CmdBtn)#, CasBtn, ChkBtn, RadBtn, NoMenu)
def makeCommandMenu():
CmdBtn =3D Menubutton(mBar, text=3D'Button Commands', underline=3D0)
CmdBtn.pack(side=3DLEFT, padx=3D"2m")
CmdBtn.menu =3D Menu(CmdBtn)
CmdBtn.menu.add_command(label=3D"Undo")
CmdBtn.menu.entryconfig(0, state=3DDISABLED)
CmdBtn.menu.add_command(label=3D'New...', underline=3D0, =
command=3Dnew_file)
CmdBtn.menu.add_command(label=3D'Open...', underline=3D0, =
command=3Dopen_file)
CmdBtn.menu.add_command(label=3D'Wild Font', underline=3D0,
font=3D('Tempus Sans ITC', 14), =
command=3Dstub_action)
CmdBtn.menu.add_command(bitmap=3D"@bitmaps/RotateLeft")
CmdBtn.menu.add('separator')
CmdBtn.menu.add_command(label=3D'Quit', underline=3D0,
background=3D'white', =
activebackground=3D'green',
command=3DCmdBtn.quit)
print 'bitch'
CmdBtn['menu'] =3D CmdBtn.menu
return CmdBtn
root.mainloop()
This is almost exactly copied from John Grayson's book, but I cut some =
things from it.
I'm using Python 2.0. It keeps telling me there is an error with the =
makeCommandMenu thing,
says there is no such variable as mbar.
Help!
------=_NextPart_000_0037_01C040DF.B2E04220
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> Hi all. This is probably so mind-numbingly simple but =
hey -=20
I'm a newbie.</DIV>
<DIV> </DIV>
<DIV>can anyone see any problems with this?</DIV>
<DIV> </DIV>
<DIV>from Tkinter import *<BR>root =3D Tk()<BR>root.title("I'm a Tkinter =
Program=20
!")</DIV>
<DIV> </DIV>
<DIV>mBar =3D Frame(root, relief=3DRAISED,=20
borderwidth=3D2)<BR>mBar.pack(fill=3DX)<BR>CmdBtn =3D=20
makeCommandMenu()<BR>mBar.tk_menuBar(CmdBtn)#, CasBtn, ChkBtn, RadBtn,=20
NoMenu)<BR>def makeCommandMenu():<BR> CmdBtn =3D=20
Menubutton(mBar, text=3D'Button Commands', =
underline=3D0)<BR> =20
CmdBtn.pack(side=3DLEFT, padx=3D"2m")<BR> CmdBtn.menu =
=3D=20
Menu(CmdBtn)<BR> =20
CmdBtn.menu.add_command(label=3D"Undo")<BR> =20
CmdBtn.menu.entryconfig(0, state=3DDISABLED)<BR> =20
CmdBtn.menu.add_command(label=3D'New...', underline=3D0,=20
command=3Dnew_file)<BR> =
CmdBtn.menu.add_command(label=3D'Open...',=20
underline=3D0, command=3Dopen_file)<BR> =20
CmdBtn.menu.add_command(label=3D'Wild Font',=20
underline=3D0,<BR> &=
nbsp; &n=
bsp; =20
font=3D('Tempus Sans ITC', 14), =
command=3Dstub_action)<BR> =20
CmdBtn.menu.add_command(bitmap=3D"@bitmaps/RotateLeft")<BR> &n=
bsp;=20
CmdBtn.menu.add('separator')<BR> =20
CmdBtn.menu.add_command(label=3D'Quit',=20
underline=3D0,<BR> &=
nbsp; &n=
bsp; =20
background=3D'white',=20
activebackground=3D'green',<BR> =
&=
nbsp; =20
command=3DCmdBtn.quit)<BR> print =
'bitch'<BR> =20
CmdBtn['menu'] =3D CmdBtn.menu<BR> return =
CmdBtn<BR></DIV>
<DIV>root.mainloop()<BR></DIV>
<DIV>This is almost exactly copied from John Grayson's book, but I cut =
some=20
things from it.</DIV>
<DIV>I'm using Python 2.0. It keeps telling me there is an error =
with the=20
makeCommandMenu thing,</DIV>
<DIV>says there is no such variable as mbar.</DIV>
<DIV> </DIV>
<DIV>Help!</DIV></BODY></HTML>
------=_NextPart_000_0037_01C040DF.B2E04220--