Source

gtkarchitect-main / gtkarchitect / utils / debug.py

Full commit

import gtk

from lxml.etree import tostring

from ..view.base import Slave


def create_pida_console(**locals_ns):
    from .pyconsole import Console

    swin = gtk.ScrolledWindow()
    swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
    swin.add(Console(locals_ns,
                     banner="Architect internal shell",
                     use_rlcompleter=True,
                    ))
    swin.show_all()
    return swin


class DebugSlave(Slave):

    def __init__(self, mainview):
        self.set_main(mainview)
        Slave.__init__(self)


    def create_ui(self):
        t = self.get_toplevel()
        buttons = gtk.HBox()
        t.pack_start(buttons, expand=False)

        self.dump_button = gtk.Button('Dump')
        buttons.pack_start(self.dump_button, expand=False)

        console = create_pida_console(main=self.main)
        t.pack_start(console)

    def set_main(self, mainview):
        self.main = mainview

    def on_dump_button__clicked(self, button):
        p = self.main.project
        print p
        print tostring(p.tree)