示例#1
0
    def _conflicts_with_thonny_version(self, req_strings):
        import pkg_resources

        try:
            conflicts = []
            for req_string in req_strings:
                req = pkg_resources.Requirement.parse(req_string)
                if req.project_name == "thonny" and thonny.get_version() not in req:
                    conflicts.append(req_string)

            return conflicts
        except Exception:
            logging.exception("Problem computing conflicts")
            return None
示例#2
0
    def _collect_submission_data(self):
        import json

        tree_data = []

        for iid in self.tree.get_children():
            values = self.tree.item(iid, "values")
            tree_data.append(
                {
                    "helpful": values[0] == self._checked_box,
                    "confusing": values[1] == self._checked_box,
                    "message": values[2],
                    "group": values[3],
                    "symbol": values[4],
                }
            )

        submission = {
            "feedback_format_version": 1,
            "thonny_version": thonny.get_version(),
            "python_version": ".".join(map(str, sys.version_info[:3])),
            "message_feedback": tree_data,
            "comments": self.comments_text_frame.text.get("1.0", "end"),
        }

        try:
            import mypy.version

            submission["mypy_version"] = str(mypy.version.__version__)
        except ImportError:
            logging.exception("Could not get MyPy version")

        try:
            import pylint

            submission["pylint_version"] = str(pylint.__version__)
        except ImportError:
            logging.exception("Could not get Pylint version")

        if self.include_snapshots_var.get():
            submission["snapshots"] = self.snapshots

        if self.include_thonny_id_var.get():
            submission["thonny_timestamp"] = get_workbench().get_option(
                "general.configuration_creation_timestamp"
            )

        return json.dumps(submission, indent=2)
示例#3
0
 def _get_remote_program_directory(self):
     return "/tmp/thonny-backend-" + thonny.get_version()
示例#4
0
文件: about.py 项目: ZCG-coder/thonny
    def __init__(self, master):
        import webbrowser

        super().__init__(master)

        main_frame = ttk.Frame(self)
        main_frame.grid(sticky=tk.NSEW, ipadx=15, ipady=15)
        main_frame.rowconfigure(0, weight=1)
        main_frame.columnconfigure(0, weight=1)

        self.title(tr("About Thonny"))
        self.resizable(height=tk.FALSE, width=tk.FALSE)
        self.protocol("WM_DELETE_WINDOW", self._ok)

        # bg_frame = ttk.Frame(self) # gives proper color in aqua
        # bg_frame.grid()

        heading_font = tkinter.font.nametofont("TkHeadingFont").copy()
        heading_font.configure(size=19, weight="bold")
        heading_label = ttk.Label(
            main_frame, text="Thonny " + thonny.get_version(), font=heading_font
        )
        heading_label.grid()

        url = "https://thonny.org"
        url_font = tkinter.font.nametofont("TkDefaultFont").copy()
        url_font.configure(underline=1)
        url_label = ttk.Label(
            main_frame, text=url, style="Url.TLabel", cursor=get_hyperlink_cursor(), font=url_font
        )
        url_label.grid()
        url_label.bind("<Button-1>", lambda _: webbrowser.open(url))

        if sys.platform == "linux":
            try:
                import distro  # distro don't need to be installed

                system_desc = distro.name(True)
            except ImportError:
                system_desc = "Linux"

            if "32" not in system_desc and "64" not in system_desc:
                system_desc += " " + self.get_os_word_size_guess()
        else:
            system_desc = (
                platform.system() + " " + platform.release() + " " + self.get_os_word_size_guess()
            )

        platform_label = ttk.Label(
            main_frame,
            justify=tk.CENTER,
            text=system_desc
            + "\n"
            + "Python "
            + get_python_version_string(maxsize=sys.maxsize)
            + "\n"
            + "Tk "
            + ui_utils.get_tk_version_str(),
        )
        platform_label.grid(pady=20)

        credits_label = ttk.Label(
            main_frame,
            text=tr(
                "Made in\n"
                + "University of Tartu, Estonia,\n"
                + "with the help from\n"
                + "open-source community,\n"
                + "Raspberry Pi Foundation\n"
                + "and Cybernetica AS"
            ),
            style="Url.TLabel",
            cursor=get_hyperlink_cursor(),
            font=url_font,
            justify="center",
        )
        credits_label.grid()
        credits_label.bind(
            "<Button-1>",
            lambda _: webbrowser.open("https://github.com/thonny/thonny/blob/master/CREDITS.rst"),
        )

        license_font = tkinter.font.nametofont("TkDefaultFont").copy()
        license_font.configure(size=7)
        license_label = ttk.Label(
            main_frame,
            text="Copyright (©) "
            + str(datetime.datetime.now().year)
            + " Aivar Annamaa\n"
            + tr(
                "This program comes with\n"
                + "ABSOLUTELY NO WARRANTY!\n"
                + "It is free software, and you are welcome to\n"
                + "redistribute it under certain conditions, see\n"
                + "https://opensource.org/licenses/MIT\n"
                + "for details"
            ),
            justify=tk.CENTER,
            font=license_font,
        )
        license_label.grid(pady=20)

        ok_button = ttk.Button(main_frame, text=tr("OK"), command=self._ok, default="active")
        ok_button.grid(pady=(0, 15))
        ok_button.focus_set()

        self.bind("<Return>", self._ok, True)
        self.bind("<Escape>", self._ok, True)
