Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Add menuBar with the actions available to each tab #89

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions spyder_notebook/notebookplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
from qtpy.QtCore import Qt, QEventLoop, QTimer, Signal
from qtpy.QtGui import QIcon
from qtpy.QtWebEngineWidgets import WEBENGINE
from qtpy.QtWidgets import QApplication, QMessageBox, QVBoxLayout, QMenu
from qtpy.QtWidgets import (QApplication, QMessageBox, QVBoxLayout,
QMenu, QMenuBar)

# Third-party imports
import nbformat
Expand Down Expand Up @@ -57,6 +58,7 @@ def __init__(self, parent, testing=False):
self.fileswitcher_dlg = None
self.tabwidget = None
self.menu_actions = None
self.menu_bar_actions = None

self.main = parent

Expand All @@ -70,21 +72,15 @@ def __init__(self, parent, testing=False):

layout = QVBoxLayout()

new_notebook_btn = create_toolbutton(self,
icon=ima.icon('project_expanded'),
tip=_('Open a new notebook'),
triggered=self.create_new_client)
menu_btn = create_toolbutton(self, icon=ima.icon('tooloptions'),
tip=_('Options'))

self.menu = QMenu(self)
menu_btn.setMenu(self.menu)
menu_btn.setPopupMode(menu_btn.InstantPopup)
add_actions(self.menu, self.menu_actions)
corner_widgets = {Qt.TopRightCorner: [new_notebook_btn, menu_btn]}
corner_widgets = {Qt.TopRightCorner: [menu_btn]}
self.tabwidget = Tabs(self, menu=self.menu, actions=self.menu_actions,
corner_widgets=corner_widgets)

if hasattr(self.tabwidget, 'setDocumentMode') \
and not sys.platform == 'darwin':
# Don't set document mode to true on OSX because it generates
Expand All @@ -96,7 +92,11 @@ def __init__(self, parent, testing=False):

self.tabwidget.set_close_function(self.close_client)

self.menuBar = QMenuBar(self)
add_actions(self.menuBar, self.menu_bar_actions)

layout.addWidget(self.tabwidget)
layout.setMenuBar(self.menuBar)
self.setLayout(layout)

# ------ SpyderPluginMixin API --------------------------------------------
Expand Down Expand Up @@ -169,6 +169,11 @@ def get_plugin_actions(self):
self.recent_notebook_menu, MENU_SEPARATOR,
save_as_action, MENU_SEPARATOR,
open_console_action]

# Plugin menu bar actions
self.menu_bar_actions = [create_nb_action, open_action,
save_as_action, open_console_action]

self.setup_menu_actions()

return self.menu_actions
Expand Down