双击检索树视图数据
retrieve treeview data on double click
我正在尝试通过双击(row-activated
信号)检索 treeview
数据。
我现在已经通过 changed
信号做到了这一点:
self.view.get_selection().connect("changed", self.row_activated)
def row_activated(self, selection):
(model, iter) = selection.get_selected()
print(model[iter][:])
return True
但我无法使用 row-activated
:
self.view.connect("row-activated", self.row_activated)
def row_activated(self):
(model, iter) = self.view.get_selected()
print(model[iter][:])
return True
但是,这是错误的:
TypeError: row_activated() takes 1 positional argument but 4 were given
回答我自己的问题很奇怪,但我设法解决了它:
self.view.connect("row-activated", self.row_activated)
def row_activated(self, widget, row, col):
model = widget.get_model()
print(model[row][:])
return True
我正在尝试通过双击(row-activated
信号)检索 treeview
数据。
我现在已经通过 changed
信号做到了这一点:
self.view.get_selection().connect("changed", self.row_activated)
def row_activated(self, selection):
(model, iter) = selection.get_selected()
print(model[iter][:])
return True
但我无法使用 row-activated
:
self.view.connect("row-activated", self.row_activated)
def row_activated(self):
(model, iter) = self.view.get_selected()
print(model[iter][:])
return True
但是,这是错误的:
TypeError: row_activated() takes 1 positional argument but 4 were given
回答我自己的问题很奇怪,但我设法解决了它:
self.view.connect("row-activated", self.row_activated)
def row_activated(self, widget, row, col):
model = widget.get_model()
print(model[row][:])
return True