newbie needs help with tkinter

Bertrand Geston bergeston at yahoo.fr
Mon Mar 11 08:02:40 EST 2002


And you can even comment the line:
self.update_idletasks()
it works as well !


"Bertrand Geston" <bergeston at yahoo.fr> wrote in message
news:a6i9p3$eip6d$1 at ID-135695.news.dfncis.de...
> Beeing newbie myself, I played with you code, here is the result:
>
> -----------------------------------------------------------
> from Tkinter import *
>
> class Application(Frame):
>     def __init__(self,master=None):
>         Frame.__init__(self,master)
>         menubar=self.addmenubar()
>         master.config(menu=menubar)
>         w=Label(self,fg="green",text="*")
>         self.pack()
>         w.grid()
>
>     def addmenubar(self):
>         menubar=Menu()
>         filemenu=Menu(menubar)
>         menubar.add_cascade(menu=filemenu,label="File")
>      filemenu.add_command(label="Configura", command=self.configframe)
>         filemenu.add_command(label="Lavora")
>         return menubar
>
>     def configframe(self):
>         self.config(bg="yellow")
>         w=Label(self,fg="blue",text="prova")
>         w.grid()
>         self.update_idletasks()
>         print "hello!"
>
> #main
>
> root=Tk()
> applicazione=Application(root)
> root.mainloop()
>
> -----------------------------------------------------------
>
> "Sacchi" <sacchi at nospamfreemail.it> wrote in message
> news:1Myi8.13667$%d1.409160 at twister2.libero.it...
> > 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)
> >         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