micropi.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:Micro-Pi 作者: Bottersnike 项目源码 文件源码
def addNotebookPage(self, title, content, path):
        area = gtk.ScrolledWindow()
        area.set_policy(gtk.POLICY_ALWAYS, gtk.POLICY_ALWAYS)
        area.show()

        txtB = gtkSourceView.Buffer()
        txtB.begin_not_undoable_action()
        txtB.set_style_scheme(self.style_scheme)

        language = self.getLanguage(title)

        txtB.set_highlight_matching_brackets(True)
        if language is not None:
            txtB.set_highlight_syntax(True)
            txtB.set_language(language)

        txtB.set_text(content)
        txtB.place_cursor(txtB.get_start_iter())
        txtB.set_modified(False)
        txtB.end_not_undoable_action()

        text = SourceView(txtB)
        text.set_tab_width(self.tabWidth)
        text.set_insert_spaces_instead_of_tabs(False)
        text.set_show_right_margin(True)
        text.set_show_line_marks(True)
        text.set_auto_indent(self.autoIndent)
        text.set_show_line_numbers(self.lineNumbers)
        text.show()
        text.modify_font(pango.FontDescription('Monospace 10'))
        area.add(text)


        top = gtk.HBox()

        title = gtk.Label(title)
        title.show()
        top.set_tooltip_text(path)


        top.pack_start(title, True, True, 0)
        butt = gtk.Button()
        img = gtk.Image()
        img.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU)
        img.show()
        butt.set_image(img)
        butt.connect_object("clicked", self.closePage, area)
        top.pack_end(butt, False, False, 0)

        butt.show()
        top.show()

        self.notebook.insert_page(area, top, 0)

        pages = self.notebook.get_n_pages()
        self.notebook.set_current_page(0)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号