Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
gonext_btn = create_toolbutton(
self, icon=ima.icon('ArrowForward'),
tip=_("Next figure ({})").format(
CONF.get_shortcut('plots', 'next figure')),
triggered=self.go_next_thumbnail)
vsep2 = QFrame()
vsep2.setFrameStyle(53)
self.zoom_out_btn = create_toolbutton(
self, icon=ima.icon('zoom_out'),
tip=_("Zoom out (Ctrl + mouse-wheel-down)"),
triggered=self.zoom_out)
self.zoom_in_btn = create_toolbutton(
self, icon=ima.icon('zoom_in'),
tip=_("Zoom in (Ctrl + mouse-wheel-up)"),
triggered=self.zoom_in)
self.zoom_disp = QSpinBox()
self.zoom_disp.setAlignment(Qt.AlignCenter)
self.zoom_disp.setButtonSymbols(QSpinBox.NoButtons)
self.zoom_disp.setReadOnly(True)
self.zoom_disp.setSuffix(' %')
self.zoom_disp.setRange(0, 9999)
self.zoom_disp.setValue(100)
self.figviewer.sig_zoom_changed.connect(self.zoom_disp.setValue)
zoom_pan = QWidget()
layout = QHBoxLayout(zoom_pan)
layout.setSpacing(0)
layout.setContentsMargins(0, 0, 0, 0)
icon=ima.icon('edit'),
triggered=self.edit_item)
self.plot_action = create_action(self, _("Plot"),
icon=ima.icon('plot'),
triggered=lambda: self.plot_item('plot'))
self.plot_action.setVisible(False)
self.hist_action = create_action(self, _("Histogram"),
icon=ima.icon('hist'),
triggered=lambda: self.plot_item('hist'))
self.hist_action.setVisible(False)
self.imshow_action = create_action(self, _("Show image"),
icon=ima.icon('imshow'),
triggered=self.imshow_item)
self.imshow_action.setVisible(False)
self.save_array_action = create_action(self, _("Save array"),
icon=ima.icon('filesave'),
triggered=self.save_array)
self.save_array_action.setVisible(False)
self.insert_action = create_action(self, _("Insert"),
icon=ima.icon('insert'),
triggered=self.insert_item)
self.remove_action = create_action(self, _("Remove"),
icon=ima.icon('editdelete'),
triggered=self.remove_item)
self.minmax_action = create_action(self, _("Show arrays min/max"),
toggled=self.toggle_minmax)
self.minmax_action.setChecked(minmax)
self.toggle_minmax(minmax)
self.rename_action = create_action(self, _("Rename"),
icon=ima.icon('rename'),
triggered=self.rename_item)
self.duplicate_action = create_action(self, _("Duplicate"),
self.next_warning_action = create_action(self,
_("Next warning/error"), icon=ima.icon('next_wng'),
tip=_("Go to next code analysis warning/error"),
triggered=self.go_to_next_warning)
self.previous_edit_cursor_action = create_action(self,
_("Last edit location"), icon=ima.icon('last_edit_location'),
tip=_("Go to last edit location"),
triggered=self.go_to_last_edit_location,
context=Qt.WidgetShortcut)
self.register_shortcut(self.previous_edit_cursor_action,
context="Editor",
name="Last edit location",
add_sc_to_tip=True)
self.previous_cursor_action = create_action(self,
_("Previous cursor position"), icon=ima.icon('prev_cursor'),
tip=_("Go to previous cursor position"),
triggered=self.go_to_previous_cursor_position,
context=Qt.WidgetShortcut)
self.register_shortcut(self.previous_cursor_action,
context="Editor",
name="Previous cursor position",
add_sc_to_tip=True)
self.next_cursor_action = create_action(self,
_("Next cursor position"), icon=ima.icon('next_cursor'),
tip=_("Go to next cursor position"),
triggered=self.go_to_next_cursor_position,
context=Qt.WidgetShortcut)
self.register_shortcut(self.next_cursor_action,
context="Editor",
name="Next cursor position",
add_sc_to_tip=True)
self.save_action = create_action(self, _("&Save"),
icon=ima.icon('filesave'), tip=_("Save file"),
triggered=self.save,
context=Qt.WidgetShortcut)
self.register_shortcut(self.save_action, context="Editor",
name="Save file", add_sc_to_tip=True)
self.save_all_action = create_action(self, _("Sav&e all"),
icon=ima.icon('save_all'), tip=_("Save all files"),
triggered=self.save_all,
context=Qt.WidgetShortcut)
self.register_shortcut(self.save_all_action, context="Editor",
name="Save all", add_sc_to_tip=True)
save_as_action = create_action(self, _("Save &as..."), None,
ima.icon('filesaveas'), tip=_("Save current file as..."),
triggered=self.save_as,
context=Qt.WidgetShortcut)
self.register_shortcut(save_as_action, "Editor", "Save As")
print_preview_action = create_action(self, _("Print preview..."),
tip=_("Print preview..."), triggered=self.print_preview)
self.print_action = create_action(self, _("&Print..."),
icon=ima.icon('print'), tip=_("Print current file..."),
triggered=self.print_file)
# Shortcut for close_action is defined in widgets/editor.py
self.close_action = create_action(self, _("&Close"),
icon=ima.icon('fileclose'), tip=_("Close current file"),
triggered=self.close_file)
self.close_all_action = create_action(self, _("C&lose all"),
icon=ima.icon('filecloseall'), tip=_("Close all opened files"),
def __update_maximize_action(self):
if self.state_before_maximizing is None:
text = _("Maximize current pane")
tip = _("Maximize current pane")
icon = ima.icon('maximize')
else:
text = _("Restore current pane")
tip = _("Restore pane to its original size")
icon = ima.icon('unmaximize')
self.maximize_action.setText(text)
self.maximize_action.setIcon(icon)
self.maximize_action.setToolTip(tip)
def get_plugin_icon(self):
"""Return widget icon."""
path = images.__path__[0]
return ima.icon('spyder.line_profiler', icon_path=path)
context=Qt.WidgetShortcut)
self.register_shortcut(self.previous_edit_cursor_action,
context="Editor",
name="Last edit location",
add_sc_to_tip=True)
self.previous_cursor_action = create_action(self,
_("Previous cursor position"), icon=ima.icon('prev_cursor'),
tip=_("Go to previous cursor position"),
triggered=self.go_to_previous_cursor_position,
context=Qt.WidgetShortcut)
self.register_shortcut(self.previous_cursor_action,
context="Editor",
name="Previous cursor position",
add_sc_to_tip=True)
self.next_cursor_action = create_action(self,
_("Next cursor position"), icon=ima.icon('next_cursor'),
tip=_("Go to next cursor position"),
triggered=self.go_to_next_cursor_position,
context=Qt.WidgetShortcut)
self.register_shortcut(self.next_cursor_action,
context="Editor",
name="Next cursor position",
add_sc_to_tip=True)
# --- Edit Toolbar ---
self.toggle_comment_action = create_action(self,
_("Comment")+"/"+_("Uncomment"), icon=ima.icon('comment'),
tip=_("Comment current line or selection"),
triggered=self.toggle_comment, context=Qt.WidgetShortcut)
self.register_shortcut(self.toggle_comment_action, context="Editor",
name="Toggle comment")
blockcomment_action = create_action(self, _("Add &block comment"),
def create_file_manage_actions(self, fnames):
"""Return file management actions"""
only_files = all([osp.isfile(_fn) for _fn in fnames])
only_modules = all([osp.splitext(_fn)[1] in ('.py', '.pyw', '.ipy')
for _fn in fnames])
only_notebooks = all([osp.splitext(_fn)[1] == '.ipynb'
for _fn in fnames])
only_valid = all([encoding.is_text_file(_fn) for _fn in fnames])
run_action = create_action(self, _("Run"), icon=ima.icon('run'),
triggered=self.run)
open_with_spyder_action = create_action(
self, _("Open in Spyder"), icon=ima.icon('edit'),
triggered=self.open)
open_with_menu = QMenu(_('Open with'), self)
open_external_action = create_action(
self, _("Open externally"),
triggered=self.open_external)
move_action = create_action(self, _("Move..."),
icon="move.png",
triggered=self.move)
delete_action = create_action(self, _("Delete..."),
icon=ima.icon('editdelete'),
triggered=self.delete)
rename_action = create_action(self, _("Rename..."),
icon=ima.icon('rename'),
triggered=self.rename)
ipynb_convert_action = create_action(self, _("Convert to Python script"),
icon=ima.icon('python'),
def __update_fullscreen_action(self):
if self.isFullScreen():
icon = ima.icon('window_nofullscreen')
else:
icon = ima.icon('window_fullscreen')
if is_text_string(icon):
icon = get_icon(icon)
self.fullscreen_action.setIcon(icon)
def add_actions_to_context_menu(self, menu):
"""Add actions to IPython widget context menu"""
inspect_action = create_action(self, _("Inspect current object"),
QKeySequence(get_shortcut('console',
'inspect current object')),
icon=ima.icon('MessageBoxInformation'),
triggered=self.inspect_object)
clear_line_action = create_action(self, _("Clear line or block"),
QKeySequence("Shift+Escape"),
icon=ima.icon('editdelete'),
triggered=self.clear_line)
reset_namespace_action = create_action(self, _("Reset namespace"),
QKeySequence("Ctrl+Alt+R"),
triggered=self.reset_namespace)
clear_console_action = create_action(self, _("Clear console"),
QKeySequence(get_shortcut('console',
'clear shell')),
icon=ima.icon('editclear'),
triggered=self.clear_console)
quit_action = create_action(self, _("&Quit"), icon=ima.icon('exit'),
triggered=self.exit_callback)
add_actions(menu, (None, inspect_action, clear_line_action,
clear_console_action, reset_namespace_action,
None, quit_action))
return menu