def __init__(self, questions):
     self.questions = questions
     self.qlabel = ipw.Label(value=self.prompt)
     self.question = ipw.Textarea()
     self.tags = ipw.Text(description="tags")
     self.qtbox = ipw.VBox([self.qlabel, self.question, self.tags])
     self.answer = ipw.RadioButtons(options=['T', 'F'])
     self.qbox = ipw.HBox([self.qtbox, self.answer])
     self.tfb = ipw.Textarea(description="True Feedback")
     self.ffb = ipw.Textarea(description="False Feedback")
     self.feedback = ipw.Tab()
     self.feedback.children = [self.tfb, self.ffb]
     self.commit = ipw.Button(description="commit")
     self.commit.on_click(self.commit_question)
     super(TFQuestion,
           self).__init__(children=[self.qbox, self.feedback, self.commit])
示例#2
0
文件: top10_w.py 项目: nysol/miningpy
    def widget(self):
        pbox = []

        # ファイル名とファイル内容
        self.iName_w = widgets.Text(description="入力ファイル",
                                    value="",
                                    layout=Layout(width='100%'),
                                    disabled=False)
        self.iText_w = widgets.Textarea(value="",
                                        rows=5,
                                        layout=Layout(width='100%'),
                                        disabled=True)
        pbox.append(self.iName_w)
        pbox.append(self.iText_w)
        self.oPath_w = widgets.Text(description="出力パス",
                                    value="",
                                    layout=Layout(width='100%'),
                                    disabled=False)
        pbox.append(self.oPath_w)
        self.oFile_w = widgets.Text(description="ファイル名",
                                    value="",
                                    layout=Layout(width='100%'),
                                    disabled=False)
        pbox.append(self.oFile_w)

        self.titles_w = widgets.Select(options=[],
                                       description="歌詞の選択",
                                       rows=10,
                                       layout=Layout(width='100%'))
        pbox.append(self.titles_w)

        box = widgets.VBox(pbox)
        return box
 def select_multiple_items(label, item_name):
     """ Select multiple items """
     label_item = widgets.Label(value=label)
     items = widgets.Textarea(value='', placeholder='One per line: \n 0x7ae3 \n 0x7ae6', description=item_name, disabled=False, rows=5)
     display(label_item)
     display(items)
     return items
示例#4
0
 def __initialise_errors__(self):
     if self.verbosity > 0:
         self.__error_label__ = ipywidgets.HTML(
             value="<span style='color: red'>Errors:</span>")
         self.__error_field__ = ipywidgets.Textarea(disabled=True)
         display(self.__error_label__)
         display(self.__error_field__)
示例#5
0
 def make_default_user_namespaces(self):
     user_namespaces = W.Textarea(
         placeholder="PREFIX ex: <https://www.example.org/>",
         layout=W.Layout(width="80%"),
     )
     T.link((user_namespaces, "value"), (self, "user_namespaces_value"))
     return user_namespaces
示例#6
0
def create_function_widget(data_handler, pipeline):
    create_function_button = widgets.Button(
        description='Create function',
        disabled=False,
        button_style='',  # 'success', 'info', 'warning', 'danger' or ''
        tooltip='Save function')
    function_name_input = widgets.Text(placeholder="Enter function name",
                                       description="Command: ",
                                       disabled=False)
    function_input = widgets.Textarea(
        value=
        '# Enter what the function has to execute. Use "self.data" to access to the data\n# self.data.set_index(["concept:instance"], inplace=True)\n'
        '# There is no definition needed aswell as no return. Directly start with functionality.',
        placeholder='What the function needs to do',
        description='Function: ',
        disabled=False,
        layout=widgets.Layout(width='600px', height='300px'))

    create_box = widgets.VBox(
        [function_name_input, function_input, create_function_button])

    display(create_box)

    # Helper function that gets called on clicking the button
    # Calls the backend functions to export as xes
    def on_create(b):
        pipeline.functions[function_name_input.value] = function_input.value
        data_handler.save_functions(pipeline.functions)
        print("Function saved as " + function_name_input.value)
        print(function_input.value)

    create_function_button.on_click(on_create)
    return
