- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
当用户单击 TreeView 中的单元格时,是否有一种有效的方式/方法来检索 ListModel 中所选单元格的列?或者当我调用 get_selected() 方法时,是否没有 Cells 之类的东西,只能选择 Rows 并返回它们的 treeiter/model?
我想向用户展示一个数值矩阵,让他选择一个列,然后绘制这些值。
如果您手头有任何文档/示例,请不要犹豫分享:)
编辑:我试图做的是将列标题上的单击事件连接到一个函数,该函数为我提供了我在创建期间在列文本中编码的列号。但这似乎不太对..
如果有帮助的话,我可以创建一个最小的工作示例..
最佳答案
访问 GtkTreeView 中的“列”比乍一看要复杂一些。原因之一是列实际上可以包含多个项目,然后显示为新列,即使它们是“打包”的。
识别列的一种方法是为每个列分配一个 sort_id,但这会使标题可点击,如果排序实际上不起作用,这是不自然的。
我设计了这个(有点狡猾的)方法:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# test_coord.py
#
# Copyright 2016 John Coppens <john@jcoppens.com>
#
# This program is free software```; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
#
from gi.repository import Gtk
class MainWindow(Gtk.Window):
def __init__(self):
super(MainWindow, self).__init__()
self.connect("destroy", lambda x: Gtk.main_quit())
trview = Gtk.TreeView()
tstore = Gtk.ListStore(str, str, str)
renderer = Gtk.CellRendererText()
for i in range(3):
col = Gtk.TreeViewColumn("Col %d" % i, renderer, text = i)
col.colnr = i
trview.append_column(col)
trview.set_model(tstore)
trview.connect("button-press-event", self.on_pressed)
for i in range(0, 15, 3):
tstore.append((str(i), str(i+1), str(i+2)))
self.add(trview)
self.show_all()
def on_pressed(self, trview, event):
path, col, x, y = trview.get_path_at_pos(event.x, event.y)
print("Column = %d, Row = %s" % (col.colnr, path.to_string()))
def run(self):
Gtk.main()
def main(args):
mainwdw = MainWindow()
mainwdw.run()
return 0
if __name__ == '__main__':
import sys
sys.exit(main(sys.argv))
这里的技巧是利用 Python
提供的可能性将属性添加到现有类中。所以我向每一列添加了一个 colnr
并用它来识别被点击的单元格。在 C++ 中,需要使用 set_data
和 get_data
方法来做同样的事情(这在 Python
中不可用)。
关于python - Gtk3+ Pygobject 在 TreeView 中选择列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38057144/
我在一页上有两个 Kendo UI TreeViews。例如: var data1 = new kendo.data.HierarchicalDataSource({ data: [
使用 Vuetify 的 TreeView 组件时,我试图能够选择父级 没有 让它也选择所有的后代( child )。我尝试了可选、可激活等的各种组合……但似乎找不到合适的组合。 任何人都有实现这一预
在我的应用程序中,左侧有一个 TreeView,我根据 TreeView 中的选择更新右侧的 Pane 。一个非常直接的场景。当选择为空时,我会在 Pane 中显示一条类似“请进行选择”的消息,即我还
我有一个我自己无法解决的问题。请帮忙。 我有(有条件地): /** @mainpage A @subpage B */ /** @page B @subpage C */ /** @page C */
我制作了一个高度为 40 px 的自定义树单元。 这里的问题披露三角形没有垂直居中对齐。 这里是树单元的代码: public static class TestObjectCell extends A
我正在学习如何使用 kotlin 并已开始使用tornadoFX。我正在阅读该指南以尝试学习它,但是我无法弄清楚“具有不同类型的 TreeView”中的含义。似乎是说我应该使用星形投影,据我所知,当您
如何在 JavaFX 2 TreeView 中过滤节点? 我有一个 TextField,我想根据 TextField 的内容过滤所有节点(例如节点标签)。 谢谢。 最佳答案 这是我编写的可重用的可过滤
我正在通过查询 sharepoint 用户配置文件构建一个 asp.net TreeView 。要选择的帐户名和根节点帐户名正在从查询字符串中读取。 我还需要为树配置可配置的扩展深度。 如果节点属于第
我使用的是 JavaFX 8,目前正在进行一些 GUI 开发。我的 TreeView 有点问题,我需要你的帮助。 您知道在 TreeView 中是否可以只选择标签而不是 TreeCell 的整个宽度吗
我有很多(分层的)数据显示在 TreeView 中(可能是大约 20K 项或更多,包括子项)。我的数据的特殊问题是 TreeView 中显示的每个对象都可以存在于许多 TreeView 项目中。我的意
有没有什么简单的方法可以让 Gtk.Treeview 在编辑时更新它的列? 我基于 Gtk.ListStore 模型构建了 Treeview。我这样初始化单元格: Gtk.CellRendererTe
我开始使用 javafx。我有一个问题。我有一个树 View ,其中节点通过外部命令改变了他的位置,但它只是看不到树。我必须最小化父级并重新展开才能看到效果。 Altem 对该树 View 的任何建议
如何在 Kendo Treeview 中取消选择节点? 我尝试从节点中删除类“k-state-selected”。它工作正常,但有没有直接的方法可以做到这一点。 最佳答案 现在有一种更好的方法可以取消
我有以下情况,我有一个带有许多嵌套子节点的父节点。只有父节点应该有一个复选框,我发现的唯一例子是只有子节点有一个复选框。这可以使用 Kendo 模板吗? http://dojo.telerik.com
我正在尝试向 TreeView 数据项添加一些内联图标,但是 k-template 指令似乎没有呈现任何内容。 我基于在线文档在 http://demos.telerik.com/k
我有一个带有复选框和父节点和子节点的 Kendo Treeview 。 我需要将选中节点的完整层次结构复制到另一个 Treeview 中。 ex - 根节点、父节点和选中的子节点。 下面是我的代码,但
我需要在较大的滚动 Pane 中使用 JavaFX 2.2 TreeView 控件,该滚动 Pane 具有多个不属于 Treeview 的其他元素。问题是 TreeView 有它自己的内置滚动 Pan
当我通过单击 TreeView 节点右侧的加号来展开该节点时,该节点将被选中。我怎样才能避免这种情况?我希望能够在不更改所选节点的情况下展开节点(例如在 RegEdit.exe 中),并且仅在单击节点
我正在尝试设置一个 Treeview 对象,设置节点,然后更新控件以使值具有适当的格式。现在我有以下代码,当我设置一个控件时,它可以工作,但不是来自变量的控件。如何从变量设置本地控件? Private
如何将节点填充到作为另一个 treeview1 实例的 newtreeview1 中?添加到“newtreeview1”的节点应该在 treeview1 的第一个实例中可用? 例如;如果 treevi
我是一名优秀的程序员,十分优秀!