Thank you Christian.  I was going to write an example similar to yours but
didn't have time at the moment.

Bill

On May 4, 2017 3:03 PM, "Christian Kanzian" <christian.kanz...@gmx.at>
wrote:

> Am Donnerstag, 4. Mai 2017, 20:02:02 CEST schrieb Holger Klemm:
> > Thanks for the function. I do not understand how I must use that :-(
> > choice_table?
>
> AFAIK a combobox stores its entries like a lua table with indices.
> Updating lua table entries can only be done be looping over the entries?
> That
> is what Bill suggest in his reply.
>
> Merging your test.lua with Bill's answer like that works for me:
>
> local dt = require "darktable"
>
> test_combobox = dt.new_widget("combobox")
> {
>     label = 'test combobox',
>     tooltip ='',
>     value = 1,
>     editable=true,
>     "1","2","3","4","5",
>     reset_callback = function(self_reset)
>        self_reset.value = 1
>     end
> }
>
>
> local function update_combobox_choices(combobox, choice_table, selected)
>     local items = #combobox
>     local choices = #choice_table
>     for i, name in ipairs(choice_table) do
>     combobox[i] = name
>     end
>     if choices < items then
>     for j = items, choices + 1, -1 do
>     combobox[j] = nil
>         end
>     end
>     combobox.value = selected
>     end
>
> local new_choices = {"XX","YY"}
>
> add_button = dt.new_widget("button")
>     {
>       label = 'change combobox',
>       clicked_callback = function (x)
>             update_combobox_choices(test_combobox,new_choices,2)
>         dt.print("combobox changed")
>       end
>     }
>
>
> local import_widget =   dt.new_widget("box") {
>     test_combobox,
>     add_button,
>
>  }
>
> Christian
>
> >
> > Am Mittwoch, 3. Mai 2017, 15:55:42 CEST schrieb William Ferguson:
> > > local function update_combobox_choices(combobox, choice_table,
> selected)
> > >
> > >   local items = #combobox
> > >   local choices = #choice_table
> > >   for i, name in ipairs(choice_table) do
> > >
> > >     combobox[i] = name
> > >
> > >   end
> > >   if choices < items then
> > >
> > >     for j = items, choices + 1, -1 do
> > >
> > >       combobox[j] = nil
> > >
> > >     end
> > >
> > >   end
> > >   combobox.value = selected
> > >
> > > end
> >
> > ____________________________________________________________
> _______________
> > darktable developer mailing list
> > to unsubscribe send a mail to darktable-dev+unsubscribe@
> lists.darktable.org
>
>
> ____________________________________________________________
> _______________
> darktable developer mailing list
> to unsubscribe send a mail to darktable-dev+unsubscribe@
> lists.darktable.org
>
>

___________________________________________________________________________
darktable developer mailing list
to unsubscribe send a mail to darktable-dev+unsubscr...@lists.darktable.org

Reply via email to