示例#7
0
    def __init__(self, config=Configuration(), *args, **kwargs):
        widgets.Button.__init__(self, *args, **kwargs)

        # Config
        self.config = config

        # Text box to write the motors
        self.text = widgets.Textarea(
            value='',
            placeholder='Example: IOC:m1 IOC:m3 LNLS:TEST:motor_g3',
            description='',
            disabled=False)

        # class Button values for MotorsMonitor
        self.description = 'Start Motor Monitoring'
        self.disabled = False
        self.button_style = 'success'
        self.tooltip = 'Click me'
        self.icon = ''
        self.layout = widgets.Layout(width='300px')

        # Boxes
        self.motors_values = {}

        # Motors
        self.motors_list = []

        # Set callback function for click event
        self.monitoring_status = False
        self.on_click(self._monitor_button)

        # Main widget
        self.main_box = widgets.VBox([self, self.text])
        self.output = widgets.Output()
示例#8
0
    def init_regress_ui(self):
        """线性拟合ui"""

        with self._init_tip_label_with_step_x(self._regress_analyse,
                                              u'线性拟合分析') as (widget_list,
                                                             step_x):
            self.regress_step_x = step_x
            self.regress_mode_description = widgets.Textarea(
                value=u'1. 技术线最少拟合次数:\n'
                u'检测至少多少次拟合曲线可以代表原始曲线y的走势,'
                u'通过度量始y值和均线y_roll_mean的距离和原始y值和拟合回归的趋势曲线y_fit的距离的方法,默认使用metrics_rmse\n'
                u'2. 技术线最优拟合次数:\n'
                u'寻找多少次多项式拟合回归的趋势曲线可以完美的代表原始曲线y的走势\n'
                u'3. 可视化技术线拟合曲线:\n'
                u'通过步长参数在子金融序列中进行走势拟合,形成拟合曲线及上下拟合通道曲线,返回三条拟合曲线,组成拟合通道',
                disabled=False,
                layout=self.description_layout)
            widget_list.append(self.regress_mode_description)
            self.regress_mode = widgets.RadioButtons(options={
                u'技术线最少拟合次数': 0,
                u'技术线最优拟合次数': 1,
                u'可视化技术线拟合曲线': 2
            },
                                                     value=0,
                                                     description=u'拟合模式:',
                                                     disabled=False)
            widget_list.append(self.regress_mode)
        return widgets.VBox(
            widget_list,
            # border='solid 1px',
            layout=self.tool_layout)
示例#9
0
def get_chat_window(my_nickname,socket_address):
    def handle_input(sender):
        context = zmq.Context()
        push_socket = context.socket(zmq.PUSH)
        push_socket.connect(socket_address)

        push_socket.send_json({'plain_message':{'nickname':my_nickname,'message':sender.value}})
        sender.value = ''

    console_container = widgets.VBox(visible=False)
    console_container.padding = '10px'

    output_box = widgets.Textarea()
    output_box.height = '400px'
    output_box.font_family = 'monospace'
    output_box.color = '#AAAAAA'
    output_box.background_color = 'black'
    output_box.width = '600px'

    input_box = widgets.Text()
    input_box.font_family = 'monospace'
    input_box.color = '#AAAAAA'
    input_box.background_color = 'black'
    input_box.width = '800px'

    console_container.children = [output_box, input_box]
    console_container.visible = True

    input_box.on_submit(handle_input)
    return output_box,console_container
示例#10
0
    def widget(self):
        # ボタン系
        self.sizek_w = widgets.Text(value="15",
                                    layout=widgets.Layout(width='40px'))
        shuffle_w = widgets.Button(description='シャッフル', disabled=False)
        shuffle_w.on_click(self.randomSelect_h)

        self.from_w = widgets.Text(value="0",
                                   layout=widgets.Layout(width='40px'))
        range_w = widgets.Button(description='範囲選択', disabled=False)
        range_w.on_click(self.rangeSelect_h)
        buttons = widgets.HBox([self.sizek_w, shuffle_w, self.from_w, range_w])

        # メッセージ窓
        self.out_w = widgets.Text(value="",
                                  layout=widgets.Layout(width='100%'),
                                  disabled=True)

        # サンプル一覧と内容
        self.sampleSel_w = widgets.SelectMultiple(
            options=[],
            rows=14,
            disabled=False,
            layout=widgets.Layout(width='70%'))
        self.sampleSel_w.observe(self.summary_h, names='value')  # HANDLER
        self.summary_w = widgets.Textarea(value="",
                                          rows=10,
                                          disabled=True,
                                          layout=widgets.Layout(width='100%'))
        sampleBox = widgets.HBox([self.sampleSel_w, self.summary_w])

        box = widgets.VBox([self.out_w, buttons, sampleBox])
        return box
