def on_toplevel_response(self, msg): if not self.winfo_ismapped(): return if get_runner().get_backend_proxy().supports_remote_files(): # pass cwd, as proxy may not yet know it self.check_update_focus(msg.get("cwd"))
def request_dirs_child_data(self, node_id, paths): if get_runner(): get_runner().send_command( InlineCommand("get_dirs_children_info", node_id=node_id, paths=paths) )
def make_remote_path(target_path): return get_runner().get_node_label() + REMOTE_PATH_MARKER + target_path
def perform_mkdir(self, parent_dir, name): get_runner().send_command_and_wait( InlineCommand("mkdir", path=parent_dir + self.get_dir_separator() + name), dialog_title=tr("Creating directory"), )
def cmd_refresh_tree(self): if not get_runner().ready_for_remote_file_operations(show_message=True): return super().cmd_refresh_tree()
def _run_or_resume(): state = get_runner().get_state() if state == "waiting_debugger_command": _issue_debugger_command("resume") elif state == "waiting_toplevel_command": get_runner().cmd_run_current_script()
def ready_for_remote_file_operations(self): return self._proc is not None and get_runner( ).is_waiting_toplevel_command()
def __init__(self, master, kind, initial_dir): super().__init__(master=master) self.result = None self.updating_selection = False self.kind = kind if kind == "open": self.title(tr("Open from %s") % get_runner().get_node_label()) else: assert kind == "save" self.title(tr("Save to %s") % get_runner().get_node_label()) background = ttk.Frame(self) background.grid(row=0, column=0, sticky="nsew") self.columnconfigure(0, weight=1) self.rowconfigure(0, weight=1) self.browser = DialogRemoteFileBrowser(background, self) self.browser.grid(row=0, column=0, columnspan=4, sticky="nsew", pady=20, padx=20) self.browser.configure(borderwidth=1, relief="groove") self.browser.tree.configure(selectmode="browse") self.name_label = ttk.Label(background, text=tr("File name:")) self.name_label.grid(row=1, column=0, pady=(0, 20), padx=20, sticky="w") self.name_var = create_string_var("") self.name_entry = ttk.Entry( background, textvariable=self.name_var, state="normal" if kind == "save" else "disabled") self.name_entry.grid(row=1, column=1, pady=(0, 20), padx=(0, 20), sticky="we") self.name_entry.bind("<KeyRelease>", self.on_name_edit, True) self.ok_button = ttk.Button(background, text=tr("OK"), command=self.on_ok) self.ok_button.grid(row=1, column=2, pady=(0, 20), padx=(0, 20), sticky="e") self.cancel_button = ttk.Button(background, text=tr("Cancel"), command=self.on_cancel) self.cancel_button.grid(row=1, column=3, pady=(0, 20), padx=(0, 20), sticky="e") background.rowconfigure(0, weight=1) background.columnconfigure(1, weight=1) self.bind("<Escape>", self.on_cancel, True) self.bind("<Return>", self.on_ok, True) self.protocol("WM_DELETE_WINDOW", self.on_cancel) self.tree_select_handler_id = self.browser.tree.bind( "<<TreeviewSelect>>", self.on_tree_select, True) self.browser.request_focus_into(initial_dir) self.name_entry.focus_set()
def cancel_work(self): super(InlineCommandDialog, self).cancel_work() get_runner()._cmd_interrupt()
def _loop_gui_update(self, force=False): if force or get_runner().is_waiting_toplevel_command(): self.send_command(InlineCommand("process_gui_events")) self._gui_update_loop_id = get_workbench().after(50, self._loop_gui_update)
def _delete_paths(self, paths): get_runner().send_command_and_wait( InlineCommand("delete", paths=paths), dialog_title=tr("Deleting"), )
def check_update_focus(self): proxy = get_runner().get_backend_proxy() if self.current_focus != proxy.get_cwd(): self.focus_into(proxy.get_cwd())
def on_toplevel_response(self, event): if get_runner().get_backend_proxy().supports_remote_files(): self.check_update_focus()
def on_remote_files_changed(self, event=None): if not self.winfo_ismapped(): return if get_runner().get_backend_proxy().supports_remote_files(): self.refresh_tree()
def ready_for_remote_file_operations(self): return self.is_connected() and get_runner().is_waiting_toplevel_command()
def open_backend_pip_gui_enabled(): return "pip_gui" in get_runner().get_supported_features()
def _start_debug_enabled(): return (_current_debugger is None and get_workbench().get_editor_notebook().get_current_editor() is not None and "debug" in get_runner().get_supported_features())
def __init__(self, master): self._backend_proxy = get_runner().get_backend_proxy() super().__init__(master) assert isinstance(self._backend_proxy, running.CPythonProxy) self._last_name_to_show = None
def _run_or_resume_enabled(): return get_runner().cmd_run_current_script_enabled( ) or _debugger_command_enabled("resume")
def _get_interpreter(self): return get_runner().get_local_executable()
def perform_delete(self, paths, description): get_runner().send_command_and_wait( InlineCommand("delete", paths=paths, description=description), dialog_title=tr("Deleting"), )
def _handle_outdated_or_missing_pip(self, error): if get_runner().using_venv(): self._install_pip() else: self._provide_pip_install_instructions(error)
def supports_trash(self): return get_runner().get_backend_proxy().supports_trash()
def _targets_virtual_environment(self): return get_runner().using_venv()
def get_root_text(self): runner = get_runner() if runner: return runner.get_node_label() return "Back-end"
def _send_interrupt(self): self._sent_interrupt = True self._description_label.configure(text="Cancelling...") self._cancel_button.configure(text=tr("Close")) get_runner()._cmd_interrupt()
def request_fs_info(self, path): if get_runner(): get_runner().send_command(InlineCommand("get_fs_info", path=path))
def cmd_run_current_script_enabled(self) -> bool: return ( get_workbench().get_editor_notebook().get_current_editor() is not None and "run" in get_runner().get_supported_features() )
def can_do_file_operations(self): return self._proc is not None and get_runner( ).is_waiting_toplevel_command()
def request_dir_data(self, paths): get_runner().send_command(InlineCommand("get_dir_data", paths=paths))