newbie needs help with tkinter
Joonas Paalasmaa
joonas at olen.to
Sun Mar 10 17:39:03 EST 2002
Sacchi wrote:
>
> I've just learned the main rules of python(I already knew both java and
> C). Now I'm trying to get something out of Tkinter, but while running
> this sample program (made by myself) I encountered a problem. I wanted
> that by clicking on the "configura" command under the "File" menu the
> frame would get yellow and that a label would appear on it. The
> function works(the line "print "hello!"" gets executed) but the gui
> window doesn't change. I even tried to use the widget redraw methods
> but with no success... anyone can help me please?
>
> Thanks in advance
> Marco
>
> --------- Program Code ----------------------
>
> from Tkinter import *
>
> class Application(Frame):
>
> def __init__(self,master=None):
> Frame.__init__(self,master)
> menubar=self.addmenubar()
> master.config(menu=menubar)
> menubar.mainloop()
>
> def addmenubar(self):
> menubar=Menu()
> filemenu=Menu(menubar)
> menubar.add_cascade(menu=filemenu,label="File")
> #these lines got shifted by the newsreader program, but all belong to
> #the addmenubar function
> filemenu.add_command(label="Configura"command=self.configframe)
Isn't a comma required here? ---------> ^
> filemenu.add_command(label="Lavora")
> return menubar
>
> def configframe(self):
> self.set(bg="yellow")
> w=Label(self,fg="blue",text="prova")
> w.grid()
> self.update_idletasks()
> print "hello!"
>
> #main
>
> root=Tk()
> applicazione=Application(root)
> root.mainloop()
> --
> -----------------------------------------------------
> remove "nospam" from email address to answer
> -----------------------------------------------------
More information about the Python-list
mailing list