示例#11
0
def onclick_pixval(d, name=None, d_axes=None):
    def onclick(event):
        inaxes = event.inaxes
        if d_axes:
            name = d_axes[inaxes]
        x, y = event.xdata, event.ydata
        idx = get_idx_from_xy(d, x, y)
        if idx != None:
            val = d[name][idx]
            txt.value = '(x,y,{0:})=({1:.4g}, {2:.4g}, {3:.4g})'.format(
                name, x, y, val)
        else:
            txt.value = 'NULL'

    txt = wdg.Textarea(value='',
                       layout={
                           'width': '100%',
                           'height': '40px'
                       },
                       placeholder='',
                       description='Val:',
                       disabled=True)
    display(txt)

    return onclick
示例#12
0
    def _init_widget(self):
        """构建AbuFactorCloseAtrNStop策略参数界面"""
        self.description = widgets.Textarea(
            value=u'利润保护止盈策略:\n'
            u'1. 买入后最大收益价格 - 今日价格 > 一定收益\n'
            u'2. 买入后最大收益价格 - 今日价格 < close_atr_n * 当日atr\n'
            u'3. 当买入有一定收益后,如果下跌幅度超过close_atr_n乘以当日atr->保护止盈卖出',
            description=u'保护止盈',
            disabled=False,
            layout=self.description_layout)

        self.close_atr_n_label = widgets.Label(
            u'收益下跌超过close_atr_n乘以当日atr->保护止盈', layout=self.label_layout)
        self.close_atr_n = widgets.FloatSlider(
            value=1.5,
            min=0.10,
            max=10.0,
            step=0.1,
            description='close_atr_n',
            disabled=False,
            orientation='horizontal',
            readout=True,
            readout_format='.1f',
        )
        self.close_atr_n_box = widgets.VBox(
            [self.close_atr_n_label, self.close_atr_n])
        self.widget = widgets.VBox(
            [self.description, self.close_atr_n_box, self.add_box
             ],  # border='solid 1px',
            layout=self.widget_layout)
示例#13
0
    def _init_manager_ui(self):
        """裁判数据管理界面初始化"""
        description = widgets.Textarea(value=u'删除选择的裁判本地数据:\n'
                                       u'删除所选择的已训练好的本地裁判数据,谨慎操作!\n'
                                       u'分享选择的裁判:\n'
                                       u'将训练好的裁判数据分享到交易社区,供其他交易者使用\n'
                                       u'下载更多的裁判:\n'
                                       u'从交易社区,下载更多训练好的裁判数据\n',
                                       disabled=False,
                                       layout=widgets.Layout(height='150px'))

        self.manager_umps = widgets.Select(options=[],
                                           description=u'本地裁判:',
                                           disabled=False,
                                           layout=widgets.Layout(
                                               width='100%',
                                               align_items='stretch'))
        self.load_train_ump(self.manager_umps)
        delete_bt = widgets.Button(description=u'删除选择的裁判本地数据',
                                   layout=widgets.Layout(width='98%'),
                                   button_style='warning')
        delete_bt.on_click(self._do_delete_ump)

        share_bt = widgets.Button(description=u'分享选择的裁判',
                                  layout=widgets.Layout(width='98%'),
                                  button_style='info')
        share_bt.on_click(permission_denied)
        down_bt = widgets.Button(description=u'下载更多的裁判',
                                 layout=widgets.Layout(width='98%'),
                                 button_style='info')
        down_bt.on_click(permission_denied)

        return widgets.VBox(
            [description, self.manager_umps, delete_bt, share_bt, down_bt])
示例#14
0
    def _init_train_ui(self):
        """裁判特征训练面初始化"""
        description = widgets.Textarea(
            value=u'裁判特征训练:\n'
            u'通过在\'裁判特征采集\'选中\'回测过程生成交易特征\'可在回测完成后保存当此回测结果\n'
            u'所有回测的结果将显示在下面的\'备选回测:\'框中\n'
            u'通过\'开始训练裁判\'进行指定的回测裁判训练,训练后的裁判在\'裁判预测拦截\'下可进行选择,选中的裁判将在对应的'
            u'回测中生效,即开始在回测中对交易进行预测拦截等智能交易干涉行为',
            disabled=False,
            layout=widgets.Layout(height='150px'))

        self.abu_result = widgets.Select(options=[],
                                         description=u'备选回测:',
                                         disabled=False,
                                         layout=widgets.Layout(
                                             width='100%',
                                             align_items='stretch'))
        self.load_abu_result()

        train_bt = widgets.Button(description=u'开始训练裁判',
                                  layout=widgets.Layout(width='98%'),
                                  button_style='info')
        train_bt.on_click(self._do_train)
        delete_bt = widgets.Button(description=u'删除选择的备选回测本地数据',
                                   layout=widgets.Layout(width='98%'),
                                   button_style='warning')
        delete_bt.on_click(self._do_delete_abu_result)

        return widgets.VBox(
            [description, self.abu_result, train_bt, delete_bt])
