3

When I run this program, the treeWiew widget showed with white background and nothing else. I think, it's a bug but I'm not sure. I do not want report a bug which is not a bug.

testTree :: Tree String
testTree =
    (Node "root" 
        [(Node "child" 
            [(Node "rose" []),
            (Node "cry" 
                [(Node "karma" [])])]),
        (Node "future" []),
        (Node "destiny" 
            [(Node "call" []),
            (Node "saw" [])]),
        (Node "reason" [])])

start :: IO ()
start =
    builderNew >>= (\builder ->
        builderAddFromFile builder "graphic.glade" >>
        builderGetObject builder castToWindow "mainWindow" >>= (\window ->
            widgetShowAll window >>
            windowMaximize window >>
            (window `on` deleteEvent) (liftIO (widgetDestroy window >> mainQuit >> return True))) >>
        builderGetObject builder castToTreeView "treeView" >>= (\tv -> 
            treeStoreNew [testTree] >>= (\ts ->
                treeViewSetModel tv ts)) >>
        return ())

gtkmain :: IO ()
gtkmain = 
    initGUI     >>  
    start >>
    mainGUI  

main = gtkmain
rosetree
  • 305
  • 2
  • 9
  • Is there a particular reason you're using `>>=` and `>>` instead of do notation? It might make your code more readable, which can help track down problems in your code. – bheklilr Sep 12 '14 at 18:43
  • 1
    I love operators >>= and >> – rosetree Sep 12 '14 at 18:44
  • Fair enough, I just don't see many people who do. – bheklilr Sep 12 '14 at 18:49
  • I think you may need to explicitly re-draw the treeView after setting the model, but I'm not very familiar with using the builder/glade API. – John L Sep 13 '14 at 01:17
  • I tryed functions widgetShow and widgetQueueDraw (for redrawing the widget), both called after setting treeStore and nothing changed. – rosetree Sep 13 '14 at 08:47
  • Your setup is not complete. You need to add TreeViewColumns, CellRenderers and so on. They determine what pieces of data must be displayed and how the must be shown in the TreeView. – Alfonso Villén Sep 20 '14 at 11:59

0 Answers0