Tkinter + Button widget

Laura Creighton lac at strakt.com
Sat Mar 9 18:22:18 EST 2002


> 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))
> 
> any help would greatly be appreciated.
> 
> Adonis
> 
> 
> 
> --__--__--
> 
> Message: 6
> From: "Adonis Vargas" <deltapigz at telocity.com>
> Newsgroups: comp.lang.python
> Subject: Tkinter + Button widget
> Date: Sat, 9 Mar 2002 17:33:32 -0500
> Lines: 18
> NNTP-Posting-Host: nopics.sjc
> Message-ID: <3c8a91ed$1_2 at nopics.sjc>
> Path: news.baymountain.net!uunet!ash.uu.net!sac.uu.net!news.compaq.com!paloalto-snf1.gtei.net!n
> ews.gtei.net!enews.sgi.com!telocity-west!TELOCITY!nopics.sjc!directvdsl.com
> Xref: news.baymountain.net comp.lang.python:151323
> To: python-list at python.org
> Sender: python-list-admin at python.org
> Precedence: bulk
> List-Help: <mailto:python-list-request at python.org?subject=help>
> List-Post: <mailto:python-list at python.org>
> List-Subscribe: <http://mail.python.org/mailman/listinfo/python-list>,
> 	<mailto:python-list-request at python.org?subject=subscribe>
> List-Id: General discussion list for the Python programming language <python-list.python.org>
> List-Unsubscribe: <http://mail.python.org/mailman/listinfo/python-list>,
> 	<mailto:python-list-request at python.org?subject=unsubscribe>
> List-Archive: <http://mail.python.org/pipermail/python-list/>
> 
> 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))
> 
> any help would greatly be appreciated.
> 
> Adonis

You don't pass paramenters to commands that you want to run when you
click a button like that.  All command wants is the name of the
command you are going to run.  If you need to pass an argument it
is usual to get out the lambda, so something like this ought to work.

pdb_btnSearch = Button(pdb_frmCommands,
                       text="Search",
                       relief=GROOVE,
                       font=("Tahoma", 10),
                       width=16,
                       command=lambda s=self, arg=pdb_frmNewClient : 
                       s.HideNewClient(arg))

Laura Creighton




More information about the Python-list mailing list