【问题标题】:ComboBox in Gtk2hs compiling errorGtk2hs中的ComboBox编译错误
【发布时间】:2016-08-25 15:22:36
【问题描述】:

如何使用 Gtk2hs 处理 ComboBox? 在this 页面上,我找到了解决方案:

store <- listStoreNew ["green", "yellow", "..."]
comboElem <- comboBoxNewWithModel store
ren <- cellRendererTextNew
cellLayoutPackEnd comboElem ren True
cellLayoutSetAttributes comboElem ren store
  (\txt -> [cellText := Just txt])

但是在编译时出现此错误(发生在我的代码示例的最后一行):

Main.hs:36:17:
No instance for (System.Glib.UTFString.GlibString (Maybe [Char]))
  arising from a use of ‘cellText’
In the first argument of ‘(:=)’, namely ‘cellText’
In the expression: cellText := Just txt
In the expression: [cellText := Just txt]

我该如何解决这个问题?

提前致谢

【问题讨论】:

    标签: haskell combobox gtk2hs


    【解决方案1】:

    GlibString 似乎没有Maybe String 的实例。它可能在某一时刻有,但您应该能够只使用 cellText := txt 代替。如果出于某种原因您需要使用Maybe String,您可以自己实现该实例。

    【讨论】:

    • 可能更多的是cellText 的属性类型在某些时候(在某些Gtk2HS 版本中)从GlibString a =&gt; Maybe a 更改为GlibString a =&gt; a
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-12-16
    • 2011-11-12
    • 2016-07-14
    • 2014-12-25
    • 2017-06-14
    • 2014-09-24
    • 2015-11-25
    相关资源
    最近更新 更多