1

ComboBoxGtk が提供する基本は aStringまたは aのみを処理できます。Pixbuf

しかし、選択範囲の同じ行の近くにテキストと画像が必要でした。

Haskell と Gtk2Hs を使用して以下の結果を取得する方法をしばらく探しました。

ここに画像の説明を入力

4

1 に答える 1

2

期待される結果を得るためのコードは次のとおりです。

pic1 <- pixbufNewFromFile "Picture_1.png"
pic2 <- pixbufNewFromFile "Picture_2.png"
pic3 <- pixbufNewFromFile "Picture_3.png"

let lstsecrep = [
                  ("Picture 1",pic1)
                , ("Picture 2",pic2)
                , ("Picture 3",pic3)
                ]

lststorerep <- listStoreNew lstsecrep 

customStoreSetColumn lststorerep (makeColumnIdString 0) fst
customStoreSetColumn lststorerep (makeColumnIdPixbuf 1) snd

combo <- comboBoxNewWithModel lststorerep

rendertxt <- cellRendererTextNew
renderpic <- cellRendererPixbufNew

cellLayoutPackStart  combo rendertxt False
cellLayoutPackStart  combo renderpic True
cellLayoutAddColumnAttribute combo rendertxt cellText $ makeColumnIdString 0
cellLayoutAddColumnAttribute combo renderpic cellPixbuf $ makeColumnIdPixbuf 1

よろしくお願いします。

于 2015-02-01T00:09:01.210 に答える