示例#15
0
    def _init_widget(self):
        """构建AbuPickStockNTop策略参数界面"""
        self.description = widgets.Textarea(
            value=u'涨跌幅top N选股因子策略:\n'
                  u'选股周期上对多只股票涨跌幅进行排序,选取top n个股票做为交易目标:\n'
                  u'(只对在股池中选定的symbol序列生效,对全市场回测暂时不生效)\n',
            description=u'top N涨跌',
            disabled=False,
            layout=self.description_layout
        )

        n_top_label = widgets.Label(u'设定选取top个交易目标数量,默认3', layout=self.label_layout)
        self.n_top = widgets.IntText(
            value=3,
            description=u'TOP N',
            disabled=False
        )
        self.n_top_box = widgets.VBox([n_top_label, self.n_top])

        direction_top_label1 = widgets.Label(u'direction_top参数的意义为选取方向:', layout=self.label_layout)
        direction_top_label2 = widgets.Label(u'默认值为正:即选取涨幅最高的n_top个股票', layout=self.label_layout)
        direction_top_label3 = widgets.Label(u'可设置为负:即选取跌幅最高的n_top个股票', layout=self.label_layout)
        self.direction_top = widgets.Dropdown(
            options={u'正(涨幅)': 1, u'负(跌幅)': -1},
            value=1,
            description=u'选取方向:',
        )
        self.direction_top_box = widgets.VBox([direction_top_label1, direction_top_label2, direction_top_label3,
                                               self.direction_top])

        self.widget = widgets.VBox([self.description, self.n_top_box, self.direction_top_box,
                                    self.xd_box, self.reversed_box, self.add_box],
                                   # border='solid 1px',
                                   layout=self.widget_layout)
示例#16
0
 def _widgets(self):
     self.file_selector = HTML(
         '<input type="file" id="selectedFile" style="display: none; " /> \
                         <input type="button" value="Search Input Path ..." \
                         onclick="document.getElementById(\'selectedFile\').click();" />'
     )
     self.input_path_widget = widgets.Text(
         value='',
         placeholder='Input Path...',
         description='Input Path:',
         disabled=False,
         layout=widgets.Layout(width='100%'))
     self.input_path_button = widgets.Button(
         description='Run via OpenCV!',
         disabled=False,
         button_style='success',
         tooltip='Start to define the barriers.',
         icon='',
         layout=widgets.Layout(width='30%', height='40px'))
     self.print_barrier_results_text = widgets.Textarea(
         value='',
         placeholder='Barrier Info Results',
         description='Status:',
         disabled=False,
         layout=widgets.Layout(width='90%', height='120px'))
示例#17
0
def TextAreaSubmit(submit_func=print, default_text=''):
    ''' displays a text area and a submit button for
        evalutating 'submit_func' on the given text
    '''

    text_layout = widgets.Layout(height='150px')

    text_area = widgets.Textarea(value=default_text, layout=text_layout)

    submit_button = widgets.Button(
        description='Submit',
        disabled=False,
        button_style='',  # 'success', 'info', 'warning', 'danger' or ''
        tooltip='Submit'
    )

    box_layout = widgets.Layout(display='flex',
                                flex_flow='column',
                                align_items='stretch',
                                width='100%')

    box = widgets.Box(children=[text_area, submit_button], layout=box_layout)

    display(box)

    def _submit_function(b):
        submit_func(text_area.value)

    submit_button.on_click(_submit_function)
