##// END OF EJS Templates
Merge pull request #3409 from pankajp/qt-console-freeze-on-output-clip...
Merge pull request #3409 from pankajp/qt-console-freeze-on-output-clip Prevent qtconsole frontend freeze on lots of output. The output from the kernel is now clipped to last buffer_size before displaying and a timer is used to flush the pending output text instead of attempting to display text on every stream output from kernel. The timer interval is adjusted based on actual time taken to append a screenful of text to widget. This throttles the widget repaints and avoids choking the Qt event loop leaving time to handle other Qt events.

File last commit:

r11439:5cbf0663
r11532:0397c02f merge
Show More
dialog.js
83 lines | 2.7 KiB | application/javascript | JavascriptLexer
//----------------------------------------------------------------------------
// Copyright (C) 2013 The IPython Development Team
//
// Distributed under the terms of the BSD License. The full license is in
// the file COPYING, distributed as part of this software.
//----------------------------------------------------------------------------
//============================================================================
// Utility for modal dialogs with bootstrap
//============================================================================
IPython.namespace('IPython.dialog');
IPython.dialog = (function (IPython) {
var modal = function (options) {
var dialog = $("<div/>").addClass("modal").attr("role", "dialog");
dialog.append(
$("<div/>")
.addClass("modal-header")
.append($("<button>")
.addClass("close")
.attr("data-dismiss", "modal")
.html("&times;")
).append(
$("<h3/>").text(options.title || "")
)
).append(
$("<div/>").addClass("modal-body").append(
options.body || $("<p/>")
)
);
var footer = $("<div/>").addClass("modal-footer");
for (var label in options.buttons) {
var btn_opts = options.buttons[label];
var button = $("<button/>")
.addClass("btn")
.attr("data-dismiss", "modal")
.text(label);
if (btn_opts.click) {
button.click($.proxy(btn_opts.click, dialog));
}
if (btn_opts.class) {
button.addClass(btn_opts.class);
}
footer.append(button);
}
dialog.append(footer);
// hook up on-open event
dialog.on("shown", function() {
setTimeout(function() {
footer.find("button").last().focus();
if (options.open) {
$.proxy(options.open, dialog)();
}
}, 0);
});
// destroy dialog on hide, unless explicitly asked not to
if (options.destroy == undefined || options.destroy) {
dialog.on("hidden", function () {
dialog.remove();
});
}
if (options.reselect_cell !== false) {
dialog.on("hidden", function () {
if (IPython.notebook) {
cell = IPython.notebook.get_selected_cell();
if (cell) cell.select();
}
});
}
return dialog.modal(options);
}
return {
modal : modal,
};
}(IPython));