Hyperlink CellRenderText标记中的超链接
我想在pygtk表格中显示超链接:Hyperlink CellRenderText标记中的超链接,hyperlink,pygtk,Hyperlink,Pygtk,我想在pygtk表格中显示超链接: cr=gtk.CellRendererText() column=gtk.TreeViewColumn(name) column.add_attribute(cr, "markup", 0) my_liststore=['<a href="http://google.com/">google</a>', ...] 如何在pygtk表中显示超链接?当然,如果你点击它,它会打开浏览器 更新 问了这个问题几个月后:以下是我的个人建议:不要
cr=gtk.CellRendererText()
column=gtk.TreeViewColumn(name)
column.add_attribute(cr, "markup", 0)
my_liststore=['<a href="http://google.com/">google</a>', ...]
如何在pygtk表中显示超链接?当然,如果你点击它,它会打开浏览器
更新
问了这个问题几个月后:以下是我的个人建议:不要使用gtk。这是一匹死马。我不知道Qt是否更好。要走的路是网络技术。以下是我现在使用的几行。单元格将以蓝色渲染并加下划线。双击事件使用webbrowser模块调用回调
table = gtk.TreeView(list_store)
cr = gtk.CellRendererText()
# allow pango markup
column.add_attribute(cr, "markup", i)
# connect double click handler:
self.timeline.connect('row-activated', self.on_treeview_click)
# content in the data rows:
u'<span foreground="blue" underline="single">%s</span>' % (
glib.markup_escape_text(name))
table = gtk.TreeView(list_store)
cr = gtk.CellRendererText()
# allow pango markup
column.add_attribute(cr, "markup", i)
# connect double click handler:
self.timeline.connect('row-activated', self.on_treeview_click)
# content in the data rows:
u'<span foreground="blue" underline="single">%s</span>' % (
glib.markup_escape_text(name))
def on_treeview_click(self, treeview, path, view_column):
model=treeview.get_model()
action_id=model[path][0]
url='....' # build your url
import webbrowser
webbrowser.open(url)