示例#18
0
    def _init_widget(self):
        """构建AbuFactorSellNDay策略参数界面"""
        self.description = widgets.Textarea(value=u'持有N天后卖出策略:\n'
                                            u'卖出策略,不管交易现在什么结果,买入后只持有N天\n'
                                            u'需要与特定\'买入策略\'形成配合\n,'
                                            u'单独使用N天卖出策略意义不大',
                                            description=u'N天卖出',
                                            disabled=False,
                                            layout=self.description_layout)
        sell_n_label = widgets.Label(u'设定买入后只持有天数,默认1',
                                     layout=self.label_layout)
        self.sell_n = widgets.IntText(value=1,
                                      description=u'N天',
                                      disabled=False)
        sell_n_box = widgets.VBox([sell_n_label, self.sell_n])

        is_sell_today_label = widgets.Label(u'设定买入n天后,当天还是隔天卖出',
                                            layout=self.label_layout)
        self.is_sell_today = widgets.Dropdown(
            options={
                u'N天后隔天卖出': False,
                u'N天后当天卖出': True
            },
            value=False,
            description=u'当天隔天:',
        )
        is_sell_today_box = widgets.VBox(
            [is_sell_today_label, self.is_sell_today])

        self.widget = widgets.VBox(
            [self.description, sell_n_box, is_sell_today_box, self.add_box],
            # border='solid 1px',
            layout=self.widget_layout)
示例#19
0
    def _init_widget(self):
        """构建AbuFactorPreAtrNStop策略参数界面"""
        self.description = widgets.Textarea(
            value=u'风险控制止损策略:\n'
            u'1. 单日最大跌幅n倍atr止损\n'
            u'2. 当今日价格下跌幅度 > 当日atr 乘以 pre_atr_n(下跌止损倍数)卖出操作',
            description=u'风险止损',
            disabled=False,
            layout=self.description_layout)

        self.pre_atr_n_label = widgets.Label(u'当今天价格开始剧烈下跌,采取果断平仓措施',
                                             layout=self.label_layout)
        self.pre_atr_n = widgets.FloatSlider(
            value=1.5,
            min=0.10,
            max=10.0,
            step=0.1,
            description='pre_atr_n',
            disabled=False,
            orientation='horizontal',
            readout=True,
            readout_format='.1f',
        )
        self.pre_atr_n_box = widgets.VBox(
            [self.pre_atr_n_label, self.pre_atr_n])
        self.widget = widgets.VBox(
            [self.description, self.pre_atr_n_box, self.add_box
             ],  # border='solid 1px',
            layout=self.widget_layout)
示例#20
0
    def __init__(self, name, default_value="", title="", height="300px"):
        self.header = w.HTML(value="<h3>{}:</h3>".format(title),
                             layout=w.Layout(width="40%", height="50px"))
        self.code = w.Textarea(value=default_value,
                               description="",
                               layout=w.Layout(width="70%", height=height))
        self.button_reset = w.Button(description="Reset default")
        self.button_load = w.Button(description="Load", disabled=True)
        self.path = w.Text(description="file",
                           placeholder="Path to a python file",
                           value="")

        def check_file(path):
            if os.path.isfile(path) and path[-3:] == ".py":
                self.button_load.disabled = False
                self.button_load.button_style = "success"
            else:
                self.button_load.disabled = True
                self.button_load.button_style = ""

        def load_file(button):
            with open(self.path.value, "rb") as code_file:
                self.code.value = code_file.read()

        w.interactive(check_file, path=self.path)
        self.button_load.on_click(load_file)

        def reset_code(button):
            self.code.value = default_initialization_code

        self.button_reset.on_click(reset_code)
示例#21
0
    def widget(self):
        # ボタン系
        submit_w = widgets.Button(description="登録")
        submit_w.on_click(self.submit_h)

        lb0 = widgets.Label(value="cID: %s" % self.data.id)
        lb1 = widgets.Label(value="タイトル:")
        title_w = widgets.Text(value="", layout=Layout(width='80%'))
        title_w.observe(self.submit_h, names='value')  # HANDLER

        lb2 = widgets.Label(value="詳細内容:")
        self.descriptionTxt = widgets.Textarea(rows=5,
                                               layout=Layout(width='90%'))

        lb3 = widgets.Label(value="サンプル:")
        config = {"db": self.data.sampleDB, "message": self.sampleList_m}
        sl = SampleList_w(config)

        description_w = widgets.Select(options=[],
                                       rows=10,
                                       disable=True,
                                       layout=Layout(width='90%'))
        del_w = widgets.Button(description="このクラスタを削除")
        box = widgets.VBox([
            lb0, submit_w, lb1, title_w, lb2, descriptionTxt, lb3, description,
            del_w
        ])
        return box
