On Mon, Nov 17, 2014 at 4:14 AM, Davy Cottet <cottet.d...@gmail.com> wrote:

>
> Now, how do I declare a new command for every builder ?
>
> I've tr
> ​i​
> ed this :
>
>
> ​​
> table = []
>     for builder in builders:
>         @g.command('make-'+builder)
>
> ​​
> def mymakecommand(keywords):
>
> ​​
> make(builder)
>         table.append((builder,None,'make-'+builder),)
>
> ​​
> c.frame.menu.
> ​​
> createMenuEntries(makeMenu, table)
>

​This should work:

​    ​def mymakecommand(keywords,builder=builder):​
        ​make(builder)

Here is my test script::

    def make(arg):
        g.trace(arg)

    # parent = c.frame.menu.menuBar
    # makeMenu = c.frame.menu.new_menu(parent,tearoff=False,label='Make')
    builders = ('abc','xyz',)
    table = []
    for builder in builders:
        @g.command('make-'+builder)
        def junk_f(keywords,builder=builder):
            make(builder)
        table.append((builder,None,'make-'+builder),)
    # c.frame.menu.createMenuEntries(makeMenu,table)
    for s in builders:
        c.k.simulateCommand('make-'+s)

HTH

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to