How to use the @lumino/widgets.Menu function in @lumino/widgets

To help you get started, we’ve selected a few @lumino/widgets examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hadim / jupyter-archive / src / index.ts View on Github external
// matches anywhere on filebrowser
    const selectorContent = ".jp-DirListing-content";

    // matches directory filebrowser items
    const selectorOnlyDir = '.jp-DirListing-item[data-isdir="true"]';

    // matches file filebrowser items
    const selectorNotDir = '.jp-DirListing-item[data-isdir="false"]';

    // Create submenus
    const archiveFolder = new Menu({
      commands
    });
    archiveFolder.title.label = "Download As";
    archiveFolder.title.iconClass = "jp-MaterialIcon jp-DownloadIcon";
    const archiveCurrentFolder = new Menu({
      commands
    });
    archiveCurrentFolder.title.label = "Download Current Folder As";
    archiveCurrentFolder.title.iconClass = "jp-MaterialIcon jp-DownloadIcon";

    ["zip", "tar.bz2", "tar.gz", "tar.xz"].forEach(format => {
      archiveFolder.addItem({
        command: CommandIDs.downloadArchive,
        args: { format }
      });
      archiveCurrentFolder.addItem({
        command: CommandIDs.downloadArchiveCurrentFolder,
        args: { format }
      });
    });
github timkpaine / jupyterlab_email / js / src / index.ts View on Github external
});
          },
          isEnabled: () => {
            if (app.shell.currentWidget &&
              docManager.contextForWidget(app.shell.currentWidget) &&
              docManager.contextForWidget(app.shell.currentWidget).model) {
              return true;
            }
            return false;
          },
          label: command1,
        });

        palette.addItem({command: command1, category: "Email"});

        const menu = new Menu({ commands });
        menu.title.label = "Send Emails";

        app.restored.then(() => {
          all_emails1.forEach((command) => {
            menu.addItem({command, args: {}});
          });

          if (mainMenu && !loaded) {
            loaded = true;
            mainMenu.fileMenu.addGroup([{ type: "submenu", submenu: menu }], 11);
          }
        });
      }
    }
  });
  // eslint-disable-next-line no-console