示例#22
0
    def stylingTab(self):
        self.grid_button_widget = widgets.ToggleButton(value=True,
                                                       description='Grid',
                                                       icon='check')
        self.color_buttons_widget = widgets.ToggleButtons(
            options=['blue', 'red', 'green'],
            description='Color:',
        )
        self.xlim_min_widget = widgets.widgets.FloatText(
            value=-4.0, description='min xlim:', disabled=False)
        self.xlim_max_widget = widgets.widgets.FloatText(
            value=4.0, description='max xlim:', disabled=False)
        self.ylim_min_widget = widgets.widgets.FloatText(
            value=-0.5, description='min ylim:', disabled=False)
        self.ylim_max_widget = widgets.widgets.FloatText(
            value=1.25, description='max ylim:', disabled=False)
        self.disable_axislim_widget = widgets.ToggleButton(
            value=True, description='axislim', icon='check')
        self.xaxis_label_widget = widgets.Textarea(value='x',
                                                   description='x-axis label:',
                                                   disabled=False)
        self.yaxis_label_widget = widgets.Textarea(value='y',
                                                   description='y-axis label:',
                                                   disabled=False)
        self.styleTab= \
            VBox(children=[
                HBox(children=[
                   self.xaxis_label_widget,
                   self.yaxis_label_widget
                ]),
                HBox(children=[
                    self.color_buttons_widget]),
                HBox(children=[
                    self.xlim_min_widget,
                    self.xlim_max_widget
                ]),
                HBox(children=[
                    self.ylim_min_widget,
                    self.ylim_max_widget
                ]),
                HBox(children=[
                    self.disable_axislim_widget,
                    self.grid_button_widget
                ])

            ])
        self.tabs.append(self.styleTab)
示例#23
0
    def _init_widget(self):
        """构建AbuFactorBuyWD策略参数界面"""

        self.description = widgets.Textarea(
            value=u'日胜率均值回复策略:\n'
            u'1. 默认以40天为周期(8周)结合涨跌阀值计算周几适合买入\n'
            u'2. 回测运行中每一月重新计算一次上述的周几适合买入\n'
            u'3. 在策略日任务中买入信号为:昨天下跌,今天开盘也下跌,且明天是计算出来的上涨概率大的\'周几\'',
            description=u'周涨胜率',
            disabled=False,
            layout=self.description_layout)

        self.buy_dw_label = widgets.Label(u'代表周期胜率阀值,默认0.55即55%的胜率',
                                          layout=self.label_layout)
        self.buy_dw = widgets.FloatSlider(
            value=0.55,
            min=0.50,
            max=0.99,
            step=0.01,
            description=u'胜率',
            disabled=False,
            orientation='horizontal',
            readout=True,
            readout_format='.2f',
        )
        self.buy_dw_box = widgets.VBox([self.buy_dw_label, self.buy_dw])

        self.buy_dwm_label = widgets.Label(u'代表涨幅比例阀值系数,默认0.618',
                                           layout=self.label_layout)
        self.buy_dwm = widgets.FloatSlider(value=0.618,
                                           min=0.50,
                                           max=1.0,
                                           step=0.01,
                                           description=u'系数',
                                           disabled=False,
                                           orientation='horizontal',
                                           readout=True,
                                           readout_format='.3f')
        self.buy_dwm_box = widgets.VBox([self.buy_dwm_label, self.buy_dwm])

        self.dw_period_label = widgets.Label(u'代表分所使用的交易周期,默认40天周期(8周)',
                                             layout=self.label_layout)
        self.dw_period = widgets.IntSlider(value=40,
                                           min=20,
                                           max=120,
                                           step=1,
                                           description=u'周期',
                                           disabled=False,
                                           orientation='horizontal',
                                           readout=True,
                                           readout_format='d')
        self.dw_period_box = widgets.VBox(
            [self.dw_period_label, self.dw_period])
        self.widget = widgets.VBox(
            [
                self.description, self.buy_dw_box, self.buy_dwm_box,
                self.dw_period_box, self.add
            ],  # border='solid 1px',
            layout=self.widget_layout)
示例#24
0
def make_text_large(value, description, placeholder, layout=None,
                    disabled=False, continuous_update=True):

    widg = widgets.Textarea(value=value, placeholder=placeholder, disabled=disabled,
                            description=description, continuous_update=continuous_update,
                            layout=layout)

    return widg
示例#25
0
 def __init__(self, level=logging.DEBUG):
     self.stream = StringIO()
     super(TextareaLogHandler, self).__init__(self.stream)
     self.widget = widgets.Textarea(
         layout=widgets.Layout(width='100%', height='500px'))
     self.setFormatter(logging.Formatter(self.log_format, self.time_format))
     self.setLevel(level)
     self.last_time = None
