Example #1
0
    def construct(self):
        window = Gtk.Window.new(Gtk.WindowType.TOPLEVEL)
        window.set_transient_for(self.main_window.window)
        window.set_title(self.title)

        console = GTKInterpreterConsole(
            locals={"service": self.component_registry.get_service}
        )
        console.show()
        window.add(console)
        window.show()

        self.window = window

        def key_event(widget, event):
            if (
                event.keyval == Gdk.KEY_d
                and event.get_state() & Gdk.ModifierType.CONTROL_MASK
            ):
                window.destroy()
            return False

        window.connect("key_press_event", key_event)

        window.connect("destroy", self.close)

        return console
Example #2
0
def test_history():
    console = GTKInterpreterConsole(locals={})
    console.history.append("my_history()")

    console.key_pressed(console, KeyEvent(Gdk.keyval_from_name("Up")))
    text = console_text(console)

    assert ">>> my_history()" in text
Example #3
0
def test_run_line():
    console = GTKInterpreterConsole(locals={})

    console.buffer.append("help")
    console.key_pressed(console, KeyEvent(Gdk.keyval_from_name("Return")))

    text = console_text(console)

    assert "Usage: help(object)" in text