[Tkinter-discuss] writing a function to create button

Cameron Laird Cameron at phaseit.net
Tue Jun 20 20:43:21 CEST 2006


On Fri, May 05, 2006 at 04:53:30PM +0300, Ilknur Ozturk wrote:
			.
			.
			.
> Actually my aim is a little bit different. I put one of the buttons in
> my code;
> 
>         button_name = "menu"
>         self.menu = Button(self.mycontainer,
>                              command=lambda
>                              arg1=button_name:
>                               self.writecommand(arg1) 
>                              ) 
>         self.menu.configure(text="menu")
>         self.menu.grid(row=2, column=0)
>         ch = "<m>"
>         self.menu.bind(ch,
>                        lambda
>                        event, arg1=button_name:
>                        self.writecommand(arg1)
>                        )
> 
> This part repeatedly occurs in my code for different buttons, but those
> buttons placed in a different frames (not each in one, group by group)
> 
> For each button, button_name, configuration and geometry are changing.
> It can be divided 2 or more functions if it can be achieved in any way. 
			.
			.
			.
This confuses me.

I'm trying to catch up on a few loose ends; I'm in arrears by 
weeks.  I've re-read this thread, and I still don't understand the
aim.  I'm confident, though, that there are easier ways to meet
the true requirements.  Is the intent to work with Buttons, or
Menubuttons?  It's quite unusual to need to bind conventional
events to Buttons; it's more typical to rely on .command.

My suggestion:  simplify your question down to a more "atomic" 
one.  There are too many things going on in the code above for me
to understand.


More information about the Tkinter-discuss mailing list