当前的Julia Gtk.jl包中未实现GtkListbox吗?

时间:2019-09-29 05:07:51

标签: listbox gtk julia signals glade

我正在使用Glade将列表框添加到窗口,然后使用Gtk.jl的GtkBuilder将GUI加载到Julia中。加载列表框时,Julia认为它是GtkContainer小部件而不是列表框(除了一个或两个注释外,Julia包的源代码中似乎不存在该列表框)。我已经搜索了Gtk.jl源代码,但是什么都找不到(或者对我正在看的东西了解不多)。

一些“列表框”信号有效,但最重要的信号(“行激活”)无效。我真的需要这个信号来发射...这没有实现吗?有错误吗?难道我做错了什么?我是否只需要使用更复杂的GtkTreeView?

julia代码中注释掉的行是不会触发的信号(我也不是很在意)。根据Gtk文档,“激活”信号用于GtkListboxRow,它是用户需要使用的“行激活”信号,但我无法使其发出...

“列表框Example.glade”:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
  <requires lib="gtk+" version="3.20"/>
  <object class="GtkWindow" id="win">
    <property name="can_focus">False</property>
    <child>
      <placeholder/>
    </child>
    <child>
      <object class="GtkListBox" id="lb">
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <child>
          <object class="GtkListBoxRow">
            <property name="width_request">100</property>
            <property name="height_request">80</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <child>
              <object class="GtkLabel">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="label" translatable="yes">label1</property>
              </object>
            </child>
          </object>
        </child>
        <child>
          <object class="GtkListBoxRow">
            <property name="width_request">100</property>
            <property name="height_request">80</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <child>
              <object class="GtkLabel">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="label" translatable="yes">label2</property>
              </object>
            </child>
          </object>
        </child>
        <child>
          <object class="GtkListBoxRow">
            <property name="width_request">100</property>
            <property name="height_request">80</property>
            <property name="visible">True</property>
            <property name="can_focus">True</property>
            <child>
              <object class="GtkLabel">
                <property name="visible">True</property>
                <property name="can_focus">False</property>
                <property name="label" translatable="yes">label3</property>
              </object>
            </child>
          </object>
        </child>
      </object>
    </child>
  </object>
</interface>
using Gtk

app = GtkBuilder(filename = "listbox Example.glade")

win = app["win"]

lb = app["lb"]

showall(win)

# id1 = signal_connect(lb, "activate-cursor-row") do widget
#     println("activate-cursor-row")
# end

# id2 = signal_connect(lb, "move-cursor") do widget
#     println("move-cursor")
# end

id3 = signal_connect(lb, "row-activated") do widget
    println("row-activated")
end

id4 = signal_connect(lb, "row-selected") do widget
    println("row-selected")
end

id5 = signal_connect(lb, "select-all") do widget
    println("select-all")
end

id6 = signal_connect(lb, "selected-rows-changed") do widget
    println("selected-rows-change")
end

# id7 = signal_connect(lb, "toggle-cursor-row") do widget
#     println("toggle-cursor-row")
# end

id8 = signal_connect(lb, "unselect-all") do widget
    println("unselect-all")
end

# id9 = signal_connect(lb, "activate") do widget
#     println("activate")
# end
julia> typeof(lb)
Gtk.GtkContainerLeaf

1 个答案:

答案 0 :(得分:2)

每个信号都有自己的一组参数。例如,“ selected-rows-changed”仅具有小部件,而“ row-activated”具有小部件和行。

https://developer.gnome.org/gtk3/stable/GtkListBox.html#GtkListBox-selected-rows-changed https://developer.gnome.org/gtk3/stable/GtkListBox.html#GtkListBox-row-activated

您应该更改:

id3 = signal_connect(lb, "row-activated") do widget
    println("row-activated")
end

收件人:

id3 = signal_connect(lb, "row-activated") do widget, row
    println("row-activated")
end