使用Glade在Gtk treeview中创建具有可编辑单元格的列 [英] Creating columns with editable cells in Gtk treeview using Glade

查看:311
本文介绍了使用Glade在Gtk treeview中创建具有可编辑单元格的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用包含样本的x和y坐标的表格创建一个简单的GUI。我使用treeview,我希望表格的单元格可以由用户编辑。是否可以指定单元格是否可以直接在Glade中的cellrenderer属性中编辑,还是必须在我的代码中指定它?我使用Glade 3.6.1

I am trying to create a simple GUI with table containing x and y coordinates of samples. I use treeview, and I want the cells of the table to be editable by user. Is it possible to specify if the cells should be editable directly in Glade in cellrenderer properties, or do I have to specify it in my code? I use Glade 3.6.1

在编辑我的树视图时,我刚刚发现在树视图编辑器中不使用框Editable,使我可以指定单元格是否应可编辑或不可编辑,因为如果该框未被选中,单元格可编辑属性将不再与模型相关联。
但是如果我运行该程序,单元格是可编辑的,但是我写入的值消失了。我该如何解决这个问题?为什么单元格不存储我输入的值?

I have just found out that unticking box "Editable" in the Tree View Editor when editing my treeview, enables me to specify whether the cells shall be editable or not, because if the box is unticked, the cells editable property is no longer connected with the model. But if I run the program, cells are editable, but the value that I write inside disappears. How can I fix that? Why doesn't the cell store the value I type inside?

感谢您的任何提示

推荐答案

问题,我解决了它 - 每当一个单元格被编辑时,模型中的适当记录需要改变,例如Python代码:

For anyone dealing with a similar problem, I have solved it - whenever a cell is edited, appropriate record in the model needs to be changed, example code in Python:

cell.connect("edited", self.text_edited, model, column)

def text_edited( self, w, row, new_text, model, column)
  model[row][column] = new_text

这篇关于使用Glade在Gtk treeview中创建具有可编辑单元格的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