示例#26
0
def show_question(questionText, rows=1):
    css = ipywidgets.HTML('<style>.widget-label{white-space:normal;'
                          ' overflow:auto}</style>')
    layout = ipywidgets.Layout(width='95%', height='100%')
    label = ipywidgets.Label(questionText, layout=layout)
    answer = ipywidgets.Textarea(rows=rows, layout=layout)
    box = ipywidgets.VBox(children=[css, label, answer])
    display(box)
示例#27
0
    def __init__(self,
                 file: Optional[str] = None,
                 settings: Optional[Dict[str, Any]] = None):
        """
        Create an instance of the MSTICPy Configuration helper class.

        Parameters
        ----------
        file : Optional[str], optional
            config file to load, by default None
        settings : Optional[Dict[str, Any]], optional
            setting dict to load, by default None

        """
        self.settings = settings or {}
        self.kv_client: Optional[BHKeyVaultClient] = None
        self.mp_config_def_path = os.environ.get("MSTICPYCONFIG", "")
        self._current_file = None

        # Set up controls
        self.file_browser = FileBrowser(select_cb=self.load_from_file)
        self.txt_viewer = widgets.Textarea(
            layout=widgets.Layout(width="99%", height="300px"))
        self.btn_close = widgets.Button(description="Close")
        self.btn_close.on_click(self._close_view)

        self.html_title = widgets.HTML("<h3>MSTICPy settings</h3>")
        self.txt_current_file = widgets.Text(description="Current file",
                                             **_TXT_STYLE)
        self.txt_current_file.value = self.current_file or ""
        self.txt_current_file.observe(self._update_curr_file, "value")
        self.txt_curr_mpconfig = widgets.Text(
            description="Value of MSTICPCONFIG", **_TXT_STYLE)
        self.txt_curr_mpconfig.value = self.mp_config_def_path
        self.txt_curr_mpconfig.disabled = True

        self.buttons: Dict[str, widgets.Button] = {}
        self.btn_pane = self._setup_buttons()
        self.info_pane = widgets.VBox(
            [
                self.txt_current_file,
                self.txt_curr_mpconfig,
            ],
            layout=self.border_layout("60%"),
        )
        self.viewer = widgets.VBox([])
        self.layout = widgets.VBox(
            [
                self.html_title,
                widgets.HBox([self.info_pane, self.btn_pane]),
                self.viewer,
            ],
            layout=self.border_layout("99%"),
        )

        self.current_file = file
        if file and Path(file).is_file():
            self.load_from_file(file)
示例#28
0
def create_gif():
    """This function allows the user to select all the parameters to create their own GIFs.
    It saves them directly on their /work directory
    """

    lonmax = widgets.FloatText(value=1.5153795, description='Long max:', disabled=False, step=0.001)
    latmax = widgets.FloatText(value=43.668708, description='Lat max:', disabled=False, step=0.001)
    lonmin = widgets.FloatText(value=1.3503956, description='Long min:', disabled=False, step=0.001)
    latmin = widgets.FloatText(value=43.532654, description='Lat min:', disabled=False, step=0.001)

    bbox_menu = widgets.VBox([lonmax, latmax, lonmin, latmin])

    raw_bbox_menu = widgets.Textarea(
        value='1.5153795,43.668708,1.3503956,43.532654',
        placeholder='BBOX',
        disabled=False,
        layout=widgets.Layout(width='50%')
    )

    cities_menu = widgets.Text(placeholder='Ex: Toulouse, Paris, New-York...')

    children = [bbox_menu,
                widgets.VBox([
                    widgets.Label(value="Enter a city:"),
                    cities_menu
                ]),
                widgets.VBox([
                    widgets.Label(value="Enter a raw BBOX:"),
                    raw_bbox_menu
                ])]

    tab = widgets.Tab()
    tab.children = children
    tab.set_title(0, 'Bounding Box')
    tab.set_title(1, 'Cities')
    tab.set_title(2, 'Raw Bounding Box')

    global_output = widgets.Output()
    out = widgets.Output()
    button = widgets.Button(description='Validate')

    display(tab)
    display(button)
    display(out)
    display(global_output)

    bbox = [1.5153795, 43.668708, 1.3503956, 43.532654]  # default bbox on Toulouse

    # Defines the action when the button is clicked.
    # Here the button validates the bbox, and call the next widget (collection_widget)
    def click_bbox(b):
        global bbox
        bbox = get_bbox(tab, out, lonmax, latmax, lonmin, latmin, cities_menu, raw_bbox_menu)
        with global_output:
            clear_output(wait=True)
            get_collection(bbox)

    button.on_click(click_bbox)
