首页 > 解决方案 > nim 语言,gintro 演示,在 listview / gtktreeview 中有两列,可排序

问题描述

对于 nim 语言,只有一个 gui 工具包对我有用,那就是 gintro。

演示代码列表视图在我的 netbsd 上编译并运行良好。资料来源: http ://ssalewski.de/gintroreadme.html

但是我需要一个包含两列的列表视图(gtktreeview),我查看了 nim.gtk 但无法弄清楚我应该拼写哪些“演员”。

演示程序中的代码:

let gtype = typeFromName("gchararray")
let store = newListStore(N_COLUMNS, cast[pointer]( unsafeaddr gtype)) 
# cast due to bug in gtk.nim

适用于N_COLUMNS=1但不适用N_COLUMNS:2

这是 nim.gtk 中的相关部分:

proc newListStore*(nColumns: int; types: GTypeArray): ListStore =
    let gobj = gtk_list_store_newv(int32(nColumns), types)

其次,当我有多个列时,我想通过单击标题使其可排序(如 Excel 表)

标签: gtk3nim-lang

解决方案


我认为你需要这样的东西:

let gtypes = [typeFromName("gchararray"), typeFromName("gchararray")] # Be sure to change the types to whatever you need.
let store = newListStore(N_COLUMNS, addr gtype[0]) # You shouldn't need this weird cast here.

未经测试,但应该可以工作。如果您需要更多帮助,请随时加入我们的 Gitter/IRC :)


推荐阅读