Hi Michael,

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. 

Thanks,

ilknur


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Michael Lange
Sent: Friday, May 05, 2006 12:42 PM
To: [email protected]
Subject: Re: [Tkinter-discuss] writing a function to create button

On Fri, 5 May 2006 11:04:20 +0300
"Ilknur Ozturk" <[EMAIL PROTECTED]> wrote:

> Hi all,
> 
>  
> 
> I prepared a GUI which contains lots of buttons. Instead of defining
> each of them one by one, I want to write a function that gets the
> parameters and create a button.(Each one calls same function for
> buttonclick event) Is it possible? If it is, can you give me a simple
> example?
> 

Hi Ilknur,

maybe you mean something like

    buttons = []
    r = 0
    c = 0
    for i in range(100):
        b = Button(master, text=i, **kw)
        b.grid(row=r, column=c)
        buttons.append(b)
        c += 1
        if c > 10:
            c = 0
            r += 1

I hope this helps

Michael
_______________________________________________
Tkinter-discuss mailing list
[email protected]
http://mail.python.org/mailman/listinfo/tkinter-discuss

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
_______________________________________________
Tkinter-discuss mailing list
[email protected]
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to