示例#29
0
    def __init__(self):
        """Set up all widget GUI elements and class attributes."""
        self.error_output = None
        self.interact_current_index = 0
        self.interact_max_index = 0
        self.subsys_list = []
        self.interact_list = [self.empty_interaction_term()]

        label = ipywidgets.Label(value='HilbertSpace subsys_list')
        self.subsys_widget = ipywidgets.Textarea(
            placeholder='object name 1\nobject name 2\n...\n(existing  objects)'
        )
        self.subsys_box = ipywidgets.VBox([label, self.subsys_widget])

        self.interact_new_button = ipywidgets.Button(
            description='New', layout=ipywidgets.Layout(width='80px'))
        self.interact_del_button = ipywidgets.Button(
            icon='fa-remove', layout=ipywidgets.Layout(width='30px'))
        self.interact_right_button = ipywidgets.Button(
            icon='arrow-right', layout=ipywidgets.Layout(width='30px'))
        self.interact_left_button = ipywidgets.Button(
            icon='arrow-left', layout=ipywidgets.Layout(width='30px'))
        self.interact_buttons = ipywidgets.HBox([
            self.interact_new_button, self.interact_left_button,
            self.interact_right_button, self.interact_del_button
        ])

        self.op1_widget = ipywidgets.Text(
            description='op1', placeholder='e.g., <object>.n_operator()')
        self.op2_widget = ipywidgets.Text(
            description='op2',
            placeholder='e.g., <object>.creation_operator()')
        self.op1subsys_widget = ipywidgets.Text(description='subsys1')
        self.op2subsys_widget = ipywidgets.Text(description='subsys2')
        self.g_widget = ipywidgets.FloatText(description='g_strength')
        self.addhc_widget = ipywidgets.Dropdown(description='add_hc',
                                                options=['False', 'True'])

        self.interact_box = ipywidgets.VBox([
            self.interact_buttons, self.op1subsys_widget, self.op1_widget,
            self.op2subsys_widget, self.op2_widget, self.g_widget,
            self.addhc_widget
        ])

        self.interact_new_button.on_click(self.new_interaction_term)
        self.interact_del_button.on_click(self.del_interaction_term)
        self.interact_left_button.on_click(self.previous_interaction_term)
        self.interact_right_button.on_click(self.next_interaction_term)

        self.tab_nest = ipywidgets.widgets.Tab()
        self.tab_nest.children = [self.subsys_box, self.interact_box]
        self.tab_nest.set_title(0, 'Subsystems')
        self.tab_nest.set_title(1, 'Interactions')

        # run button is connected externally, see use in create_hilbertspace_widget below
        self.run_button = ipywidgets.Button(description='Finish')

        self.ui = ipywidgets.VBox([self.tab_nest, self.run_button])
示例#30
0
def define_GUI(i,n,region,fig,axis):

    # define interactivity
    button = dict()
    button['next orbit'] = widgets.Button(description="next orbit")
    button['prev orbit'] = widgets.Button(description="prev orbit")

    button['next bound'] = widgets.Button(description="next bound")
    button['prev bound'] = widgets.Button(description="prev bound")

    button['del bound'] = widgets.Button(description="del bound")

    button['next orbit'].on_click(lambda event : next_orbit(event, i, n, region) )
    button['prev orbit'].on_click(lambda event : prev_orbit(event, i, n, region) )

    button['next bound'].on_click(lambda event : next_bound(event, i, n, fig) )
    button['prev bound'].on_click(lambda event : prev_bound(event, i, n, fig) )

    comment = list()
    comment.append( widgets.Text(value='',placeholder='update comment',description='',disabled=False) )


    try:
        value = region.get_value(n.get_mapping(), 'comment')
        comment.append( widgets.Textarea(value=value,placeholder='no comment',description='',disabled=True) )
    except:
        comment.append( widgets.Textarea(value='',placeholder='no comment',description='',disabled=True) )

    def callback(_, comment, region, n):

        region.add(n.get_mapping(),'comment',comment[0].value)

        comment[1].value = comment[0].value
        comment[0].value = ''


    comment[0].on_submit(lambda event : callback(event, comment, region, n))

    display(widgets.VBox([
        widgets.HBox([button['prev orbit'], button['next orbit']]),

        widgets.HBox([button['prev bound'], button['next bound']]),
        
        comment[0], comment[1]
    ]))