【问题标题】:PyGTK - Retrieve / Save formatted text TextBuffer/Sqlite3PyGTK - 检索/保存格式化文本 TextBuffer/Sqlite3
【发布时间】:2012-08-25 10:12:13
【问题描述】:

我正在gtk.TextBuffer(跨越gtk.TextView)和Sqlite3 table 之间实现文本格式。 TextView 中的文本格式工作正常,我的问题是在Sqlite3 table(TEXT 类型字段)中保存和检索格式化文本。

基本上我将TextBuffer中的文本格式化如下:

class db(object):
   text_tag = 0

def format(self, constant): 
        if self.textbuffer.get_selection_bounds() != ():
            start, end = self.textbuffer.get_selection_bounds()
            self.textbuffer.apply_tag(constant, start, end)

def on_bold_btn_clicked(self, widget):
        db.text_tag = db.text_tag+1
        self.tt_bold = gtk.TextTag("bold_"+str(db.text_tag))
        self.tt_bold.set_property("weight", pango.WEIGHT_BOLD) 
        self.TextTagTable.add(self.tt_bold)

        self.format(self.tt_bold)

在表格中保存时间时,我检索格式如下的文本:

textbuffer.get_text (textbuffer.get_start_iter (), textbuffer.get_end_iter (), include_hidden_chars = True)

据我了解文档gtk.TextBuffer.get_text,如果 include_hidden_​​chars 为 False,带有标签的文本会被删除,所以当 True 时,文本会以正确的格式保存?

格式化文本显示对象是一个 TextView,它在运行时正确显示格式化文本,但显然,格式化完成后文本没有被保存/恢复。

有人知道我是否忘记了什么吗?

谢谢。

【问题讨论】:

    标签: python gtk pygtk


    【解决方案1】:
    猜你喜欢
    • 1970-01-01
    • 2011-06-22
    • 2018-11-20
    • 1970-01-01
    • 2021-11-21
    • 1970-01-01
    • 2020-04-22
    • 1970-01-01
    • 2013-06-19
    相关资源
    最近更新 更多