def __init__(self, master, page_records_with_order): super().__init__(master) width = ems_to_pixels(60) height = ems_to_pixels(50) self.geometry("%dx%d" % (width, height)) self.title(tr("Thonny options")) self.columnconfigure(0, weight=1) self.rowconfigure(0, weight=1) self.backend_restart_required = False self.gui_restart_required = False main_frame = ttk.Frame( self) # otherwise there is wrong color background with clam main_frame.grid(row=0, column=0, sticky=tk.NSEW) main_frame.columnconfigure(0, weight=1) main_frame.rowconfigure(0, weight=1) self._notebook = ttk.Notebook(main_frame) self._notebook.grid(row=0, column=0, columnspan=3, sticky=tk.NSEW, padx=10, pady=10) self._ok_button = ttk.Button(main_frame, text=tr("OK"), command=self._ok, default="active") self._cancel_button = ttk.Button(main_frame, text=tr("Cancel"), command=self._cancel) self._ok_button.grid(row=1, column=1, padx=(0, 11), pady=(0, 10)) self._cancel_button.grid(row=1, column=2, padx=(0, 11), pady=(0, 10)) self._page_records = [] for key, title, page_class, _ in sorted(page_records_with_order, key=lambda r: (r[3], r[0])): try: spacer = ttk.Frame(self) spacer.rowconfigure(0, weight=1) spacer.columnconfigure(0, weight=1) page = page_class(spacer) page.key = key page.dialog = self self._page_records.append((key, title, page)) page.grid(sticky=tk.NSEW, pady=(15, 10), padx=15) self._notebook.add(spacer, text=title) except Exception as e: logger.exception("Could not create configuration page %s", key, exc_info=e) self.bind("<Return>", self._ok, True) self.bind("<Escape>", self._cancel, True) self._notebook.select( self._notebook.tabs()[ConfigurationDialog.last_shown_tab_index])
def __init__(self, master, page_records): tk.Toplevel.__init__(self, master) width = ems_to_pixels(53) height = ems_to_pixels(43) self.geometry("%dx%d" % (width, height)) self.title("Thonny options") self.columnconfigure(0, weight=1) self.rowconfigure(0, weight=1) main_frame = ttk.Frame( self) # otherwise there is wrong color background with clam main_frame.grid(row=0, column=0, sticky=tk.NSEW) main_frame.columnconfigure(0, weight=1) main_frame.rowconfigure(0, weight=1) self._notebook = ttk.Notebook(main_frame) self._notebook.grid(row=0, column=0, columnspan=3, sticky=tk.NSEW, padx=10, pady=10) self._ok_button = ttk.Button(main_frame, text="OK", command=self._ok, default="active") self._cancel_button = ttk.Button(main_frame, text="Cancel", command=self._cancel) self._ok_button.grid(row=1, column=1, padx=(0, 11), pady=(0, 10)) self._cancel_button.grid(row=1, column=2, padx=(0, 11), pady=(0, 10)) self._page_records = [] for key, title, page_class, order in sorted(page_records, key=lambda r: (r[3], r[0])): try: spacer = ttk.Frame(self) spacer.rowconfigure(0, weight=1) spacer.columnconfigure(0, weight=1) page = page_class(spacer) page.key = key self._page_records.append((key, title, page)) page.grid(sticky=tk.NSEW, pady=(15, 10), padx=15) self._notebook.add(spacer, text=title) except Exception: traceback.print_exc() self.bind("<Return>", self._ok, True) self.bind("<Escape>", self._cancel, True) self._notebook.select( self._notebook.tabs()[ConfigurationDialog.last_shown_tab_index])
def present_signatures(self, text: SyntaxText, signatures: List[SignatureInfo]): self._target_text_widget = text self._check_bind_for_keypress(text) self.text.direct_delete("1.0", "end") self.render_signatures(signatures, only_params=True) char_count = self.text.count("1.0", "end", "chars")[0] extra_width_factor = 1.0 # NB! Width should be set here, not in update_size, so that it that on-screen # height calculation already uses this if char_count * extra_width_factor < self._max_width: self.text["width"] = max(round(char_count * extra_width_factor), 10) else: self.text["width"] = self._max_width self.text["height"] = 3 expected_height = 10 # TODO pos = signatures[0].call_bracket_start if pos: self._show_on_target_text( "%d.%d" % pos, expected_height, "above", y_offset=-ems_to_pixels(0.3), )
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): ContentInspector.__init__(self, master) thonny.memory.MemoryFrame.__init__(self, master, ("key_id", "id", "key", "value"), show_statusbar=True) # self.configure(border=1) # self.vert_scrollbar.grid_remove() self.tree.column("key_id", width=ems_to_pixels(7), anchor=tk.W, stretch=False) self.tree.column("key", width=100, anchor=tk.W, stretch=False) self.tree.column("id", width=750, anchor=tk.W, stretch=True) self.tree.column("value", width=750, anchor=tk.W, stretch=True) self.tree.heading("key_id", text=tr("Key ID"), anchor=tk.W) self.tree.heading("key", text=tr("Key"), anchor=tk.W) self.tree.heading("id", text=tr("Value ID"), anchor=tk.W) self.tree.heading("value", text=tr("Value"), anchor=tk.W) self.len_label = ttk.Label(self.statusbar, text="", anchor="w") self.len_label.grid(row=0, column=0, sticky="w") self.statusbar.columnconfigure(0, weight=1) self.update_memory_model()
def __init__(self, master): ContentInspector.__init__(self, master) thonny.memory.MemoryFrame.__init__(self, master, ("index", "id", "value"), show_statusbar=True) # self.vert_scrollbar.grid_remove() self.tree.column("index", width=ems_to_pixels(4), anchor=tk.W, stretch=False) self.tree.column("id", width=750, anchor=tk.W, stretch=True) self.tree.column("value", width=750, anchor=tk.W, stretch=True) self.tree.heading("index", text=tr("Index"), anchor=tk.W) self.tree.heading("id", text=tr("Value ID"), anchor=tk.W) self.tree.heading("value", text=tr("Value"), anchor=tk.W) self.len_label = ttk.Label(self.statusbar, text="", anchor="w") self.len_label.grid(row=0, column=0, sticky="w") self.statusbar.columnconfigure(0, weight=1) self.elements_have_indices = None self.update_memory_model() get_workbench().bind("ShowView", self.update_memory_model, True) get_workbench().bind("HideView", self.update_memory_model, True)
def __init__(self, master, target_dir): self._release_info = None self._hex_url = None self._hex_size = None self._target_dir = target_dir self._bytes_copied = 0 self._state = "starting" super().__init__(master) main_frame = ttk.Frame(self) # To get styled background main_frame.grid(row=0, column=0, sticky="nsew") self.rowconfigure(0, weight=1) self.columnconfigure(0, weight=1) main_frame.columnconfigure(1, weight=1) self.title(tr("Install latest MicroPython to BBC micro:bit")) target_caption_label = ttk.Label(main_frame, text=tr("micro:bit location:")) target_caption_label.grid(row=0, column=0, padx=15, pady=(15, 0), sticky="w") target_label = ttk.Label(main_frame, text=self._target_dir) target_label.grid(row=0, column=1, padx=15, pady=(15, 0), sticky="w", columnspan=2) version_caption_label = ttk.Label(main_frame, text=tr("Version to be installed:")) version_caption_label.grid(row=1, column=0, sticky="w", padx=15, pady=(0, 15)) self._version_label = ttk.Label(main_frame, text=tr("please wait") + " ...") self._version_label.grid(row=1, column=1, columnspan=2, padx=15, pady=(0, 15), sticky="w") self._state_label = ttk.Label( main_frame, text=tr("NB! All files on micro:bit will be deleted!") ) self._state_label.grid(row=2, column=0, columnspan=3, sticky="w", padx=15, pady=(0, 15)) self._progress_bar = ttk.Progressbar(main_frame, length=ems_to_pixels(30)) self._progress_bar.grid(row=3, column=0, columnspan=3, sticky="nsew", padx=15, pady=0) self._install_button = ttk.Button( main_frame, text=tr("Install"), command=self._start_installing ) self._install_button.grid(row=4, column=0, columnspan=2, sticky="ne", padx=0, pady=15) self._close_button = ttk.Button(main_frame, text=tr("Cancel"), command=self._close) self._close_button.grid(row=4, column=2, sticky="ne", padx=15, pady=15) self._progress_bar.focus_set() main_frame.columnconfigure(1, weight=1) self.bind("<Escape>", self._close, True) # escape-close only if process has completed self.protocol("WM_DELETE_WINDOW", self._close) self._start_downloading_release_info() self._update_state()
def __init__(self, master, conf_group): super().__init__(master) self._changed = False self._conf_group = conf_group inner_pad = ems_to_pixels(0.6) self._host_var = self._add_text_field("Host", self._conf_group + ".host", 1, pady=(0, inner_pad), width=20) self._user_var = self._add_text_field("Username", self._conf_group + ".user", 3, pady=(0, inner_pad), width=20) from thonny.misc_utils import ( PASSWORD_METHOD, PUBLIC_KEY_NO_PASS_METHOD, PUBLIC_KEY_WITH_PASS_METHOD, ) self._method_var = self._add_combobox_field( "Authentication method", self._conf_group + ".auth_method", 5, [ PASSWORD_METHOD, PUBLIC_KEY_NO_PASS_METHOD, PUBLIC_KEY_WITH_PASS_METHOD ], pady=(0, inner_pad), width=30, ) self._interpreter_var = self._add_text_field( "Interpreter", self._conf_group + ".executable", 30, pady=(2 * inner_pad, inner_pad), width=30, )
def _add_combobox_field(self, label_text, variable_name, row, options, pady: Union[int, tuple] = 0, width=None): if isinstance(pady, int): pady = (pady, pady) label = ttk.Label(self, text=label_text) label.grid(row=row, column=0, sticky="w", pady=pady) variable = create_string_var(get_workbench().get_option(variable_name), self._on_change) return self.add_combobox(variable, options, row=row, column=1, pady=pady, padx=ems_to_pixels(1), width=width)
def _add_text_field(self, label_text, variable_name, row, show=None, pady: Union[int, tuple] = 0, width=None): if isinstance(pady, int): pady = (pady, pady) entry_label = ttk.Label(self, text=label_text) entry_label.grid(row=row, column=0, sticky="w", pady=pady) variable = create_string_var(get_workbench().get_option(variable_name), self._on_change) entry = ttk.Entry(self, textvariable=variable, show=show, width=width) entry.grid(row=row, column=1, sticky="we", pady=pady, padx=ems_to_pixels(1)) return variable
def _show_next_to_completions(self): self._details_box._show_on_screen( self.winfo_rootx() + self.winfo_width() + ems_to_pixels(0.5), self.winfo_rooty())
def __init__(self, master, chip, start_address, initial_port_desc=""): super().__init__(master) self.title("Install %s firmware with esptool" % chip.upper()) self._chip = chip self._start_address = start_address self._esptool_command = self._get_esptool_command() if not self._esptool_command: messagebox.showerror( "Can't find esptool", "esptool not found.\n" + "Install it via 'Tools => Manage plug-ins'\n" + "or using your OP-system package manager.", ) return self._close() self.main_frame.columnconfigure(2, weight=1) epadx = ems_to_pixels(2) ipadx = ems_to_pixels(0.5) epady = epadx ipady = ipadx # Port port_label = ttk.Label(self.main_frame, text="Port") port_label.grid(row=1, column=1, sticky="w", padx=(epadx, 0), pady=(epady, 0)) self._port_desc_variable = tk.StringVar(value=initial_port_desc) self._port_combo = ttk.Combobox(self.main_frame, exportselection=False, textvariable=self._port_desc_variable, values=[]) self._port_combo.state(["!disabled", "readonly"]) self._port_combo.grid(row=1, column=2, sticky="nsew", padx=ipadx, pady=(epady, 0)) port_reload_button = ttk.Button(self.main_frame, text="Reload", command=self._reload_ports) port_reload_button.grid(row=1, column=3, sticky="ew", padx=(0, epadx), pady=(epady, 0)) # Firmware firmware_label = ttk.Label(self.main_frame, text="Firmware") firmware_label.grid(row=2, column=1, sticky="w", padx=(epadx, 0), pady=(ipady, 0)) self._firmware_entry = ttk.Entry(self.main_frame, width=65) self._firmware_entry.grid(row=2, column=2, sticky="nsew", padx=ipadx, pady=(ipady, 0)) browse_button = ttk.Button(self.main_frame, text="Browse...", command=self._browse) browse_button.grid(row=2, column=3, sticky="we", padx=(0, epadx), pady=(ipady, 0)) # Erase self._erase_variable = tk.BooleanVar(value=True) self._erase_checkbutton = ttk.Checkbutton( self.main_frame, text="Erase flash before installing", variable=self._erase_variable) self._erase_checkbutton.grid(row=3, column=1, columnspan=3, sticky="w", padx=(epadx, 0), pady=(ipady, 0)) # Buttons install_button = ttk.Button(self.main_frame, text="Install", command=self._install) install_button.grid(row=4, column=1, columnspan=2, sticky="e", padx=ipadx, pady=(0, epady)) cancel_button = ttk.Button(self.main_frame, text="Close", command=self._close) cancel_button.grid(row=4, column=3, columnspan=1, sticky="we", padx=(0, epadx), pady=(0, epady)) self._reload_ports()
def _install(self): if not self._port_desc_variable.get(): messagebox.showerror("Select port", "Please select port") return port = self._ports_by_desc[self._port_desc_variable.get()] firmware_path = self._firmware_entry.get() if not os.path.exists(firmware_path): messagebox.showerror("Bad firmware path", "Can't find firmware, please check path") return erase_command = self._esptool_command + [ "--chip", self._chip, "--port", port, "erase_flash", ] write_command = self._esptool_command + [ "--chip", self._chip, "--port", port, "write_flash", self._start_address, firmware_path, ] if not self._check_connection(port): return # unknown problem with first dialog appearing at 0,0 # self.update_idletasks() if self.winfo_screenwidth() >= 1024: min_left = ems_to_pixels(15) min_top = ems_to_pixels(5) else: min_left = 0 min_top = 0 def long_desc(cmd): return "Command:\n%s\n\nOutput:\n" % construct_cmd_line(cmd) self.update_idletasks() if self._erase_variable.get(): proc = self._create_subprocess(erase_command) dlg = SubprocessDialog( self, proc, "Erasing flash", long_description=long_desc(erase_command), autoclose=True, ) show_dialog(dlg, master=self, min_left=min_left, min_top=min_top) if dlg.cancelled or dlg.returncode: return proc = self._create_subprocess(write_command) dlg = SubprocessDialog( self, proc, "Installing firmware", long_description=long_desc(write_command), autoclose=False, ) show_dialog(dlg, master=self, min_left=min_left, min_top=min_top)
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=tr("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.add_checkbox( self.backend_name + ".interrupt_on_connect", row=10, description=tr("Interrupt working program on connect"), pady=(ems_to_pixels(2.0), 0), ) self.add_checkbox( self.backend_name + ".sync_time", row=11, description=tr("Synchronize device's real time clock"), ) self.add_checkbox( self.backend_name + ".local_rtc", row=12, description=tr("Use local time in real time clock"), ) self.add_checkbox( self.backend_name + ".restart_interpreter_before_run", row=13, description=tr("Restart interpreter before running a script"), ) 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()
def clam() -> BasicUiThemeSettings: # Transcribed from https://github.com/tcltk/tk/blob/master/library/ttk/clamTheme.tcl defaultfg = "#000000" disabledfg = "#999999" frame = "#dcdad5" window = "#ffffff" dark = "#cfcdc8" darker = "#bab5ab" darkest = "#9e9a91" lighter = "#eeebe7" selectbg = "#4a6984" selectfg = "#ffffff" altindicator = "#5895bc" disabledaltindicator = "#a0a0a0" return { ".": { "configure": { "background": frame, "foreground": defaultfg, "bordercolor": darkest, "darkcolor": dark, "lightcolor": lighter, "troughcolor": darker, "selectbackground": selectbg, "selectforeground": selectfg, "selectborderwidth": 0, "font": "TkDefaultFont", }, "map": { "background": [("disabled", frame), ("active", lighter)], "foreground": [("disabled", disabledfg)], "selectbackground": [("!focus", darkest)], "selectforeground": [("!focus", "white")], }, }, "TButton": { "configure": { "anchor": "center", "width": scale(11), "padding": scale(5), "relief": "raised", }, "map": { "background": [("disabled", frame), ("pressed", darker), ("active", lighter)], "lightcolor": [("pressed", darker)], "darkcolor": [("pressed", darker)], "bordercolor": [("alternate", "#000000")], }, }, "Toolbutton": { "configure": { "anchor": "center", "padding": scale(2), "relief": "flat" }, "map": { "relief": [ ("disabled", "flat"), ("selected", "sunken"), ("pressed", "sunken"), ("active", "raised"), ], "background": [("disabled", frame), ("pressed", darker), ("active", lighter)], "lightcolor": [("pressed", darker)], "darkcolor": [("pressed", darker)], }, }, "TCheckbutton": { "configure": { "indicatorbackground": "#ffffff", "indicatormargin": [scale(1), scale(1), scale(6), scale(1)], "padding": scale(2), }, "map": { "indicatorbackground": [ ("pressed", frame), ("!disabled", "alternate", altindicator), ("disabled", "alternate", disabledaltindicator), ("disabled", frame), ] }, }, # TRadiobutton has same style as TCheckbutton "TRadiobutton": { "configure": { "indicatorbackground": "#ffffff", "indicatormargin": [scale(1), scale(1), scale(6), scale(1)], "padding": scale(2), }, "map": { "indicatorbackground": [ ("pressed", frame), ("!disabled", "alternate", altindicator), ("disabled", "alternate", disabledaltindicator), ("disabled", frame), ] }, }, "TMenubutton": { "configure": { "width": scale(11), "padding": scale(5), "relief": "raised" } }, "TEntry": { "configure": { "padding": scale(1), "insertwidth": scale(1) }, "map": { "background": [("readonly", frame)], "bordercolor": [("focus", selectbg)], "lightcolor": [("focus", "#6f9dc6")], "darkcolor": [("focus", "#6f9dc6")], }, }, "TCombobox": { "configure": { "padding": [scale(4), scale(2), scale(2), scale(2)], "insertwidth": scale(1), }, "map": { "background": [("active", lighter), ("pressed", lighter)], "fieldbackground": [("readonly", "focus", selectbg), ("readonly", frame)], "foreground": [("readonly", "focus", selectfg)], "arrowcolor": [("disabled", disabledfg)], }, }, "ComboboxPopdownFrame": { "configure": { "relief": "solid", "borderwidth": scale(1) } }, "TSpinbox": { "configure": { "arrowsize": scale(10), "padding": [scale(2), 0, scale(10), 0] }, "map": { "background": [("readonly", frame)], "arrowcolor": [("disabled", disabledfg)] }, }, "TNotebook.Tab": { "configure": { "padding": [scale(6), scale(2), scale(6), scale(2)] }, "map": { "padding": [("selected", [scale(6), scale(4), scale(6), scale(4)])], "background": [("selected", frame), ("", darker)], "lightcolor": [("selected", lighter), ("", dark)], }, }, "Treeview": { "configure": { "background": window }, "map": { "background": [ ("disabled", frame), ("!disabled", "!selected", window), ("selected", selectbg), ], "foreground": [ ("disabled", disabledfg), ("!disabled", "!selected", defaultfg), ("selected", selectfg), ], }, }, # Treeview heading "Heading": { "configure": { "font": "TkHeadingFont", "relief": "raised", "padding": [scale(3), scale(3), scale(3), scale(3)], } }, "TLabelframe": { "configure": { "labeloutside": True, "labelmargins": [0, 0, 0, scale(4)] } }, "TProgressbar": { "configure": { "background": frame } }, "Sash": { "configure": { "sashthickness": ems_to_pixels(0.6), "gripcount": 10 } }, }
def _paned_window_settings() -> BasicUiThemeSettings: return {"Sash": {"configure": {"sashthickness": ems_to_pixels(0.6)}}}
def __init__(self, master): ConfigurationPage.__init__(self, master) # HACK: take geometry from options window and increase its width with 5 em for extra ev3 tab # and 10 em for extra heigt for ev3 tab optionsWindow = self.master.master optionsWindow.update() # to update geometry in optionsWindow geometry = optionsWindow.winfo_geometry() # print("geometry:",geometry) # needs above update call otherwise geometry: 1x1+0+0 width = optionsWindow.winfo_width() height = optionsWindow.winfo_height() # print("width:",width) # print("height:",height) from thonny.ui_utils import ems_to_pixels width = width + ems_to_pixels(5) height = height + ems_to_pixels(14) optionsWindow.geometry("%dx%d" % (width, height)) # get options from workbench workbench = get_workbench() for name in ('ip', 'username', 'password', 'rpyc_timeout', "playfield"): self.__dict__[name] = create_string_var( workbench.get_option("ev3." + name)) for name in ('show_start_stop_buttons', 'show_fullscreen', 'show_maximized', 'show_on_second_monitor'): self.__dict__[name] = create_string_var( workbench.get_option("ev3." + name)) ttk.Label(self, text="EV3 connection settings").pack(side=tk.TOP, padx=5, pady=(5, 30)) self.makeentry("IP address:", self.ip, width=10) self.makeentry("User name:", self.username, width=10) self.makeentry("Password:"******"EV3 Simulator options").pack(side=tk.TOP, padx=5, pady=(20, 20)) self.makeselect("Playfield", self.playfield, ["small", "large"]) #self.makecheckbox( "Show simulator maximized", self.show_maximized) import platform if platform.system().lower() == "windows": self.makecheckbox("Show simulator fullscreen on second monitor", self.show_on_second_monitor) else: self.makecheckbox("Show simulator fullscreen", self.show_fullscreen) self.makecheckbox("Show simulator window on second monitor", self.show_on_second_monitor) ttk.Label( self, text= "Warning: to use simulated bluetooth in simulator make sure you have PyBluez uninstalled!", font="BoldTkDefaultFont").pack(side=tk.TOP, padx=0, pady=(0, 0)) ttk.Label(self, text="EV3 Advanced options").pack(side=tk.TOP, padx=5, pady=(20, 20)) self.makecheckbox( "Show start/stop on the EV3 buttons on toolbar. (needs restart)", self.show_start_stop_buttons) self.makeentry("Rpyc Timeout(secs)^:", self.rpyc_timeout, width=10) default_font = tk.font.nametofont("TkDefaultFont") label = ttk.Label( self, text= ('^ The "Stop all programs/motors/sound on EV3" command is faster when using the rpyc protocol but it needs\n' ' the rpyc server installed on the EV3. First the rpyc protocol is tried, but if that fails the slower \n' ' ssh protocol is tried. Because by default no rpyc server is installed we keep the rpyc timeout low,\n' ' however sometimes a bigger rpyc timeout is needed which can be increased here.' )) label.config(font=(default_font.cget("family"), int(default_font.cget("size") * 0.9))) label.pack(side=tk.TOP, padx=5, pady=(20, 20))
def __init__(self, master): ConfigurationPage.__init__(self, master) group_spacing = ems_to_pixels(2) try: self.add_checkbox("view.name_highlighting", tr("Highlight matching names")) except Exception: # name matcher may have been disabled logger.warning("Couldn't create name matcher checkbox") try: self.add_checkbox("view.locals_highlighting", tr("Highlight local variables")) except Exception: # locals highlighter may have been disabled logger.warning("Couldn't create name locals highlighter checkbox") self.add_checkbox("view.paren_highlighting", tr("Highlight parentheses")) self.add_checkbox("view.syntax_coloring", tr("Highlight syntax elements")) self.add_checkbox("view.highlight_tabs", tr("Highlight tab characters")) self.add_checkbox( "view.highlight_current_line", tr("Highlight current line (requires reopening the editor)"), ) self.add_checkbox( "edit.automatic_calltips", tr("Automatically show parameter info after typing '('"), columnspan=2, pady=(group_spacing, 0), ) self.add_checkbox( "edit.automatic_completions", tr("Automatically propose completions while typing"), columnspan=2, ) self.add_checkbox( "edit.automatic_completion_details", tr("Automatically show documentation for completions"), columnspan=2, ) self.add_checkbox( "edit.tab_request_completions_in_editors", tr("Request completions with Tab-key in editors"), columnspan=2, ) self.add_checkbox( "edit.tab_request_completions_in_shell", tr("Request completions with Tab-key in Shell"), columnspan=2, ) self.add_checkbox( "edit.indent_with_tabs", tr("Indent with tab characters (not recommended for Python)"), columnspan=2, pady=(group_spacing, 0), ) self.add_checkbox("view.show_line_numbers", tr("Show line numbers"), pady=(20, 0)) self._line_length_var = get_workbench().get_variable("view.recommended_line_length") label = ttk.Label( self, text=tr("Recommended maximum line length\n(Set to 0 to turn off margin line)") ) label.grid(row=20, column=0, sticky=tk.W) self._line_length_combo = ttk.Combobox( self, width=4, exportselection=False, textvariable=self._line_length_var, state="readonly", values=[0, 60, 70, 80, 90, 100, 110, 120], ) self._line_length_combo.grid(row=20, column=1, sticky=tk.W, padx=10) self.columnconfigure(1, weight=1)
def _create_widgets(self, parent): header_frame = ttk.Frame(parent) header_frame.grid(row=1, column=0, sticky="nsew", padx=15, pady=(15, 0)) header_frame.columnconfigure(0, weight=1) header_frame.rowconfigure(1, weight=1) name_font = tk.font.nametofont("TkDefaultFont").copy() name_font.configure(size=16) self.search_box = ttk.Entry(header_frame) self.search_box.grid(row=1, column=0, sticky="nsew") self.search_box.bind("<Return>", self._on_search, False) self.search_box.bind("<KP_Enter>", self._on_search, False) # Selecting chars in the search box with mouse didn't make the box active on Linux without following line self.search_box.bind("<B1-Motion>", lambda _: self.search_box.focus_set()) self.search_button = ttk.Button( header_frame, text=tr(SEARCH_ON_PYPI), command=self._on_search, width=25 ) self.search_button.grid(row=1, column=1, sticky="nse", padx=(10, 0)) main_pw = tk.PanedWindow( parent, orient=tk.HORIZONTAL, background=lookup_style_option("TPanedWindow", "background"), sashwidth=15, ) main_pw.grid(row=2, column=0, sticky="nsew", padx=15, pady=15) parent.rowconfigure(2, weight=1) parent.columnconfigure(0, weight=1) listframe = ttk.Frame(main_pw, relief="flat", borderwidth=1) listframe.rowconfigure(0, weight=1) listframe.columnconfigure(0, weight=1) self.listbox = ui_utils.ThemedListbox( listframe, activestyle="dotbox", width=20, height=20, selectborderwidth=0, relief="flat", # highlightthickness=4, # highlightbackground="red", # highlightcolor="green", borderwidth=0, ) self.listbox.insert("end", " <" + tr("INSTALL") + ">") self.listbox.bind("<<ListboxSelect>>", self._on_listbox_select, True) self.listbox.grid(row=0, column=0, sticky="nsew") list_scrollbar = AutoScrollbar( listframe, orient=tk.VERTICAL, style=scrollbar_style("Vertical") ) list_scrollbar.grid(row=0, column=1, sticky="ns") list_scrollbar["command"] = self.listbox.yview self.listbox["yscrollcommand"] = list_scrollbar.set info_frame = ttk.Frame(main_pw) info_frame.columnconfigure(0, weight=1) info_frame.rowconfigure(1, weight=1) main_pw.add(listframe) main_pw.add(info_frame) self.title_label = ttk.Label(info_frame, text="", font=name_font) self.title_label.grid(row=0, column=0, sticky="w", padx=5, pady=(0, ems_to_pixels(1))) info_text_frame = tktextext.TextFrame( info_frame, read_only=True, horizontal_scrollbar=False, background=lookup_style_option("TFrame", "background"), vertical_scrollbar_class=AutoScrollbar, vertical_scrollbar_style=scrollbar_style("Vertical"), horizontal_scrollbar_style=scrollbar_style("Horizontal"), width=70, height=10, ) info_text_frame.configure(borderwidth=0) info_text_frame.grid(row=1, column=0, columnspan=4, sticky="nsew", pady=(0, 10)) self.info_text = info_text_frame.text link_color = lookup_style_option("Url.TLabel", "foreground", "red") self.info_text.tag_configure("url", foreground=link_color, underline=True) self.info_text.tag_bind("url", "<ButtonRelease-1>", self._handle_url_click) self.info_text.tag_bind("url", "<Enter>", lambda e: self.info_text.config(cursor="hand2")) self.info_text.tag_bind("url", "<Leave>", lambda e: self.info_text.config(cursor="")) self.info_text.tag_configure("install_reqs", foreground=link_color, underline=True) self.info_text.tag_bind( "install_reqs", "<ButtonRelease-1>", self._handle_install_requirements_click ) self.info_text.tag_bind( "install_reqs", "<Enter>", lambda e: self.info_text.config(cursor="hand2") ) self.info_text.tag_bind( "install_reqs", "<Leave>", lambda e: self.info_text.config(cursor="") ) self.info_text.tag_configure("install_file", foreground=link_color, underline=True) self.info_text.tag_bind( "install_file", "<ButtonRelease-1>", self._handle_install_file_click ) self.info_text.tag_bind( "install_file", "<Enter>", lambda e: self.info_text.config(cursor="hand2") ) self.info_text.tag_bind( "install_file", "<Leave>", lambda e: self.info_text.config(cursor="") ) default_font = tk.font.nametofont("TkDefaultFont") self.info_text.configure(font=default_font, wrap="word") bold_font = default_font.copy() # need to explicitly copy size, because Tk 8.6 on certain Ubuntus use bigger font in copies bold_font.configure(weight="bold", size=default_font.cget("size")) self.info_text.tag_configure("caption", font=bold_font) self.info_text.tag_configure("bold", font=bold_font) self.command_frame = ttk.Frame(info_frame) self.command_frame.grid(row=2, column=0, sticky="w") self.install_button = ttk.Button( self.command_frame, text=" " + tr(UPGRADE) + " ", command=self._on_install_click, width=20, ) self.install_button.grid(row=0, column=0, sticky="w", padx=0) self.uninstall_button = ttk.Button( self.command_frame, text=tr(UNINSTALL), command=self._on_uninstall_click, width=20, ) self.uninstall_button.grid(row=0, column=1, sticky="w", padx=(5, 0)) self.advanced_button = ttk.Button( self.command_frame, text="...", width=3, command=lambda: self._perform_pip_action("advanced"), ) self.advanced_button.grid(row=0, column=2, sticky="w", padx=(5, 0)) self.close_button = ttk.Button(info_frame, text=tr("Close"), command=self._on_close) self.close_button.grid(row=2, column=3, sticky="e")
def init_action_frame(self): super(Uf2FlashingDialog, self).init_action_frame() self._progress_bar["length"] = ems_to_pixels(10)