def init_action_frame(self): padding = self.get_padding() intpad = self.get_internal_padding() self.action_frame = ttk.Frame(self) self.action_frame.grid(row=2, column=0, sticky="nsew") self._progress_bar = ttk.Progressbar(self.action_frame, length=ems_to_pixels(4), mode="indeterminate") self._current_action_label = create_action_label( self.action_frame, text="Installing", width=self.get_action_text_max_length(), click_handler=self.toggle_log_frame, ) self._ok_button = ttk.Button(self.action_frame, text=self.get_ok_text(), command=self.on_ok, state="disabled") self._ok_button.grid(column=4, row=1, pady=padding, padx=(0, intpad)) self._cancel_button = ttk.Button( self.action_frame, text=self.get_cancel_text(), command=self.on_cancel, ) self._cancel_button.grid(column=5, row=1, padx=(0, padding), pady=padding) self.action_frame.columnconfigure(2, weight=1)
def __init__(self, master): super().__init__(master) self._configuration_variable = create_string_var( get_workbench().get_option("CustomInterpreter.path")) entry_label = ttk.Label(self, text=tr("Python executable")) entry_label.grid(row=0, column=1, columnspan=2, sticky=tk.W) self._entry = ttk.Combobox( self, exportselection=False, textvariable=self._configuration_variable, values=_get_interpreters(), ) self._entry.grid(row=1, column=1, sticky=tk.NSEW) self._select_button = ttk.Button( self, text="...", width=3, command=self._select_executable, ) self._select_button.grid(row=1, column=2, sticky="e", padx=(10, 0)) self.columnconfigure(1, weight=1) extra_text = tr("NB! Thonny only supports Python 3.5 and later") if running_on_mac_os(): extra_text += "\n\n" + tr( "NB! File selection button may not work properly when selecting executables\n" + "from a virtual environment. In this case choose the 'activate' script instead\n" + "of the interpreter (or enter the path directly to the box)!") extra_label = ttk.Label(self, text=extra_text) extra_label.grid(row=2, column=1, columnspan=2, pady=10, sticky="w") last_row = ttk.Frame(self) last_row.grid(row=100, sticky="swe", column=1, columnspan=2) self.rowconfigure(100, weight=1) last_row.columnconfigure(1, weight=1) new_venv_link = ui_utils.create_action_label( last_row, "New virtual environment", self._create_venv, ) new_venv_link.grid(row=0, column=1, sticky="e", pady=10)
def __init__(self, master): super().__init__(master) self._has_opened_firmware_flasher = False intro_label = ttk.Label(self, text=self._get_intro_text()) intro_label.grid(row=0, column=0, sticky="nw") driver_url = self._get_usb_driver_url() if driver_url: driver_url_label = create_url_label(self, driver_url) driver_url_label.grid(row=1, column=0, sticky="nw") port_label = ttk.Label( self, text="Port or WebREPL" if self.allow_webrepl else tr("Port")) port_label.grid(row=3, column=0, sticky="nw", pady=(10, 0)) self._ports_by_desc = { p.description if p.device in p.description else p.description + " (" + p.device + ")": p.device for p in list_serial_ports() } self._ports_by_desc["< " + tr("Try to detect port automatically") + " >"] = "auto" self._WEBREPL_OPTION_DESC = "< WebREPL >" if self.allow_webrepl: self._ports_by_desc[self._WEBREPL_OPTION_DESC] = "webrepl" def port_order(p): _, name = p if name is None: return "" elif name.startswith("COM") and len(name) == 4: # Make one-digit COM ports go before COM10 return name.replace("COM", "COM0") else: return name # order by port, auto first port_descriptions = [ key for key, _ in sorted(self._ports_by_desc.items(), key=port_order) ] self._port_desc_variable = create_string_var( self.get_stored_port_desc(), self._on_change_port) self._port_combo = ttk.Combobox( self, exportselection=False, textvariable=self._port_desc_variable, values=port_descriptions, ) self._port_combo.state(["!disabled", "readonly"]) self._port_combo.grid(row=4, column=0, sticky="new") self.columnconfigure(0, weight=1) self._webrepl_frame = None self._flashing_frame = None last_row = ttk.Frame(self) last_row.grid(row=100, sticky="swe") self.rowconfigure(100, weight=1) last_row.columnconfigure(1, weight=1) advanced_link = ui_utils.create_action_label( last_row, tr("Advanced options"), lambda event: self._show_advanced_options()) # advanced_link.grid(row=0, column=1, sticky="e") if self._has_flashing_dialog(): firmware_link = ui_utils.create_action_label( last_row, tr("Install or update firmware"), self._on_click_firmware_installer_link, ) firmware_link.grid(row=1, column=1, sticky="e") self._on_change_port()