示例#5
0
    def __init__(self, master):
        tk.Toplevel.__init__(self, master)

        main_frame = ttk.Frame(self)
        main_frame.grid(sticky=tk.NSEW, ipadx=15, ipady=15)
        main_frame.rowconfigure(0, weight=1)
        main_frame.columnconfigure(0, weight=1)

        self.title("About Thonny")
        if misc_utils.running_on_mac_os():
            self.configure(background="systemSheetBackground")
        self.resizable(height=tk.FALSE, width=tk.FALSE)
        self.transient(master)
        self.grab_set()
        self.protocol("WM_DELETE_WINDOW", self._ok)

        #bg_frame = ttk.Frame(self) # gives proper color in aqua
        #bg_frame.grid()

        heading_font = font.nametofont("TkHeadingFont").copy()
        heading_font.configure(size=19, weight="bold")
        heading_label = ttk.Label(main_frame,
                                  text="Thonny " + thonny.get_version(),
                                  font=heading_font)
        heading_label.grid()

        url = "http://thonny.org"
        url_font = font.nametofont("TkDefaultFont").copy()
        url_font.configure(underline=1)
        url_label = ttk.Label(
            main_frame,
            text=url,
            cursor="hand2",
            foreground="blue",
            font=url_font,
        )
        url_label.grid()
        url_label.bind("<Button-1>", lambda _: webbrowser.open(url))

        if platform.system() == "Linux":
            try:
                import distro  # distro don't need to be installed
                system_desc = distro.name(True)
            except ImportError:
                system_desc = "Linux"

            if "32" not in system_desc and "64" not in system_desc:
                system_desc += " " + self.get_os_word_size_guess()
        else:
            system_desc = (platform.system() + " " + platform.release() + " " +
                           self.get_os_word_size_guess())

        platform_label = ttk.Label(main_frame,
                                   justify=tk.CENTER,
                                   text=system_desc + "\n" + "Python " +
                                   get_python_version_string() + "Tk " +
                                   ui_utils.get_tk_version_str())
        platform_label.grid(pady=20)

        credits_label = ttk.Label(
            main_frame,
            text="Made in\nUniversity of Tartu, Estonia\n" +
            "with the help from\nopen-source community",
            cursor="hand2",
            foreground="blue",
            font=url_font,
            justify=tk.CENTER)
        credits_label.grid()
        credits_label.bind(
            "<Button-1>", lambda _: webbrowser.open(
                "https://bitbucket.org/plas/thonny/src/master/CREDITS.rst"))

        license_font = font.nametofont("TkDefaultFont").copy()
        license_font.configure(size=7)
        license_label = ttk.Label(
            main_frame,
            text="Copyright (©) " + str(datetime.datetime.now().year) +
            " Aivar Annamaa\n" + "This program comes with\n" +
            "ABSOLUTELY NO WARRANTY!\n" +
            "It is free software, and you are welcome to\n" +
            "redistribute it under certain conditions, see\n" +
            "https://opensource.org/licenses/MIT\n" + "for details",
            justify=tk.CENTER,
            font=license_font)
        license_label.grid(pady=20)

        ok_button = ttk.Button(main_frame,
                               text="OK",
                               command=self._ok,
                               default="active")
        ok_button.grid(pady=(0, 15))
        ok_button.focus_set()

        self.bind('<Return>', self._ok, True)
        self.bind('<Escape>', self._ok, True)

        ui_utils.center_window(self, master)
        self.wait_window()