def load_plugin() -> None: get_workbench().add_command( "toggle_comment", "edit", "Toggle comment", _cmd_toggle_selection_comment, default_sequence=select_sequence("<Control-Key-3>", "<Command-Key-3>"), tester=_writable_text_is_focused, group=50, ) get_workbench().add_command( "comment_selection", "edit", "Comment out", _cmd_comment_selection, default_sequence="<Alt-Key-3>", tester=_writable_text_is_focused, group=50, ) get_workbench().add_command( "uncomment_selection", "edit", "Uncomment", _cmd_uncomment_selection, default_sequence="<Alt-Key-4>", tester=_writable_text_is_focused, group=50, )
def load_plugin() -> None: def cmd_open_find_dialog(): if _active_find_dialog is not None: _active_find_dialog.focus_set() else: editor = get_workbench().get_editor_notebook().get_current_editor() if editor: FindDialog(editor._code_view) def find_f3(event): if _active_find_dialog is None: cmd_open_find_dialog() else: _active_find_dialog._perform_find(event) get_workbench().add_command( "OpenFindDialog", "edit", _("Find & Replace"), cmd_open_find_dialog, default_sequence=select_sequence("<Control-f>", "<Command-f>"), extra_sequences=["<Control-Greek_phi>"], ) get_workbench().bind("<F3>", find_f3, True)
def load_plugin() -> None: get_workbench().add_command( "indent", "edit", tr("Indent selected lines"), _cmd_indent_selection, tester=_writable_text_is_focused, accelerator="Tab", group=49, ) get_workbench().add_command( "dedent", "edit", tr("Dedent selected lines"), _cmd_dedent_selection, tester=_writable_text_is_focused, accelerator="Shift+Tab", group=49, ) get_workbench().add_command( "replace_tabs", "edit", tr("Replace tabs with spaces"), _cmd_replace_tabs, tester=_writable_text_is_focused, group=49, ) get_workbench().add_command( "toggle_comment", "edit", tr("Toggle comment"), _cmd_toggle_selection_comment, default_sequence=select_sequence("<Control-Key-3>", "<Command-Key-3>"), tester=_writable_text_is_focused, group=50, ) get_workbench().add_command( "comment_selection", "edit", tr("Comment out"), _cmd_comment_selection, default_sequence="<Alt-Key-3>", tester=_writable_text_is_focused, group=50, ) get_workbench().add_command( "uncomment_selection", "edit", tr("Uncomment"), _cmd_uncomment_selection, default_sequence="<Alt-Key-4>", tester=_writable_text_is_focused, group=50, )
def _init_commands(self) -> None: get_workbench().set_default("run.run_in_terminal_python_repl", False) get_workbench().set_default("run.run_in_terminal_keep_open", True) get_workbench().add_command( "run_current_script", "run", "Run current script", caption="Run", handler=self._cmd_run_current_script, default_sequence="<F5>", extra_sequences=[select_sequence("<Control-r>", "<Command-r>")], tester=self._cmd_run_current_script_enabled, group=10, image="run-current-script", include_in_toolbar=True, show_extra_sequences=True, ) get_workbench().add_command( "run_current_script_in_terminal", "run", "Run current script in terminal", caption="RunT", handler=self._cmd_run_current_script_in_terminal, default_sequence="<Control-t>", extra_sequences=["<<CtrlTInText>>"], tester=self._cmd_run_current_script_in_terminal_enabled, group=35, image="terminal", ) get_workbench().add_command( "restart", "run", "Stop/Restart backend", caption="Stop", handler=self.cmd_stop_restart, default_sequence="<Control-F2>", group=70, image="stop", include_in_toolbar=True, ) get_workbench().add_command( "interrupt", "run", "Interrupt execution", handler=self._cmd_interrupt, tester=self._cmd_interrupt_enabled, default_sequence="<Control-c>", group=70, bell_when_denied=False, )
def load_plugin(): get_workbench().add_command( "printcurrent", "file", tr("Print..."), print_current_script, can_print_current_script, default_sequence=select_sequence("<Control-p>", "<Command-p>"), extra_sequences=["<Control-Greek_pi>"], group=11, )
def _init_commands(self): get_workbench().add_command( "debug", "run", "Debug current script", self._cmd_debug_current_script, tester=self._cmd_debug_current_script_enabled, default_sequence="<Control-F5>", group=10, image_filename="run.debug_current_script.gif", include_in_toolbar=True) get_workbench().add_command("step_over", "run", "Step over", self._cmd_step_over, tester=self._cmd_stepping_commands_enabled, default_sequence="<F6>", group=30, image_filename="run.step_over.gif", include_in_toolbar=True) get_workbench().add_command("step_into", "run", "Step into", self._cmd_step_into, tester=self._cmd_stepping_commands_enabled, default_sequence="<F7>", group=30, image_filename="run.step_into.gif", include_in_toolbar=True) get_workbench().add_command("step_out", "run", "Step out", self._cmd_step_out, tester=self._cmd_stepping_commands_enabled, default_sequence="<F8>", group=30, image_filename="run.step_out.gif", include_in_toolbar=True) get_workbench().add_command("run_to_cursor", "run", "Run to cursor", self._cmd_run_to_cursor, tester=self._cmd_run_to_cursor_enabled, default_sequence=select_sequence( "<Control-F8>", "<Control-F8>"), group=30, image_filename="run.run_to_cursor.gif", include_in_toolbar=False)
def load_plugin(): image_path = os.path.join(os.path.dirname(__file__), "res", "tools.program_edison.png") get_workbench().add_command("program_edison", "tools", "Send current script to Edison", program_edison, program_edison_enabled, default_sequence=select_sequence( "<Control-e>", "<Command-e>"), group=120, image=image_path, caption="Program Edison", include_in_toolbar=True)
def load_plugin(): def cmd_open_find_dialog(): if _active_find_dialog is not None: _active_find_dialog.focus_set() else: editor = get_workbench().get_editor_notebook().get_current_editor() if editor: FindDialog(editor._code_view) get_workbench().add_command("OpenFindDialog", "edit", 'Find & Replace', cmd_open_find_dialog, default_sequence=select_sequence( "<Control-f>", "<Command-f>"))
def _init_commands(self) -> None: global RUN_COMMAND_CAPTION, RUN_COMMAND_LABEL RUN_COMMAND_LABEL = _("Run current script") RUN_COMMAND_CAPTION = _("Run") get_workbench().set_default("run.run_in_terminal_python_repl", False) get_workbench().set_default("run.run_in_terminal_keep_open", True) try: import thonny.plugins.debugger # @UnusedImport debugger_available = True except ImportError: debugger_available = False get_workbench().add_command( "run_current_script", "run", RUN_COMMAND_LABEL, caption=RUN_COMMAND_CAPTION, handler=self.cmd_run_current_script, default_sequence="<F5>", extra_sequences=[select_sequence("<Control-r>", "<Command-r>")], tester=self.cmd_run_current_script_enabled, group=10, image="run-current-script", include_in_toolbar=not (get_workbench().in_simple_mode() and debugger_available), show_extra_sequences=True, ) get_workbench().add_command( "run_current_script_in_terminal", "run", "Run current script in terminal", caption="RunT", handler=self._cmd_run_current_script_in_terminal, default_sequence="<Control-t>", extra_sequences=["<<CtrlTInText>>"], tester=self._cmd_run_current_script_in_terminal_enabled, group=35, image="terminal", ) get_workbench().add_command( "restart", "run", "Stop/Restart backend", caption="Stop", handler=self.cmd_stop_restart, default_sequence="<Control-F2>", group=70, image="stop", include_in_toolbar=True, ) get_workbench().add_command( "interrupt", "run", "Interrupt execution", handler=self._cmd_interrupt, tester=self._cmd_interrupt_enabled, default_sequence="<Control-c>", group=70, bell_when_denied=False, )
def _init_commands(self): # TODO: do these commands have to be in EditorNotebook ?? # Create a module level function install_editor_notebook ?? # Maybe add them separately, when notebook has been installed ?? get_workbench().add_command("new_file", "file", "New", self._cmd_new_file, default_sequence=select_sequence( "<Control-n>", "<Command-n>"), group=10, image_filename="file.new_file.gif", include_in_toolbar=True) get_workbench().add_command("open_file", "file", "Open...", self._cmd_open_file, default_sequence=select_sequence( "<Control-o>", "<Command-o>"), group=10, image_filename="file.open_file.gif", include_in_toolbar=True) # http://stackoverflow.com/questions/22907200/remap-default-keybinding-in-tkinter get_workbench().bind_class("Text", "<Control-o>", self._control_o) rebind_control_a(get_workbench()) get_workbench().add_command( "close_file", "file", "Close", self._cmd_close_file, default_sequence=select_sequence("<Control-w>", "<Command-w>"), tester=lambda: self.get_current_editor() is not None, group=10) get_workbench().add_command( "close_files", "file", "Close all", self._cmd_close_files, tester=lambda: self.get_current_editor() is not None, group=10) get_workbench().add_command("save_file", "file", "Save", self._cmd_save_file, default_sequence=select_sequence( "<Control-s>", "<Command-s>"), tester=self._cmd_save_file_enabled, group=10, image_filename="file.save_file.gif", include_in_toolbar=True) get_workbench().add_command( "save_file_as", "file", "Save as...", self._cmd_save_file_as, default_sequence=select_sequence("<Control-Shift-S>", "<Command-Shift-S>"), tester=lambda: self.get_current_editor() is not None, group=10) get_workbench().createcommand("::tk::mac::OpenDocument", self._mac_open_document)
def _init_commands(self): self.add_command("exit", "file", "Exit", self._on_close, default_sequence=select_sequence( "<Alt-F4>", "<Command-q>")) self.add_command("show_options", "tools", "Options...", self._cmd_show_options, group=180) self.createcommand("::tk::mac::ShowPreferences", self._cmd_show_options) self.add_command("increase_font_size", "view", "Increase font size", lambda: self._change_font_size(1), default_sequence=select_sequence( "<Control-plus>", "<Command-Shift-plus>"), group=60) self.add_command("decrease_font_size", "view", "Decrease font size", lambda: self._change_font_size(-1), default_sequence=select_sequence( "<Control-minus>", "<Command-minus>"), group=60) self.bind("<Control-MouseWheel>", self._cmd_zoom_with_mouse, True) self.add_command("focus_editor", "view", "Focus editor", self._cmd_focus_editor, default_sequence="<Alt-e>", group=70) self.add_command("focus_shell", "view", "Focus shell", self._cmd_focus_shell, default_sequence="<Alt-s>", group=70) if self.get_option("general.expert_mode"): self.add_command("toggle_maximize_view", "view", "Maximize view", self._cmd_toggle_maximize_view, flag_name="view.maximize_view", default_sequence=None, group=80) self.bind_class("TNotebook", "<Double-Button-1>", self._maximize_view, True) self.bind("<Escape>", self._unmaximize_view, True) if not running_on_mac_os(): # TODO: approach working in Win/Linux doesn't work in mac as it should and only confuses self.add_command("toggle_maximize_view", "view", "Full screen", self._cmd_toggle_full_screen, flag_name="view.full_screen", default_sequence=select_sequence( "<F11>", "<Command-Shift-F>"), group=80)
def load_plugin(): def create_edit_command_handler(virtual_event_sequence): def handler(event=None): widget = get_workbench().focus_get() if widget: return widget.event_generate(virtual_event_sequence) return handler def select_all(event=None): # Tk 8.6 has <<SelectAll>> virtual event, but 8.5 doesn't widget = get_workbench().focus_get() if isinstance(widget, tk.Text): widget.tag_remove("sel", "1.0", "end") widget.tag_add("sel", "1.0", "end") elif isinstance(widget, ttk.Entry) or isinstance(widget, tk.Entry): widget.select_range(0, tk.END) get_workbench().add_command( "undo", "edit", "Undo", create_edit_command_handler("<<Undo>>"), tester=None, # TODO: default_sequence=select_sequence("<Control-z>", "<Command-z>"), skip_sequence_binding=True, group=10) get_workbench().add_command( "redo", "edit", "Redo", create_edit_command_handler("<<Redo>>"), tester=None, # TODO: default_sequence=select_sequence("<Control-y>", "<Command-y>"), skip_sequence_binding=True, group=10) # Ctrl+Shift+Z as alternative shortcut for redo get_workbench().bind_class( "Text", select_sequence("<Control-Shift-Z>", "<Command-Shift-Z>"), create_edit_command_handler("<<Redo>>"), True) get_workbench().add_command( "Cut", "edit", "Cut", create_edit_command_handler("<<Cut>>"), tester=None, # TODO: default_sequence=select_sequence("<Control-x>", "<Command-x>"), skip_sequence_binding=True, group=20) get_workbench().add_command( "Copy", "edit", "Copy", create_edit_command_handler("<<Copy>>"), tester=None, # TODO: default_sequence=select_sequence("<Control-c>", "<Command-c>"), skip_sequence_binding=True, group=20) get_workbench().add_command( "Paste", "edit", "Paste", create_edit_command_handler("<<Paste>>"), tester=None, # TODO: default_sequence=select_sequence("<Control-v>", "<Command-v>"), skip_sequence_binding=True, group=20) get_workbench().add_command( "SelectAll", "edit", "Select all", select_all, tester=None, # TODO: default_sequence=select_sequence("<Control-a>", "<Command-a>"), skip_sequence_binding=True, group=20)
def load_plugin() -> None: def create_edit_command_handler(virtual_event_sequence): def handler(event=None): widget = get_workbench().focus_get() if widget: return widget.event_generate(virtual_event_sequence) return None return handler def select_all(event=None): # Tk 8.6 has <<SelectAll>> virtual event, but 8.5 doesn't widget = get_workbench().focus_get() if isinstance(widget, tk.Text): widget.tag_remove("sel", "1.0", "end") widget.tag_add("sel", "1.0", "end") elif isinstance(widget, (ttk.Entry, tk.Entry)): widget.select_range(0, tk.END) get_workbench().add_command( "undo", "edit", _("Undo"), create_edit_command_handler("<<Undo>>"), tester=None, # TODO: default_sequence=select_sequence("<Control-z>", "<Command-z>"), extra_sequences=["<Control-Greek_zeta>"], skip_sequence_binding=True, group=10, ) get_workbench().add_command( "redo", "edit", _("Redo"), create_edit_command_handler("<<Redo>>"), tester=None, # TODO: default_sequence=select_sequence("<Control-y>", "<Command-y>"), extra_sequences=[ select_sequence("<Control-Shift-Z>", "<Command-Shift-Z>"), "<Control-Greek_upsilon>", "<Control-Shift-Greek_ZETA>", ], skip_sequence_binding=True, group=10, ) get_workbench().add_command( "Cut", "edit", _("Cut"), create_edit_command_handler("<<Cut>>"), tester=None, # TODO: default_sequence=select_sequence("<Control-x>", "<Command-x>"), extra_sequences=["<Control-Greek_chi>"], skip_sequence_binding=True, group=20, ) get_workbench().add_command( "Copy", "edit", _("Copy"), create_edit_command_handler("<<Copy>>"), tester=None, # TODO: default_sequence=select_sequence("<Control-c>", "<Command-c>"), extra_sequences=["<Control-Greek_psi>"], skip_sequence_binding=True, group=20, ) get_workbench().add_command( "Paste", "edit", _("Paste"), create_edit_command_handler("<<Paste>>"), tester=None, # TODO: default_sequence=select_sequence("<Control-v>", "<Command-v>"), extra_sequences=["<Control-Greek_omega>"], skip_sequence_binding=True, group=20, ) get_workbench().add_command( "SelectAll", "edit", _("Select all"), select_all, tester=None, # TODO: default_sequence=select_sequence("<Control-a>", "<Command-a>"), extra_sequences=["<Control-Greek_alpha>"], skip_sequence_binding=True, group=20, )
def _init_commands(self) -> None: global RUN_COMMAND_CAPTION, RUN_COMMAND_LABEL RUN_COMMAND_LABEL = tr("Run current script") RUN_COMMAND_CAPTION = tr("Run") get_workbench().set_default("run.run_in_terminal_python_repl", False) get_workbench().set_default("run.run_in_terminal_keep_open", True) try: import thonny.plugins.debugger # @UnusedImport debugger_available = True except ImportError: debugger_available = False get_workbench().add_command( "run_current_script", "run", RUN_COMMAND_LABEL, caption=RUN_COMMAND_CAPTION, handler=self.cmd_run_current_script, default_sequence="<F5>", extra_sequences=[select_sequence("<Control-r>", "<Command-r>")], tester=self.cmd_run_current_script_enabled, group=10, image="run-current-script", include_in_toolbar=not (get_workbench().in_simple_mode() and debugger_available), show_extra_sequences=True, ) get_workbench().add_command( "run_current_script_in_terminal", "run", tr("Run current script in terminal"), caption="RunT", handler=self._cmd_run_current_script_in_terminal, default_sequence="<Control-t>", extra_sequences=["<<CtrlTInText>>"], tester=self._cmd_run_current_script_in_terminal_enabled, group=35, image="terminal", ) get_workbench().add_command( "restart", "run", tr("Stop/Restart backend"), caption=tr("Stop"), handler=self.cmd_stop_restart, default_sequence="<Control-F2>", group=100, image="stop", include_in_toolbar=True, ) get_workbench().add_command( "interrupt", "run", tr("Interrupt execution"), handler=self._cmd_interrupt, tester=self._cmd_interrupt_enabled, default_sequence=INTERRUPT_SEQUENCE, skip_sequence_binding=True, # Sequence will be bound differently group=100, bell_when_denied=False, ) get_workbench().bind(INTERRUPT_SEQUENCE, self._cmd_interrupt_with_shortcut, True) get_workbench().add_command( "ctrld", "run", tr("Send EOF / Soft reboot"), self.ctrld, self.ctrld_enabled, group=100, default_sequence="<Control-d>", extra_sequences=["<<CtrlDInText>>"], ) get_workbench().add_command( "disconnect", "run", tr("Disconnect"), self.disconnect, self.disconnect_enabled, group=100, )
def load_plugin(): #No idea what the screenwidth condition does. I don't think it increases the screen size if get_workbench().get_ui_mode( ) == "simple" and get_workbench().winfo_screenwidth() >= 1280: images = { "run-current-script": "media-playback-start48.png", "stop": "process-stop48.png", "new-file": "document-new48.png", "open-file": "open_file.png", "save-file": "document-save48.png", "debug-current-script": "debug-run48.png", "step-over": "debug-step-over48.png", "step-into": "debug-step-into48.png", "step-out": "debug-step-out48.png", "run-to-cursor": "debug-run-cursor48.png", "tab-close": "window-close.png", "tab-close-active": "window-close-act.png", "resume": "resume48.png", "zoom": "zoom48.png", "quit": "quit48.png", } else: images = { "run-current-script": "media-playback-start.png", "stop": "process-stop.png", "new-file": "document-new.png", "open-file": "open_file.png", "save-file": "document-save.png", "debug-current-script": "debug-run.png", "step-over": "debug-step-over.png", "step-into": "debug-step-into.png", "step-out": "debug-step-out.png", "run-to-cursor": "debug-run-cursor.png", "tab-close": "window-close.png", "tab-close-active": "window-close-act.png", "resume": "resume.png", "zoom": "zoom.png", "quit": "quit.png", } #Change the types of input images depending on the image that is selected. res_dir = os.path.join(os.path.dirname(__file__), "res") theme_image_map = {} for image in images: theme_image_map[image] = os.path.join(res_dir, images[image]) #Create a given theme. Similar to Rasberry Pi but with modified buttons get_workbench().add_ui_theme("JuiceMind-Theme", "Enhanced Clam", pix, theme_image_map) #Set our theme equal to the default theme during the launch of the IDE get_workbench().set_option("view.ui_theme", startup_theme) micropython_image = os.path.join(res_dir, "MCU.png") computer_selected_image = os.path.join(res_dir, "computer_selected.png") connect_image = os.path.join(res_dir, "connect.png") transparent_background = os.path.join(res_dir, "transparent_background.png") #Set the initial backend to be default, normal computer #Change the backend to ESP8266 get_workbench().set_option("run.backend_name", "SameAsFrontend") ''' #Add a button to switch to MicroPython Interpreter get_workbench().add_command("Switch MicroPython", "tools", "Run with MicroPython", switch_to_microPython, default_sequence=select_sequence("<Control-e>", "<Command-e>"), group=120, tester=disable_MCU, image = micropython_image, caption="Use MicroPython", include_in_toolbar=True) ''' ''' #Add command on toolbar to implement regular Python Interpreter get_workbench().add_command("Switch Regular Python", "tools", "Run with Computer Python", switch_to_python, default_sequence=select_sequence("<Control-e>", "<Command-e>"), group=120, tester=disable_computer, image = computer_image, caption="Use Python", include_in_toolbar=True) ''' get_workbench().add_command("add_spacing", "tools", "", toggle_python, default_sequence=select_sequence( "<Control-e>", "<Command-e>"), group=120, tester=always_disabled, image=transparent_background, caption="Use Python", include_in_toolbar=True, include_in_menu=False) #One command on the toolbar that toggles between Python image and microcontroller image get_workbench().add_command("toggle_python", "tools", "Toggle Python", toggle_python, default_sequence=select_sequence( "<Control-e>", "<Command-e>"), group=120, tester=always_enabled, image=computer_selected_image, caption="Use Python", include_in_toolbar=True) #Add command on toolbar to connect get_workbench().add_command("connect_button", "tools", "", connect_device, default_sequence=select_sequence( "<Control-e>", "<Command-e>"), group=120, tester=test_connection, image=connect_image, caption="Connect Button", include_in_toolbar=True)
def load_plugin() -> None: get_workbench().set_default("debugger.single_window", False) get_workbench().set_default("debugger.automatic_stack_view", True) get_workbench().add_command( "debug", "run", "Debug current script (nicer)", lambda: _request_debug("Debug"), caption="Debug", tester=_start_debug_enabled, default_sequence="<Control-F5>", group=10, image="debug-current-script", include_in_toolbar=True, ) get_workbench().add_command( "debuglite", "run", "Debug current script (faster)", lambda: _request_debug("FastDebug"), caption="Fast-debug", tester=_start_debug_enabled, default_sequence="<Shift-F5>", group=10, ) get_workbench().add_command( "step_over", "run", "Step over", lambda: _issue_debugger_command("step_over"), caption="Over", tester=lambda: _debugger_command_enabled("step_over"), default_sequence="<F6>", group=30, image="step-over", include_in_toolbar=True, ) get_workbench().add_command( "step_into", "run", "Step into", lambda: _issue_debugger_command("step_into"), caption="Into", tester=lambda: _debugger_command_enabled("step_into"), default_sequence="<F7>", group=30, image="step-into", include_in_toolbar=True, ) get_workbench().add_command( "step_out", "run", "Step out", lambda: _issue_debugger_command("step_out"), caption="Out", tester=lambda: _debugger_command_enabled("step_out"), group=30, image="step-out", include_in_toolbar=True, ) get_workbench().add_command( "resume", "run", "Resume", lambda: _issue_debugger_command("resume"), caption="Resume", tester=lambda: _debugger_command_enabled("resume"), default_sequence="<F8>", group=30, image="resume", include_in_toolbar=True, ) get_workbench().add_command( "run_to_cursor", "run", "Run to cursor", lambda: _issue_debugger_command("run_to_cursor"), tester=lambda: _debugger_command_enabled("run_to_cursor"), default_sequence=select_sequence("<Control-F8>", "<Control-F8>"), group=30, image="run-to-cursor", include_in_toolbar=False, ) get_workbench().add_command( "step_back", "run", "Step back", lambda: _issue_debugger_command("step_back"), caption="Back", tester=lambda: _debugger_command_enabled("step_back"), default_sequence=select_sequence("<Control-b>", "<Command-b>"), group=30, ) get_workbench().add_view(StackView, "Stack", "se") get_workbench().add_view(ExceptionView, "Exception", "s") get_workbench().add_configuration_page("Debugger", DebuggerConfigurationPage) get_workbench().bind("DebuggerResponse", _handle_debugger_progress, True) get_workbench().bind("ToplevelResponse", _handle_toplevel_response, True) get_workbench().bind("CommandAccepted", _debug_accepted, True)
from thonny import get_runner, get_workbench, memory, roughparse, ui_utils from thonny.codeview import PythonText, get_syntax_options_for_tag from thonny.common import InlineCommand, ToplevelCommand, ToplevelResponse from thonny.misc_utils import ( construct_cmd_line, parse_cmd_line, running_on_mac_os, shorten_repr, ) from thonny.tktextext import index2line from thonny.ui_utils import (EnhancedTextWithLogging, get_style_configuration, scrollbar_style, sequence_to_accelerator, select_sequence, TextMenu) from _tkinter import TclError _CLEAR_SHELL_DEFAULT_SEQ = select_sequence("<Control-l>", "<Command-k>") class ShellView(ttk.Frame): def __init__(self, master, **kw): ttk.Frame.__init__(self, master, **kw) self.vert_scrollbar = ttk.Scrollbar(self, orient=tk.VERTICAL, style=scrollbar_style("Vertical")) self.vert_scrollbar.grid(row=1, column=2, sticky=tk.NSEW) get_workbench().add_command( "clear_shell", "edit", "Clear shell", self.clear_shell,
def _init_commands(self): # TODO: do these commands have to be in EditorNotebook ?? # Create a module level function install_editor_notebook ?? # Maybe add them separately, when notebook has been installed ?? get_workbench().add_command( "new_file", "file", tr("New"), self._cmd_new_file, caption=tr("New"), default_sequence=select_sequence("<Control-n>", "<Command-n>"), extra_sequences=["<Control-Greek_nu>"], group=10, image="new-file", include_in_toolbar=True, ) get_workbench().add_command( "open_file", "file", tr("Open..."), self._cmd_open_file, caption=tr("Load"), default_sequence=select_sequence("<Control-o>", "<Command-o>"), extra_sequences=["<Control-Greek_omicron>"], group=10, image="open-file", include_in_toolbar=True, ) get_workbench().add_command("recents", "file", tr("Recent files"), group=10, submenu=self._recent_menu) # http://stackoverflow.com/questions/22907200/remap-default-keybinding-in-tkinter get_workbench().bind_class("Text", "<Control-o>", self._control_o) get_workbench().bind_class("Text", "<Control-Greek_omicron>", self._control_o) rebind_control_a(get_workbench()) get_workbench().add_command( "close_file", "file", tr("Close"), self._cmd_close_file, default_sequence=select_sequence("<Control-w>", "<Command-w>"), extra_sequences=["<Control-Greek_finalsmallsigma>"], tester=lambda: self.get_current_editor() is not None, group=10, ) get_workbench().add_command( "close_files", "file", tr("Close all"), self.close_tabs, tester=lambda: self.get_current_editor() is not None, default_sequence=select_sequence("<Control-W>", "<Command-Alt-w>"), group=10, ) get_workbench().add_command( "save_file", "file", tr("Save"), self._cmd_save_file, caption=tr("Save"), default_sequence=select_sequence("<Control-s>", "<Command-s>"), extra_sequences=["<Control-Greek_sigma>"], tester=self._cmd_save_file_enabled, group=10, image="save-file", include_in_toolbar=True, ) get_workbench().add_command( "save_all_files", "file", tr("Save All files"), self._cmd_save_all_files, caption=tr("Save All files"), default_sequence=select_sequence("<Control-Alt-s>", "<Command-Alt-s>"), tester=self._cmd_save_all_files_enabled, group=10, ) get_workbench().add_command( "save_file_as", "file", tr("Save as..."), self._cmd_save_file_as, default_sequence=select_sequence("<Control-Shift-S>", "<Command-Shift-S>"), extra_sequences=["<Control-Greek_SIGMA>"], tester=lambda: self.get_current_editor() is not None, group=10, ) get_workbench().add_command( "save_copy", "file", tr("Save copy..."), self._cmd_save_copy, tester=lambda: self.get_current_editor() is not None, group=10, ) get_workbench().add_command( "move_rename_file", "file", tr("Move / rename..."), self._cmd_move_rename_file, tester=self._cmd_move_rename_file_enabled, group=10, ) get_workbench().add_command( "goto_source_line", "edit", tr("Go to line ..."), self._cmd_goto_source_line, default_sequence=select_sequence("<Control-g>", "<Command-g>"), # tester=, # no global switch, or cross plugin switch? # todo use same as find and replace -> plugins/find_replace.py group=60, ) get_workbench().createcommand("::tk::mac::OpenDocument", self._mac_open_document)
def _init_commands(self): # TODO: do these commands have to be in EditorNotebook ?? # Create a module level function install_editor_notebook ?? # Maybe add them separately, when notebook has been installed ?? get_workbench().add_command( "new_file", "file", "New", self._cmd_new_file, caption="New", default_sequence=select_sequence("<Control-n>", "<Command-n>"), extra_sequences=["<Control-Greek_nu>"], group=10, image="new-file", include_in_toolbar=True, ) get_workbench().add_command( "open_file", "file", "Open...", self._cmd_open_file, caption="Load", default_sequence=select_sequence("<Control-o>", "<Command-o>"), extra_sequences=["<Control-Greek_omicron>"], group=10, image="open-file", include_in_toolbar=True, ) get_workbench().add_command("recents", "file", "Recent files", group=10, submenu=self._recent_menu) # http://stackoverflow.com/questions/22907200/remap-default-keybinding-in-tkinter get_workbench().bind_class("Text", "<Control-o>", self._control_o) get_workbench().bind_class("Text", "<Control-Greek_omicron>", self._control_o) rebind_control_a(get_workbench()) get_workbench().add_command( "close_file", "file", "Close", self._cmd_close_file, default_sequence=select_sequence("<Control-w>", "<Command-w>"), extra_sequences=["<Control-Greek_finalsmallsigma>"], tester=lambda: self.get_current_editor() is not None, group=10, ) get_workbench().add_command( "close_files", "file", "Close all", self.close_tabs, tester=lambda: self.get_current_editor() is not None, default_sequence=select_sequence("<Control-W>", "<Command-Alt-w>"), group=10, ) get_workbench().add_command( "save_file", "file", "Save", self._cmd_save_file, caption="Save", default_sequence=select_sequence("<Control-s>", "<Command-s>"), extra_sequences=["<Control-Greek_sigma>"], tester=self._cmd_save_file_enabled, group=10, image="save-file", include_in_toolbar=True, ) get_workbench().add_command( "save_file_as", "file", "Save as...", self._cmd_save_file_as, default_sequence=select_sequence("<Control-Shift-S>", "<Command-Shift-S>"), extra_sequences=["<Control-Greek_SIGMA>"], tester=lambda: self.get_current_editor() is not None, group=10, ) get_workbench().add_command( "rename_file", "file", "Rename...", self._cmd_rename_file, tester=self._cmd_rename_file_enabled, group=10, ) get_workbench().createcommand("::tk::mac::OpenDocument", self._mac_open_document)
def load_plugin() -> None: global RESUME_COMMAND_CAPTION RESUME_COMMAND_CAPTION = tr("Resume") if get_workbench().in_simple_mode(): get_workbench().set_default("debugger.frames_in_separate_windows", False) else: get_workbench().set_default("debugger.frames_in_separate_windows", True) get_workbench().set_default("debugger.automatic_stack_view", True) get_workbench().set_default("debugger.preferred_debugger", "faster" if running_on_rpi() else "nicer") get_workbench().set_default("debugger.allow_stepping_into_libraries", False) get_workbench().add_command( "runresume", "run", tr("Run / resume"), _run_or_resume, caption=running.RUN_COMMAND_CAPTION, tester=_run_or_resume_enabled, default_sequence=None, group=10, image="run-current-script", include_in_menu=False, include_in_toolbar=get_workbench().in_simple_mode(), alternative_caption=RESUME_COMMAND_CAPTION, ) get_workbench().add_command( "debug_preferred", "run", tr("Debug current script"), run_preferred_debug_command, caption=tr("Debug"), tester=_start_debug_enabled, group=10, image="debug-current-script", include_in_menu=False, include_in_toolbar=True, ) get_workbench().add_command( "debug_nicer", "run", tr("Debug current script (nicer)"), lambda: _request_debug("Debug"), caption="Debug (nicer)", tester=_start_debug_enabled, default_sequence="<Control-F5>", group=10, # image="debug-current-script", ) get_workbench().add_command( "debug_faster", "run", tr("Debug current script (faster)"), lambda: _request_debug("FastDebug"), caption="Debug (faster)", tester=_start_debug_enabled, default_sequence="<Shift-F5>", group=10, ) get_workbench().add_command( "step_over", "run", tr("Step over"), lambda: _issue_debugger_command("step_over"), caption=tr("Over"), tester=lambda: _debugger_command_enabled("step_over"), default_sequence="<F6>", group=30, image="step-over", include_in_toolbar=True, ) get_workbench().add_command( "step_into", "run", tr("Step into"), lambda: _issue_debugger_command("step_into"), caption=tr("Into"), tester=lambda: _debugger_command_enabled("step_into"), default_sequence="<F7>", group=30, image="step-into", include_in_toolbar=True, ) get_workbench().add_command( "step_out", "run", tr("Step out"), lambda: _issue_debugger_command("step_out"), caption=tr("Out"), tester=lambda: _debugger_command_enabled("step_out"), group=30, image="step-out", include_in_toolbar=True, ) get_workbench().add_command( "resume", "run", RESUME_COMMAND_CAPTION, lambda: _issue_debugger_command("resume"), caption=RESUME_COMMAND_CAPTION, tester=lambda: _debugger_command_enabled("resume"), default_sequence="<F8>", group=30, image="resume", include_in_toolbar=not get_workbench().in_simple_mode(), ) get_workbench().add_command( "run_to_cursor", "run", tr("Run to cursor"), lambda: _issue_debugger_command("run_to_cursor"), tester=lambda: _debugger_command_enabled("run_to_cursor"), default_sequence=select_sequence("<Control-F8>", "<Control-F8>"), group=30, image="run-to-cursor", include_in_toolbar=False, ) get_workbench().add_command( "step_back", "run", tr("Step back"), lambda: _issue_debugger_command("step_back"), caption=tr("Back"), tester=lambda: _debugger_command_enabled("step_back"), default_sequence=select_sequence("<Control-b>", "<Command-b>"), group=30, ) get_workbench().add_view(StackView, tr("Stack"), "se") get_workbench().add_view(ExceptionView, tr("Exception"), "s") get_workbench().bind("DebuggerResponse", _handle_debugger_progress, True) get_workbench().bind("ToplevelResponse", _handle_toplevel_response, True) get_workbench().bind("debugger_return_response", _handle_debugger_return, True) get_workbench().bind("CommandAccepted", _debug_accepted, True)
def load_plugin() -> None: def create_edit_command_handler(virtual_event_sequence): def handler(event=None): widget = get_workbench().focus_get() if widget: return widget.event_generate(virtual_event_sequence) return None return handler get_workbench().add_command( "undo", "edit", tr("Undo"), create_edit_command_handler("<<Undo>>"), tester=None, # TODO: default_sequence=select_sequence("<Control-z>", "<Command-z>"), extra_sequences=["<Control-Greek_zeta>"], skip_sequence_binding=True, group=10, ) get_workbench().add_command( "redo", "edit", tr("Redo"), create_edit_command_handler("<<Redo>>"), tester=None, # TODO: default_sequence=select_sequence("<Control-y>", "<Command-y>"), extra_sequences=[ select_sequence("<Control-Shift-Z>", "<Command-Shift-Z>"), "<Control-Greek_upsilon>", "<Control-Shift-Greek_ZETA>", ], skip_sequence_binding=True, group=10, ) get_workbench().add_command( "Cut", "edit", tr("Cut"), create_edit_command_handler("<<Cut>>"), tester=None, # TODO: default_sequence=select_sequence("<Control-x>", "<Command-x>"), extra_sequences=["<Control-Greek_chi>"], skip_sequence_binding=True, group=20, ) get_workbench().add_command( "Copy", "edit", tr("Copy"), create_edit_command_handler("<<Copy>>"), tester=None, # TODO: default_sequence=select_sequence("<Control-c>", "<Command-c>"), extra_sequences=["<Control-Greek_psi>"], skip_sequence_binding=True, group=20, ) get_workbench().add_command( "Paste", "edit", tr("Paste"), create_edit_command_handler("<<Paste>>"), tester=None, # TODO: default_sequence=select_sequence("<Control-v>", "<Command-v>"), extra_sequences=["<Control-Greek_omega>"], skip_sequence_binding=True, group=20, ) get_workbench().add_command( "SelectAll", "edit", tr("Select all"), create_edit_command_handler("<<SelectAll>>"), tester=None, # TODO: default_sequence=select_sequence("<Control-a>", "<Command-a>"), extra_sequences=["<Control-Greek_alpha>"], skip_sequence_binding=True, group=20, )