github jupyterlab / jupyterlab / packages / apputils-extension / src / themeplugins.ts View on Github external
activate: (
    app: JupyterFrontEnd,
    manager: IThemeManager,
    palette: ICommandPalette | null,
    mainMenu: IMainMenu | null
  ): void => {
    const commands = app.commands;

    // If we have a main menu, add the theme manager to the settings menu.
    if (mainMenu) {
      const themeMenu = new Menu({ commands });
      themeMenu.title.label = 'JupyterLab Theme';
      void app.restored.then(() => {
        const isPalette = false;

        // choose a theme
        manager.themes.forEach(theme => {
          themeMenu.addItem({
            command: CommandIDs.changeTheme,
            args: { isPalette, theme }
          });
        });
        themeMenu.addItem({ type: 'separator' });

        // toggle scrollbar theming
        themeMenu.addItem({ command: CommandIDs.themeScrollbars });
        themeMenu.addItem({ type: 'separator' });
github hadim / jupyter-archive / src / index.ts View on Github external
".txz",
      ".tar.xz"
    ];
    let archiveFormat: ArchiveFormat; // Default value read from settings

    // matches anywhere on filebrowser
    const selectorContent = ".jp-DirListing-content";

    // matches directory filebrowser items
    const selectorOnlyDir = '.jp-DirListing-item[data-isdir="true"]';

    // matches file filebrowser items
    const selectorNotDir = '.jp-DirListing-item[data-isdir="false"]';

    // Create submenus
    const archiveFolder = new Menu({
      commands
    });
    archiveFolder.title.label = "Download As";
    archiveFolder.title.iconClass = "jp-MaterialIcon jp-DownloadIcon";
    const archiveCurrentFolder = new Menu({
      commands
    });
    archiveCurrentFolder.title.label = "Download Current Folder As";
    archiveCurrentFolder.title.iconClass = "jp-MaterialIcon jp-DownloadIcon";

    ["zip", "tar.bz2", "tar.gz", "tar.xz"].forEach(format => {
      archiveFolder.addItem({
        command: CommandIDs.downloadArchive,
        args: { format }
      });
      archiveCurrentFolder.addItem({
github jupyterlab / jupyterlab / examples / filebrowser / src / index.ts View on Github external
commands.addKeyBinding({
    keys: ['Enter'],
    selector: '.jp-DirListing',
    command: 'file-open'
  });
  commands.addKeyBinding({
    keys: ['Accel S'],
    selector: '.jp-CodeMirrorEditor',
    command: 'file-save'
  });
  window.addEventListener('keydown', event => {
    commands.processKeydownEvent(event);
  });

  // Create a context menu.
  let menu = new Menu({ commands });
  menu.addItem({ command: 'file-open' });
  menu.addItem({ command: 'file-rename' });
  menu.addItem({ command: 'file-remove' });
  menu.addItem({ command: 'file-duplicate' });
  menu.addItem({ command: 'file-delete' });
  menu.addItem({ command: 'file-cut' });
  menu.addItem({ command: 'file-copy' });
  menu.addItem({ command: 'file-paste' });
  menu.addItem({ command: 'file-shutdown-kernel' });
  menu.addItem({ command: 'file-dialog-demo' });
  menu.addItem({ command: 'file-info-demo' });

  // Add a context menu to the dir listing.
  let node = fbWidget.node.getElementsByClassName('jp-DirListing-content')[0];
  node.addEventListener('contextmenu', (event: MouseEvent) => {
    event.preventDefault();
github jupyterlab / lumino / examples / example-dockpanel / src / index.ts View on Github external
function createMenu(): Menu {
  let sub1 = new Menu({ commands });
  sub1.title.label = 'More...';
  sub1.title.mnemonic = 0;
  sub1.addItem({ command: 'example:one' });
  sub1.addItem({ command: 'example:two' });
  sub1.addItem({ command: 'example:three' });
  sub1.addItem({ command: 'example:four' });

  let sub2 = new Menu({ commands });
  sub2.title.label = 'More...';
  sub2.title.mnemonic = 0;
  sub2.addItem({ command: 'example:one' });
  sub2.addItem({ command: 'example:two' });
  sub2.addItem({ command: 'example:three' });
  sub2.addItem({ command: 'example:four' });
  sub2.addItem({ type: 'submenu', submenu: sub1 });
github jupyterlab / jupyterlab / packages / codemirror / src / syntaxstatus.tsx View on Github external
private _handleClick = () => {
    const modeMenu = new Menu({ commands: this._commands });
    let command = 'codemirror:change-mode';
    if (this._popup) {
      this._popup.dispose();
    }
    Mode.getModeInfo()
      .sort((a, b) => {
        let aName = a.name || '';
        let bName = b.name || '';
        return aName.localeCompare(bName);
      })
      .forEach(spec => {
        if (spec.mode.indexOf('brainf') === 0) {
          return;
        }

        let args: JSONObject = {
github jupyterlab / jupyterlab / packages / mainmenu / src / labmenu.ts View on Github external
constructor(options: Menu.IOptions, includeSeparators: boolean = true) {
    this.menu = new Menu(options);
    this._includeSeparators = includeSeparators;
  }
github jupyterlab / lumino / examples / example-dockpanel / src / index.ts View on Github external
sub1.title.mnemonic = 0;
  sub1.addItem({ command: 'example:one' });
  sub1.addItem({ command: 'example:two' });
  sub1.addItem({ command: 'example:three' });
  sub1.addItem({ command: 'example:four' });

  let sub2 = new Menu({ commands });
  sub2.title.label = 'More...';
  sub2.title.mnemonic = 0;
  sub2.addItem({ command: 'example:one' });
  sub2.addItem({ command: 'example:two' });
  sub2.addItem({ command: 'example:three' });
  sub2.addItem({ command: 'example:four' });
  sub2.addItem({ type: 'submenu', submenu: sub1 });

  let root = new Menu({ commands });
  root.addItem({ command: 'example:copy' });
  root.addItem({ command: 'example:cut' });
  root.addItem({ command: 'example:paste' });
  root.addItem({ type: 'separator' });
  root.addItem({ command: 'example:new-tab' });
  root.addItem({ command: 'example:close-tab' });
  root.addItem({ command: 'example:save-on-exit' });
  root.addItem({ type: 'separator' });
  root.addItem({ command: 'example:open-task-manager' });
  root.addItem({ type: 'separator' });
  root.addItem({ type: 'submenu', submenu: sub2 });
  root.addItem({ type: 'separator' });
  root.addItem({ command: 'example:close' });

  return root;
}