Start PyGTK cellrenderer edit from code

与世无争的帅哥 提交于 2019-12-04 10:01:34

问题


I have a treeview with an editable CellRendererText:

self.renderer = gtk.CellRendererText()
self.renderer.set_property('editable', True)

But now I need to launch the edition from code instead from user, this is to focus the user attention in the fact he just created a new row and needs to be named. I tried this but does not work:

self.renderer.start_editing(
    gtk.gdk.Event(gtk.gdk.NOTHING),
    self.treeview,
    str(index),
    gtk.gdk.Rectangle(),
    gtk.gdk.Rectangle(),
    0)

Neither does not throw errors, but the documentation about for what is each argument is not clear, in fact I really don't know if start_editing method is for this.

All suggestions are welcome, thanks.


回答1:


def set_cursor(path, focus_column=None, start_editing=False)

... If column is specified, and start_editing is True, then editing should be started in the specified cell. This method is often followed by the gtk.Widget.grab_focus() method to give keyboard focus to the treeview.

Source



来源:https://stackoverflow.com/questions/2576481/start-pygtk-cellrenderer-edit-from-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!