如何在IPython对话框中编写HTML?

时间:2018-09-13 09:49:08

标签: javascript python html ipython jupyter-notebook

如何在IPython对话框中将html编写为html(而不是HTML字符串)?

例如:我有一个显示对话框的Ipython UI扩展

require(
    ["base/js/dialog"], 
    function(dialog) {
        dialog.modal({
            title: 'Hello world',
            body: ?? ,
            buttons: {
                'schedule': {}
            }
        });
    }
);

现在在对话框的内部,我想显示以下HTML内容。

    <label>Quick Schedule</label><br />

    <a class="btn btn-primary" onclick="schedule = '@reboot'; job_string();">Startup</a>
    <a class="btn btn-primary" onclick="schedule = '@hourly'; job_string();">Hourly</a>
    <a class="btn btn-primary" onclick="schedule = '@daily'; job_string();">Daily</a>
    <a class="btn btn-primary" onclick="schedule = '@weekly'; job_string();">Weekly</a>
    <a class="btn btn-primary" onclick="schedule = '@monthly'; job_string();">Monthly</a>
    <a class="btn btn-primary" onclick="schedule = '@yearly'; job_string();">Yearly</a><br /><br />

    <div class="row">
        <div class="col-md-2">Minute</div>
        <div class="col-md-2">Hour</div>
        <div class="col-md-2">Day</div>
        <div class="col-md-2">Month</div>
        <div class="col-md-2">Week</div>
    </div>

    <div class="row">
        <div class="col-md-2"><input type="text" class="form-control" id="job-minute" value="*" onclick="this.select();"/></div>
        <div class="col-md-2"><input type="text" class="form-control" id="job-hour" value="*" onclick="this.select();"/></div>
        <div class="col-md-2"><input type="text" class="form-control" id="job-day" value="*" onclick="this.select();"/></div>
        <div class="col-md-2"><input type="text" class="form-control" id="job-month" value="*" onclick="this.select();"/></div>
        <div class="col-md-2"><input type="text" class="form-control" id="job-week" value="*" onclick="this.select();"/></div>
        <div class="col-md-2"><a class="btn btn-primary" onclick="set_schedule();">Set</a></div>
    </div>

如何显示此HTML内容?铅在这里真的很感激吗?

1 个答案:

答案 0 :(得分:0)

HTML String via jQuery append中引用答案

提示:为Jupyter Lab编写扩展名也支持编写Typescript。