def handle_tab_command(self, hummingbot: "HummingbotApplication", command_name: str, kwargs: Dict[str, Any]):
     if command_name not in self.command_tabs:
         return
     cmd_tab = self.command_tabs[command_name]
     if "close" in kwargs and kwargs["close"]:
         if cmd_tab.close_button is not None:
             self.close_buton_clicked(command_name)
         return
     if "close" in kwargs:
         kwargs.pop("close")
     if cmd_tab.button is None:
         cmd_tab.button = create_tab_button(command_name, lambda: self.tab_button_clicked(command_name))
         cmd_tab.close_button = create_tab_button("x", lambda: self.close_buton_clicked(command_name), 1, '', ' ')
         cmd_tab.output_field = create_live_field()
         cmd_tab.tab_index = max(t.tab_index for t in self.command_tabs.values()) + 1
     self.tab_button_clicked(command_name)
     self.display_tab_output(cmd_tab, hummingbot, kwargs)
Exemple #2
0
    def __init__(self, client_config_map: ClientConfigAdapter,
                 input_handler: Callable, bindings: KeyBindings,
                 completer: Completer, command_tabs: Dict[str, CommandTab]):
        super().__init__()
        self.client_config_map: Union[ClientConfigAdapter,
                                      ClientConfigMap] = client_config_map
        self.command_tabs = command_tabs
        self.search_field = create_search_field()
        self.input_field = create_input_field(completer=completer)
        self.output_field = create_output_field(client_config_map)
        self.log_field = create_log_field(self.search_field)
        self.right_pane_toggle = create_log_toggle(self.toggle_right_pane)
        self.live_field = create_live_field()
        self.log_field_button = create_tab_button("Log-pane",
                                                  self.log_button_clicked)
        self.timer = create_timer()
        self.process_usage = create_process_monitor()
        self.trade_monitor = create_trade_monitor()
        self.layout, self.layout_components = generate_layout(
            self.input_field, self.output_field, self.log_field,
            self.right_pane_toggle, self.log_field_button, self.search_field,
            self.timer, self.process_usage, self.trade_monitor,
            self.command_tabs)
        # add self.to_stop_config to know if cancel is triggered
        self.to_stop_config: bool = False

        self.live_updates = False
        self.bindings = bindings
        self.input_handler = input_handler
        self.input_field.accept_handler = self.accept
        self.app: Optional[Application] = None

        # settings
        self.prompt_text = ">>> "
        self.pending_input = None
        self.input_event = None
        self.hide_input = False

        # stdout redirection stack
        self._stdout_redirect_context: ExitStack = ExitStack()

        # start ui tasks
        loop = asyncio.get_event_loop()
        loop.create_task(start_timer(self.timer))
        loop.create_task(start_process_monitor(self.process_usage))
        loop.create_task(start_trade_monitor(self.trade_monitor))