Tkinter + Button widget

Grant Edwards grante at visi.com
Sat Mar 9 19:13:22 EST 2002


In article <3c8a943b$1_3 at nopics.sjc>, Adonis Vargas wrote:
> when i start a button widget, it automatically fires the command?
> 
>     def HideNewClient(self, frame):
>         frame.configure(bd=0, width=0, height=0)
>         return
> 
>         pdb_btnSearch = Button(pdb_frmCommands,
>                                text="Search",
>                                relief=GROOVE,
>                                font=("Tahoma", 10),
>                                width=16,
>                                command=self.HideNewClient(pdb_frmNewClient))
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
You're "firing the command" right there.

You probably want to do something like:

  pdb_btnSearch = Button(pdb_frmCommands,
                  [...]
                  command = lambda x=pdb_frmNewClient: self.HideNewClient(x)

or

  def cmdProc():
      return self.HideNewClient(pdb_frmNewClient)
  pdb_btnSearch = Button(pdb_frmCommands,
                  [...]
                  command = cmdProc
      

-- 
Grant Edwards                   grante             Yow!  Can you MAIL a BEAN
                                  at               CAKE?
                               visi.com            



More information about the Python-list mailing list