首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >gtk2Hs :用文字和图片组合框

gtk2Hs :用文字和图片组合框
EN

Stack Overflow用户
提问于 2015-02-01 00:09:01
回答 1查看 184关注 0票数 1

Gtk提供的基本ComboBox只能处理StringPixbuf

但我想要一张文本和一张图片在同一行选择的附近。

我花了一段时间研究如何使用Haskell和Gtk2Hs获得以下结果。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-02-01 00:09:01

下面是获得预期结果的代码:

代码语言:javascript
复制
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

诚挚的问候。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28258030

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档