Problem with comboBox
I have send this mail to the gtkhs@haskell.org mailing list. I do not know if this list is active, so I reply the mail in this one. If the other list is active, I'm sorry. Hi, i'm making my first graphic interface program with Haskell. I use Glade and Gtk+2.0. I create an empty comboBox with Glade and I want to add items (strings) in run time (by means of the haskell code). I tried with the functions 'comboBoxAppendText' and 'comboBoxInsertText' (http://haskell.org/gtk2hs/docs/current/Graphics-UI-Gtk-MenuComboToolbar-Comb...) but I can not do anything for display the information I want. This functions require to work with a comboBox creates with the constructor comboBoxNewText (and I think this constructor is not the used by Glade). I can create it from Glade? I can do I want by another method? Thanks.
On 14/08/06, L. J. <djsenda@gmail.com> wrote:
Hi, i'm making my first graphic interface program with Haskell. I use Glade and Gtk+2.0. I create an empty comboBox with Glade and I want to add items (strings) in run time (by means of the haskell code). I tried with the functions 'comboBoxAppendText' and 'comboBoxInsertText' (http://haskell.org/gtk2hs/docs/current/Graphics-UI-Gtk-MenuComboToolbar-Comb...) but I can not do anything for display the information I want. This functions require to work with a comboBox creates with the constructor comboBoxNewText (and I think this constructor is not the used by Glade). I can create it from Glade? I can do I want by another method? Thanks.
You have two options: * In glade insert one-element, empty hbox (or vbox) instead of combobox, and then in runtime create a box with comboBoxNewText and add it into the hbox (or vbox). Now you can use comboBoxAppendText. * In glade insert comboBox as you do it now and in runtime add a model to that box (see attribute comboBoxModel). I am, however, not well versed in haskell interface to gtk+ so I can't help you with a model part (you can see how it is done for TreeView widget though). Regards, Piotr Kalinowski -- Intelligence is like a river: the deeper it is, the less noise it makes
On 8/14/06, Piotr Kalinowski <pitkali@gmail.com> wrote:
On 14/08/06, L. J. <djsenda@gmail.com> wrote:
Hi, i'm making my first graphic interface program with Haskell. I use Glade and Gtk+2.0. I create an empty comboBox with Glade and I want to add items (strings) in run time (by means of the haskell code). I tried with the functions 'comboBoxAppendText' and 'comboBoxInsertText' (http://haskell.org/gtk2hs/docs/current/Graphics-UI-Gtk-MenuComboToolbar-Comb...) but I can not do anything for display the information I want. This functions require to work with a comboBox creates with the constructor comboBoxNewText (and I think this constructor is not the used by Glade). I can create it from Glade? I can do I want by another method? Thanks.
You have two options:
* In glade insert one-element, empty hbox (or vbox) instead of combobox, and then in runtime create a box with comboBoxNewText and add it into the hbox (or vbox). Now you can use comboBoxAppendText.
* In glade insert comboBox as you do it now and in runtime add a model to that box (see attribute comboBoxModel). I am, however, not well versed in haskell interface to gtk+ so I can't help you with a model part (you can see how it is done for TreeView widget though).
Regards, Piotr Kalinowski -- Intelligence is like a river: the deeper it is, the less noise it makes
Thanks Piotr for reply so faster. I have tried to do the two options (firstly the second, which I have not do anything good because the models' dificulty). Then the first, I tried and I can do almost I want, but I can not connect the hvox with the comboBoxNewText even I read the Duncan's answer. Thanks you two very much.
On Mon, 2006-08-14 at 20:36 +0200, L. J. wrote:
I have send this mail to the gtkhs@haskell.org mailing list. I do not know if this list is active, so I reply the mail in this one. If the other list is active, I'm sorry.
No problem. :-) The gtkhs@haskell.org mailing list was for the now defunct GTK+HS project. The successor project which it looks like you've been using is Gtk2Hs. It's mailing lists are listed here: http://haskell.org/gtk2hs/development/#mailing_lists So you'd want gtk2hs-users@lists.sourceforge.net
Hi, i'm making my first graphic interface program with Haskell. I use Glade and Gtk+2.0. I create an empty comboBox with Glade and I want to add items (strings) in run time (by means of the haskell code). I tried with the functions 'comboBoxAppendText' and 'comboBoxInsertText' (http://haskell.org/gtk2hs/docs/current/Graphics-UI-Gtk-MenuComboToolbar-Comb...) but I can not do anything for display the information I want. This functions require to work with a comboBox creates with the constructor comboBoxNewText (and I think this constructor is not the used by Glade).
I can create it from Glade?
Sadly not, in Glade it allows you to create a general ComboBox. The comboBoxNewText convenience functions can only be used in the code, not from Glade.
I can do I want by another method?
So there are two things you can do. One is to use the general interface which means creating your own model which will hold the data you want to display. If you want to display anything more complex in the combo box than simple strings then this is the only method to choose. However I just realised that with the current Gtk2Hs releases we didn't bind quite enough functions for you to use a non-trivial model with a ComboBox. We'll fix that for the next release. So as Piotr suggested, you should create the combobox in code with comboBoxNewText rather than in glade and then that to the right place in the gui constructed with glade. For example: box <- xmlGetWidget xml castToBox "box1" combo <- comboBoxNewText containerAdd box combo widgetShow combo I'd like to note that the next release of Gtk2Hs will make it much much easier to create data models to use with views like the TreeView and ComboBox. Duncan
On 8/15/06, Duncan Coutts <duncan.coutts@worc.ox.ac.uk> wrote:
On Mon, 2006-08-14 at 20:36 +0200, L. J. wrote:
I have send this mail to the gtkhs@haskell.org mailing list. I do not know if this list is active, so I reply the mail in this one. If the other list is active, I'm sorry.
No problem. :-)
The gtkhs@haskell.org mailing list was for the now defunct GTK+HS project. The successor project which it looks like you've been using is Gtk2Hs.
It's mailing lists are listed here: http://haskell.org/gtk2hs/development/#mailing_lists
So you'd want gtk2hs-users@lists.sourceforge.net
Thanks you very much for the links. I`m sorry I do not know that.
Hi, i'm making my first graphic interface program with Haskell. I use Glade and Gtk+2.0. I create an empty comboBox with Glade and I want to add items (strings) in run time (by means of the haskell code). I tried with the functions 'comboBoxAppendText' and 'comboBoxInsertText' (http://haskell.org/gtk2hs/docs/current/Graphics-UI-Gtk-MenuComboToolbar-Comb...) but I can not do anything for display the information I want. This functions require to work with a comboBox creates with the constructor comboBoxNewText (and I think this constructor is not the used by Glade).
I can create it from Glade?
Sadly not, in Glade it allows you to create a general ComboBox. The comboBoxNewText convenience functions can only be used in the code, not from Glade.
I can do I want by another method?
So there are two things you can do. One is to use the general interface which means creating your own model which will hold the data you want to display. If you want to display anything more complex in the combo box than simple strings then this is the only method to choose.
However I just realised that with the current Gtk2Hs releases we didn't bind quite enough functions for you to use a non-trivial model with a ComboBox. We'll fix that for the next release.
So as Piotr suggested, you should create the combobox in code with comboBoxNewText rather than in glade and then that to the right place in the gui constructed with glade.
For example:
box <- xmlGetWidget xml castToBox "box1" combo <- comboBoxNewText containerAdd box combo widgetShow combo
Thanks you, it lack me the 'containerAdd' function.
I'd like to note that the next release of Gtk2Hs will make it much much easier to create data models to use with views like the TreeView and ComboBox.
Duncan
participants (3)
-
Duncan Coutts -
L. J. -
Piotr Kalinowski