def __init__(self, master): ConfigurationPage.__init__(self, master) self._configuration_variable = create_string_var( get_workbench().get_option("run.backend_configuration")) entry_label = ttk.Label( self, text="Which interpreter to use for running programs?") entry_label.grid(row=0, column=0, columnspan=2, sticky=tk.W) self._entry = ttk.Combobox(self, exportselection=False, textvariable=self._configuration_variable, values=self._get_configurations()) self._entry.grid(row=1, column=0, columnspan=2, sticky=tk.NSEW) self._entry.state(['!disabled', 'readonly']) another_label = ttk.Label(self, text="Your interpreter isn't in the list?") another_label.grid(row=2, column=0, columnspan=2, sticky=tk.W, pady=(10, 0)) self._select_button = ttk.Button( self, text="Locate another executable " + ("(pythonw.exe) ..." if running_on_windows() else "(python3) ..."), command=self._select_executable) self._select_button.grid(row=3, column=0, columnspan=2, sticky=tk.NSEW) self.columnconfigure(0, weight=1) self.columnconfigure(1, weight=1)
def __init__(self, master): ConfigurationPage.__init__(self, master) self._language_var = get_workbench().get_variable("general.language") self._language_label = ttk.Label(self, text=_("Language")) self._language_label.grid(row=7, column=0, sticky=tk.W, padx=(0, 10), pady=(10, 0)) languages = list(LANGUAGES_DICT.keys()) self._language_combo = ttk.Combobox( self, width=7, exportselection=False, textvariable=self._language_var, state="readonly", height=15, values=languages, ) self._language_combo.grid(row=7, column=1, sticky=tk.W, pady=(10, 0)) reopen_label = ttk.Label( self, text=_( "You must restart Thonny for language change to take effect."), font="BoldTkDefaultFont", ) reopen_label.grid(row=20, column=0, sticky=tk.W, pady=20, columnspan=2) self.columnconfigure(1, weight=1)
def __init__(self, master): ConfigurationPage.__init__(self, master) self.columnconfigure(1, weight=1) max_lines_var = get_workbench().get_variable("shell.max_lines") max_lines_label = ttk.Label( self, text=_("Maximum number of lines to keep.\n" + "NB! Large values may cause poor performance!"), ) max_lines_label.grid(row=20, column=0, sticky=tk.W) max_lines_combo = ttk.Combobox( self, width=9, exportselection=False, textvariable=max_lines_var, state="readonly", values=[100, 500, 1000, 5000, 10000, 50000, 100000], ) max_lines_combo.grid(row=20, column=1, sticky=tk.W, padx=10) squeeze_var = get_workbench().get_variable("shell.squeeze_threshold") squeeze_label = ttk.Label( self, text="Maximum length of line fragments before squeezing") squeeze_label.grid(row=22, column=0, sticky="w") squeeze_combo = ttk.Combobox( self, width=9, exportselection=False, textvariable=squeeze_var, state="readonly", values=[500, 1000, 1500, 2000, 3000, 4000, 5000, 10000], ) squeeze_combo.grid(row=22, column=1, sticky=tk.W, padx=10, pady=10)
def __init__(self, master): ConfigurationPage.__init__(self, master) soft_max_chars_var = get_workbench().get_variable( "shell.soft_max_chars") label = ttk.Label( self, text= _("Preferred size of output history (scroll buffer) in characters.\n" + "This does not constrain last block, which is always shown in full.\n" + "NB! Larger values may cause poor performance!"), ) label.grid(row=20, column=0, sticky=tk.W) self._line_length_combo = ttk.Combobox( self, width=9, exportselection=False, textvariable=soft_max_chars_var, state="readonly", values=[1000, 5000, 10000, 50000, 100000, 500000, 1000000], ) self._line_length_combo.grid(row=20, column=1, sticky=tk.W, padx=10) self.columnconfigure(1, weight=1)
def __init__(self, master): ConfigurationPage.__init__(self, master) try: self.add_checkbox("view.name_highlighting", "Highlight matching names") except: # name matcher may have been disabled logging.warning("Couldn't create name matcher checkbox") try: self.add_checkbox("view.locals_highlighting", "Highlight local variables") except: # locals highlighter may have been disabled logging.warning("Couldn't create name locals highlighter checkbox") self.add_checkbox("view.paren_highlighting", "Highlight parentheses") self.add_checkbox("view.syntax_coloring", "Highlight syntax elements") self.add_checkbox("edit.tab_complete_in_editor", "Allow code completion with Tab-key in editors", columnspan=2, pady=(20,0), ) self.add_checkbox("edit.tab_complete_in_shell", "Allow code completion with Tab-key in Shell", columnspan=2) self.add_checkbox("view.show_line_numbers", "Show line numbers", pady=(20,0)) self._line_length_var = get_workbench().get_variable("view.recommended_line_length") label = ttk.Label(self, text="Recommended maximum line length\n(Set to 0 to turn off margin line)") label.grid(row=7, 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=7, column=1, sticky=tk.E) self.columnconfigure(0, weight=1)
def __init__(self, master): ConfigurationPage.__init__(self, master) self.columnconfigure(1, weight=1) self.add_checkbox( "shell.tty_mode", tr("Terminal emulation") + " (" + tr("supports basic ANSI-colors and styles") + ", \\a, \\r, \\b)", 10, 0, columnspan=2, pady=(0, 10), ) max_lines_var = get_workbench().get_variable("shell.max_lines") max_lines_label = ttk.Label( self, text=tr( tr("Maximum number of lines to keep.") + "\n" + tr("NB! Large values may cause poor performance!") ), ) max_lines_label.grid(row=20, column=0, sticky=tk.W) max_lines_combo = ttk.Combobox( self, width=9, exportselection=False, textvariable=max_lines_var, state="readonly", values=[100, 500, 1000, 5000, 10000, 50000, 100000], ) max_lines_combo.grid(row=20, column=1, sticky=tk.W, padx=10) squeeze_var = get_workbench().get_variable("shell.squeeze_threshold") squeeze_label = ttk.Label( self, text=tr("Maximum length of line fragments before squeezing") ) squeeze_label.grid(row=22, column=0, sticky="w") squeeze_combo = ttk.Combobox( self, width=9, exportselection=False, textvariable=squeeze_var, state="readonly", values=[500, 1000, 1500, 2000, 3000, 4000, 5000, 10000], ) squeeze_combo.grid(row=22, column=1, sticky=tk.W, padx=10, pady=10) self.add_checkbox( "shell.auto_inspect_values", tr("Open evaluated values in Object inspector"), 30, 0, columnspan=2, pady=(0, 10), )
def __init__(self, master): ConfigurationPage.__init__(self, master) ttk.Label(self, text="EV3 connection settings").pack(side=tk.TOP, padx=5, pady=(5,30)) workbench=get_workbench() for name in ('ip','username','password'): self.__dict__[name]=create_string_var(workbench.get_option("ev3."+name)) self.makeentry( "IP address:", self.ip, width=10) self.makeentry( "User name:", self.username, width=10) self.makeentry( "Password:"******"*")
def __init__(self, master): ConfigurationPage.__init__(self, master) self._backend_specs_by_desc = { spec.description: spec for spec in get_workbench().get_backends().values() } self._conf_pages = {} self._current_page = None current_backend_name = get_workbench().get_option("run.backend_name") try: current_backend_desc = get_workbench().get_backends( )[current_backend_name].description except KeyError: current_backend_desc = "" self._combo_variable = create_string_var(current_backend_desc) label = ttk.Label( self, text=tr( "Which interpreter or device should Thonny use for running your code?" )) label.grid(row=0, column=0, columnspan=2, sticky=tk.W) sorted_backend_specs = sorted(self._backend_specs_by_desc.values(), key=lambda x: x.sort_key) self._combo = ttk.Combobox( self, exportselection=False, textvariable=self._combo_variable, values=[spec.description for spec in sorted_backend_specs], height=25, ) self._combo.grid(row=1, column=0, columnspan=2, sticky=tk.NSEW, pady=(0, 10)) self._combo.state(["!disabled", "readonly"]) self.labelframe = ttk.LabelFrame(self, text=" " + tr("Details") + " ") self.labelframe.grid(row=2, column=0, sticky="nsew") self.labelframe.columnconfigure(0, weight=1) self.labelframe.rowconfigure(0, weight=1) self.columnconfigure(0, weight=1) self.rowconfigure(2, weight=1) self._combo_variable.trace("w", self._backend_changed) self._backend_changed()
def __init__(self, master): ConfigurationPage.__init__(self, master) self._family_variable = create_string_var( get_workbench().get_option("view.editor_font_family"), modification_listener=self._update_preview_font) self._size_variable = create_string_var( get_workbench().get_option("view.editor_font_size"), modification_listener=self._update_preview_font) ttk.Label(self, text="Editor font").grid(row=0, column=0, sticky="w") self._family_combo = ttk.Combobox(self, exportselection=False, state='readonly', textvariable=self._family_variable, values=self._get_families_to_show()) self._family_combo.grid(row=1, column=0, sticky=tk.NSEW, padx=(0,10)) ttk.Label(self, text="Size").grid(row=0, column=1, sticky="w") self._size_combo = ttk.Combobox(self, width=4, exportselection=False, textvariable=self._size_variable, state='readonly', values=[str(x) for x in range(3,73)]) self._size_combo.grid(row=1, column=1) ttk.Label(self, text="Preview").grid(row=2, column=0, sticky="w", pady=(10,0)) self._preview_font = tk_font.Font() self._preview_text = tk.Text(self, height=10, borderwidth=1, font=self._preview_font, wrap=tk.WORD) self._preview_text.insert("1.0", textwrap.dedent(""" The quick brown fox jumps over the lazy dog ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 1234567890 @$%()[]{}/\_-+ "Hello " + 'world!'""").strip()) self._preview_text.grid(row=3, column=0, columnspan=2, sticky=tk.NSEW, pady=(0,5)) self.columnconfigure(0, weight=1) self.rowconfigure(3, weight=1) self._update_preview_font()
def __init__(self, master): ConfigurationPage.__init__(self, master) self._init_themes() self._init_fonts() self._init_previews() self.columnconfigure(2, weight=1) self.columnconfigure(4, weight=1) self.rowconfigure(31, weight=1) self.rowconfigure(21, weight=1)
def __init__(self, master): ConfigurationPage.__init__(self, master) self.add_checkbox("view.name_highlighting", "Highlight matching names") self.add_checkbox("view.locals_highlighting", "Highlight local variables") self.add_checkbox("view.paren_highlighting", "Highlight parentheses") self.add_checkbox("view.syntax_coloring", "Highlight syntax elements") self.add_checkbox("view.show_line_numbers", "Show line numbers", pady=(20,0)) self._line_length_var = get_workbench().get_variable("view.recommended_line_length") label = ttk.Label(self, text="Recommended maximum line length\n(Set to 0 to turn off margin line)") label.grid(row=7, 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=7, column=1, sticky=tk.E) self.columnconfigure(0, weight=1)
def apply(self): ConfigurationPage.apply(self) get_workbench().get_editor_notebook().update_appearance()
def __init__(self, master): ConfigurationPage.__init__(self, master) self.add_checkbox("general.single_instance", tr("Allow only single Thonny instance"), row=1, columnspan=2) self.add_checkbox("general.event_logging", tr("Log program usage events"), row=4, columnspan=2) self.add_checkbox( "file.reopen_all_files", tr("Reopen all files from previous session"), row=5, columnspan=2, ) self.add_checkbox( "general.disable_notification_sound", tr("Disable notification sound"), row=6, columnspan=2, ) self.add_checkbox( "general.debug_mode", tr("Debug mode (provides more detailed diagnostic logs)"), row=7, columnspan=2, ) # language self._language_name_var = tk.StringVar( value=languages.LANGUAGES_DICT.get( get_workbench().get_option("general.language"), "")) self._language_label = ttk.Label(self, text=tr("Language")) self._language_label.grid(row=10, column=0, sticky=tk.W, padx=(0, 10), pady=(10, 0)) self._language_combo = ttk.Combobox( self, width=20, exportselection=False, textvariable=self._language_name_var, state="readonly", height=15, values=list(languages.LANGUAGES_DICT.values()), ) self._language_combo.grid(row=10, column=1, sticky=tk.W, pady=(10, 0)) # Mode ttk.Label(self, text=tr("UI mode")).grid(row=20, column=0, sticky=tk.W, padx=(0, 10), pady=(10, 0)) self.add_combobox( "general.ui_mode", ["simple", "regular", "expert"], row=20, column=1, pady=(10, 0), width=10, ) # scaling self._scaling_label = ttk.Label(self, text=tr("UI scaling factor")) self._scaling_label.grid(row=30, column=0, sticky=tk.W, padx=(0, 10), pady=(10, 0)) scalings = ["default"] + sorted( {0.5, 0.75, 1.0, 1.25, 1.33, 1.5, 2.0, 2.5, 3.0, 4.0}) self.add_combobox("general.scaling", scalings, row=30, column=1, pady=(10, 0), width=10) self._font_scaling_var = get_workbench().get_variable( "general.font_scaling_mode") self._font_scaling_label = ttk.Label(self, text=tr("Font scaling mode")) self._font_scaling_label.grid(row=40, column=0, sticky=tk.W, padx=(0, 10), pady=(10, 0)) self.add_combobox( "general.font_scaling_mode", ["default", "extra", "automatic"], row=40, column=1, pady=(10, 0), width=10, ) reopen_label = ttk.Label( self, text=tr("NB! Restart Thonny after changing these options!"), font="BoldTkDefaultFont", ) reopen_label.grid(row=100, column=0, sticky=tk.W, pady=20, columnspan=2) self.columnconfigure(1, weight=1)
def __init__(self, master): ConfigurationPage.__init__(self, master) self.add_checkbox( "general.single_instance", _("Allow only single Thonny instance"), row=1, columnspan=2, ) self.add_checkbox( "general.debug_mode", _("Debug mode (provides more detailed logs)"), row=3, columnspan=2, ) self.add_checkbox( "file.reopen_all_files", _("Reopen all files from previous session"), row=4, columnspan=2, ) self.add_checkbox( "general.disable_notification_sound", _("Disable notification sound"), row=5, columnspan=2, ) ttk.Label(self, text="UI mode").grid(row=6, column=0, sticky=tk.W, padx=(0, 10), pady=(10, 0)) self.add_combobox( "general.ui_mode", ["simple", "regular", "expert"], row=6, column=1, pady=(10, 0), ) self._scaling_var = get_workbench().get_variable("general.scaling") self._scaling_label = ttk.Label(self, text="UI scaling factor") self._scaling_label.grid(row=7, column=0, sticky=tk.W, padx=(0, 10), pady=(10, 0)) scalings = sorted( {0.5, 0.75, 1.0, 1.25, 1.33, 1.5, 2.0, 2.5, 3.0, 4.0}) self._scaling_combo = ttk.Combobox( self, width=7, exportselection=False, textvariable=self._scaling_var, state="readonly", height=15, values=["default"] + scalings, ) self._scaling_combo.grid(row=7, column=1, sticky=tk.W, pady=(10, 0)) self._font_scaling_var = get_workbench().get_variable( "general.font_scaling_mode") self._font_scaling_label = ttk.Label(self, text=_("Font scaling mode")) self._font_scaling_label.grid(row=8, column=0, sticky=tk.W, padx=(0, 10), pady=(10, 0)) scalings = sorted( {0.5, 0.75, 1.0, 1.25, 1.33, 1.5, 2.0, 2.5, 3.0, 4.0}) self._font_scaling_combo = ttk.Combobox( self, width=10, exportselection=False, textvariable=self._font_scaling_var, state="readonly", height=15, values=["default", "extra", "automatic"], ) self._font_scaling_combo.grid(row=8, column=1, sticky=tk.W, pady=(10, 0)) reopen_label = ttk.Label( self, text=_("NB! Restart Thonny after changing these options" + "\nin order to see the full effect"), font="BoldTkDefaultFont", ) reopen_label.grid(row=20, column=0, sticky=tk.W, pady=20, columnspan=2) self.columnconfigure(1, weight=1)
def __init__(self, master): ConfigurationPage.__init__(self, master) self.add_checkbox("general.single_instance", tr("Allow only single Thonny instance"), row=1, columnspan=2) self.add_checkbox("general.event_logging", tr("Log program usage events"), row=4, columnspan=2) self.add_checkbox( "file.reopen_all_files", tr("Reopen all files from previous session"), row=5, columnspan=2, ) if running_on_linux(): self.add_checkbox( "file.avoid_zenity", tr("Use Tk file dialogs instead of Zenity"), tooltip=tr( "Select if the file dialogs end up behind the main window" ), row=6, columnspan=2, ) self.add_checkbox( "general.disable_notification_sound", tr("Disable notification sound"), row=7, columnspan=2, ) self.add_checkbox( "general.debug_mode", tr("Debug mode (provides more detailed diagnostic logs)"), row=8, columnspan=2, ) # language self._language_name_var = tk.StringVar( value=languages.LANGUAGES_DICT.get( get_workbench().get_option("general.language"), "")) self._language_label = ttk.Label(self, text=tr("Language")) self._language_label.grid(row=10, column=0, sticky=tk.W, padx=(0, 10), pady=(10, 0)) self._language_combo = ttk.Combobox( self, width=20, exportselection=False, textvariable=self._language_name_var, state="readonly", height=15, values=list(languages.LANGUAGES_DICT.values()), ) self._language_combo.grid(row=10, column=1, sticky=tk.W, pady=(10, 0)) # Mode ttk.Label(self, text=tr("UI mode")).grid(row=20, column=0, sticky=tk.W, padx=(0, 10), pady=(10, 0)) self.add_combobox( "general.ui_mode", ["simple", "regular", "expert"], row=20, column=1, pady=(10, 0), width=10, ) # scaling self._scaling_label = ttk.Label(self, text=tr("UI scaling factor")) self._scaling_label.grid(row=30, column=0, sticky=tk.W, padx=(0, 10), pady=(10, 0)) scalings = ["default"] + sorted( {0.5, 0.75, 1.0, 1.25, 1.33, 1.5, 2.0, 2.5, 3.0, 4.0}) self.add_combobox("general.scaling", scalings, row=30, column=1, pady=(10, 0), width=10) self._font_scaling_var = get_workbench().get_variable( "general.font_scaling_mode") self._font_scaling_label = ttk.Label(self, text=tr("Font scaling mode")) self._font_scaling_label.grid(row=40, column=0, sticky=tk.W, padx=(0, 10), pady=(10, 0)) self.add_combobox( "general.font_scaling_mode", ["default", "extra", "automatic"], row=40, column=1, pady=(10, 0), width=10, ) env_label = ttk.Label( self, text=tr("Environment variables (one KEY=VALUE per line)")) env_label.grid(row=90, column=0, sticky=tk.W, pady=(20, 0), columnspan=2) self.env_box = tktextext.TextFrame(self, horizontal_scrollbar=False, height=4, borderwidth=1, undo=True, wrap="none") self.env_box.grid(row=100, column=0, sticky="nsew", pady=(0, 10), columnspan=2) for entry in get_workbench().get_option("general.environment"): self.env_box.text.insert("end", entry + "\n") reopen_label = ttk.Label( self, text=tr("NB! Restart Thonny after changing these options!"), font="BoldTkDefaultFont", ) reopen_label.grid(row=110, column=0, sticky="sw", pady=(20, 0), columnspan=2) self.columnconfigure(1, weight=1) self.rowconfigure(100, weight=1)
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): self._original_family = get_workbench().get_option( "view.editor_font_family") self._original_size = get_workbench().get_option( "view.editor_font_size") self._original_ui_theme = get_workbench().get_option("view.ui_theme") self._original_syntax_theme = get_workbench().get_option( "view.syntax_theme") self._original_io_family = get_workbench().get_option( "view.io_font_family") self._original_io_size = get_workbench().get_option( "view.io_font_size") ConfigurationPage.__init__(self, master) self._family_variable = create_string_var( self._original_family, modification_listener=self._update_appearance) self._size_variable = create_string_var( self._original_size, modification_listener=self._update_appearance) self._ui_theme_variable = create_string_var( self._original_ui_theme, modification_listener=self._update_appearance) self._syntax_theme_variable = create_string_var( self._original_syntax_theme, modification_listener=self._update_appearance) self._io_family_variable = create_string_var( self._original_io_family, modification_listener=self._update_appearance) self._io_size_variable = create_string_var( self._original_io_size, modification_listener=self._update_appearance) ttk.Label(self, text="UI theme").grid(row=1, column=0, sticky="w", pady=(10, 0)) self._ui_theme_combo = ttk.Combobox( self, exportselection=False, textvariable=self._ui_theme_variable, state="readonly", height=15, values=get_workbench().get_usable_ui_theme_names(), ) self._ui_theme_combo.grid(row=2, column=0, sticky="nsew", padx=(0, 10)) ttk.Label(self, text="Syntax theme").grid(row=1, column=1, sticky="w", pady=(10, 0)) self._syntax_theme_combo = ttk.Combobox( self, exportselection=False, textvariable=self._syntax_theme_variable, state="readonly", height=15, values=get_workbench().get_syntax_theme_names(), ) self._syntax_theme_combo.grid(row=2, column=1, sticky="nsew", padx=(0, 10)) ttk.Label(self, text="Editor font").grid(row=1, column=2, sticky="w", pady=(10, 0)) self._family_combo = ttk.Combobox( self, exportselection=False, state="readonly", height=15, textvariable=self._family_variable, values=self._get_families_to_show(), ) self._family_combo.grid(row=2, column=2, sticky=tk.NSEW, padx=(0, 10)) ttk.Label(self, text="Size").grid(row=1, column=3, sticky="w", pady=(10, 0)) self._size_combo = ttk.Combobox( self, width=4, exportselection=False, textvariable=self._size_variable, state="readonly", height=15, values=[str(x) for x in range(3, 73)], ) self._size_combo.grid(row=2, column=3, sticky="nsew") ttk.Label(self, text="Editor preview").grid(row=3, column=0, sticky="w", pady=(10, 0), columnspan=4) self._preview_codeview = CodeView( self, height=6, font="EditorFont", # relief="sunken", # borderwidth=1, ) self._preview_codeview.set_content( textwrap.dedent(""" def foo(bar): if bar is None: # This is a comment print("The answer is", 33) unclosed_string = "blah, blah """).strip()) self._preview_codeview.grid(row=4, column=0, columnspan=4, sticky=tk.NSEW, pady=(0, 5)) ttk.Label(self, text="Shell font").grid(row=5, column=2, sticky="w", pady=(10, 0)) self._family_combo = ttk.Combobox( self, exportselection=False, state="readonly", height=15, textvariable=self._io_family_variable, values=self._get_families_to_show(), ) self._family_combo.grid(row=6, column=2, sticky=tk.NSEW, padx=(0, 10)) ttk.Label(self, text="Size").grid(row=5, column=3, sticky="w", pady=(10, 0)) self._size_combo = ttk.Combobox( self, width=4, exportselection=False, textvariable=self._io_size_variable, state="readonly", height=15, values=[str(x) for x in range(3, 73)], ) self._size_combo.grid(row=6, column=3, sticky="nsew") ttk.Label(self, text="Shell preview").grid(row=7, column=0, sticky="w", pady=(10, 0), columnspan=4) self._shell_preview = tk.Text(self, height=3) self._shell_preview.grid(row=8, column=0, columnspan=4, sticky=tk.NSEW, pady=(0, 5)) self._insert_shell_text() ttk.Label( self, text="NB! Some style elements change only after restarting Thonny" ).grid(row=9, column=0, columnspan=4, sticky="w", pady=(0, 5)) self.columnconfigure(0, weight=1) self.columnconfigure(1, weight=1) self.columnconfigure(2, weight=1) self.columnconfigure(3, weight=1)
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)