[Haskell-cafe] Gtk2hs multiple column TreeView with ListStore issue

Andy Stewart lazycat.manatee at gmail.com
Sun Mar 20 12:52:21 CET 2011


Andy Stewart <lazycat.manatee at gmail.com> writes:

> Hi Кирилл,
>
> Here have a simplest code at http://code.haskell.org/gtk2hs/gtk/demo/treelist/ListDemo.hs
>
> Cheers, 
>
>   -- Andy
>
> PS:
>
>   All gtk2hs user, it's always best choose to read source code of demo
>   when you don't know how to fix some problem.
>   
>   Demo has include in Cabal package.
>   Example, we have build demo sub-directory in package gtk-0.12.0.tar.gz 
>   Otherwise package, such as Cairo and Pango is same. 
Others package, damn english helper. :)

  -- Andy

>   
>   Of course, ask in gtk2hs-user mailing-list (gtk2hs-users at lists.sourceforge.net) are welcome! :)
>
> Кирилл Березин <pechenie.k at gmail.com> writes:
>
>> I cannot force GTK to render data in TreeView with ListStore model with multiple columns through
>> Haskell. I have the following code
>>
>> addTextColumn view name =
>>
>>     do
>>
>>     col <- treeViewColumnNew
>>
>>     rend <- cellRendererTextNew
>>
>>     treeViewColumnSetTitle col name
>>     treeViewColumnPackStart col rend True
>>     treeViewColumnSetExpand col True
>>     treeViewAppendColumn view col
>>
>> prepareTreeView view = 
>>
>>     do
>>
>>     addTextColumn view "column1"
>>
>>     addTextColumn view "column2"
>>
>>     --adding data here
>>
>> Then I try to add some data, and there are problems. I tried these:
>>
>>     --variant 1 (data TRow = TRow {one::String, two::String}
>>
>>     model <- listStoreNew ([] :: [TRow])
>>
>>     listStoreAppend model $ TRow { one = "Foo", two = "Boo" }
>>
>>     treeViewSetModel view model
>>
>>     --variant 2
>>
>>     model <- listStoreNew ([] :: [[String]])
>>
>>     listStoreAppend model ["foo","boo"]
>>
>>     treeViewSetModel view model
>>
>>     --variant 3
>>
>>     model <- listStoreNew ([] :: [(String, String)])
>>
>>     listStoreAppend model ("foo", "boo")
>>
>>     treeViewSetModel view model
>>
>> But in all cases I see the table with column header and one blank row inserted. Any help will be
>> appreciated.
>>
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe




More information about the Haskell-Cafe mailing list