def _ask_feedback(self, event=None):

        all_snapshots = self._snapshots_per_main_file[
            self._current_snapshot["main_file_path"]]

        # TODO: select only snapshots which are not sent yet
        snapshots = all_snapshots

        ui_utils.show_dialog(
            FeedbackDialog(get_workbench(), self.main_file_path, snapshots))
def ask_backend_path(master, dialog_kind):
    proxy = get_runner().get_backend_proxy()
    if not proxy:
        return None

    assert proxy.supports_remote_files()

    dlg = BackendFileDialog(master, dialog_kind, proxy.get_cwd())
    show_dialog(dlg, master)
    return dlg.result
def choose_node_for_file_operations(master, prompt):
    if get_runner().supports_remote_files():
        dlg = NodeChoiceDialog(master, prompt)
        show_dialog(dlg, master)
        if dlg.result == "remote" and not get_runner().ready_for_remote_file_operations(
            show_message=True
        ):
            return None
        return dlg.result
    else:
        return "local"
Esempio n. 4
0
    def _create_venv(self):
        path = None
        while True:
            path = askdirectory(
                master=self,
                initialdir=path,
                title=_("Select empty directory for new virtual environment"),
            )
            if not path:
                return

            if os.listdir(path):
                messagebox.showerror(
                    _("Bad directory"),
                    _("Selected directory is not empty.\nSelect another or cancel."
                      ),
                )
            else:
                break
        assert os.path.isdir(path)
        path = normpath_with_actual_case(path)

        proc = subprocess.Popen(
            [running.get_interpreter_for_subprocess(), "-m", "venv", path],
            stdin=None,
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT,
            universal_newlines=True,
        )
        dlg = SubprocessDialog(self, proc, _("Creating virtual environment"))
        ui_utils.show_dialog(dlg)

        if running_on_windows():
            exe_path = normpath_with_actual_case(
                os.path.join(path, "Scripts", "python.exe"))
        else:
            exe_path = os.path.join(path, "bin", "python3")

        if os.path.exists(exe_path):
            self._configuration_variable.set(exe_path)
Esempio n. 5
0
 def open_replayer():
     win = ReplayWindow()
     ui_utils.show_dialog(win)
Esempio n. 6
0
 def open_about(*args):
     ui_utils.show_dialog(AboutDialog(get_workbench()))
def show_dialog():
    dlg = ShellMacroDialog(get_workbench())
    ui_utils.show_dialog(dlg)
Esempio n. 8
0
 def open_frontend_pip_gui(*args):
     pg = PluginsPipDialog(get_workbench())
     ui_utils.show_dialog(pg)
Esempio n. 9
0
 def open_backend_pip_gui(*args):
     pg = BackendPipDialog(get_workbench())
     ui_utils.show_dialog(pg)
Esempio n. 10
0
def _ask_installation_details(master, data, selected_version):
    dlg = DetailsDialog(master, data, selected_version)
    ui_utils.show_dialog(dlg, master)
    return dlg.result
Esempio n. 11
0
def _show_subprocess_dialog(master, proc, title):
    dlg = SubprocessDialog(master, proc, title)
    ui_utils.show_dialog(dlg, master)
    return dlg.returncode, dlg.stdout, dlg.stderr
Esempio n. 12
0
def launch():
    import gettext
    import runpy

    if sys.executable.endswith("ynnoht.exe"):
        # otherwise some library may try to run its subprocess with ynnoht.exe
        # NB! Must be pythonw.exe not python.exe, otherwise Runner thinks console
        # is already allocated.
        sys.executable = sys.executable[:-len("ynnoht.exe")] + "pythonw.exe"

    set_dpi_aware()

    try:
        runpy.run_module("ynnoht.customize", run_name="__main__")
    except ImportError:
        pass

    gettext.install("ynnoht", "locale")
    _prepare_ynnoht_user_dir()

    if not _check_welcome():
        return

    if _should_delegate():
        try:
            _delegate_to_existing_instance(sys.argv[1:])
            print("Delegated to an existing Thonny instance. Exiting now.")
            return 0
        except Exception:
            traceback.print_exc()

    # Did not or could not delegate

    try:
        from ynnoht import workbench

        bench = workbench.Workbench()
        try:
            bench.mainloop()
        except SystemExit:
            bench.destroy()
        return 0

    except SystemExit as e:
        from tkinter import messagebox

        messagebox.showerror("System exit", str(e))
        return -1

    except Exception:
        from logging import exception

        exception("Internal launch or mainloop error")
        from ynnoht import ui_utils

        dlg = ui_utils.LongTextDialog("Internal error", traceback.format_exc())
        ui_utils.show_dialog(dlg, get_workbench())
        return -1
    finally:
        runner = get_runner()
        if runner is not None:
            runner.destroy_backend()

    return 0