Skip to content
New issue

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

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

Already on GitHub? # to your account

Make it easier to create text notebooks via the Launcher #1344

Open
ctcjab opened this issue Mar 5, 2025 · 1 comment
Open

Make it easier to create text notebooks via the Launcher #1344

ctcjab opened this issue Mar 5, 2025 · 1 comment

Comments

@ctcjab
Copy link

ctcjab commented Mar 5, 2025

I have a monorepo set up where several hundred contributors keep their py:percent formatted notebooks in version control, and where *.ipynb files are .gitignore'd. With our setup, users never intend to create .ipynb notebooks.

However, many users are having trouble remembering to use the "Python - Percent Format" button in the "Jupytext" section (which is currently at the very bottom of the Launcher) to create new notebooks. Instead they accidentally click one of the buttons in the "Notebook" section at the top of the Launcher, which ends up creating a new .ipynb notebook, which is the wrong thing to do:
Image

So users have requested that the "Jupytext" section of the Launcher be moved to the top, ideally even replacing the "Notebook" section, to make this less error-prone for them. Unfortunately this is not currently possible.

Would you be willing to expose an option so folks like me could set up the Launcher to make it easier for our users to click the intended, Jupytext-based "new notebook" buttons from the Launcher?

Thanks for your consideration, and for the great work on Jupytext!

P.S. Another meaningful improvement would be to provide a dedicated "new notebook" button for each registered kernel in the Jupytext section, just like the "Notebook" and section offers for .ipynb notebooks (as well as the "Console" section). This way, users wouldn't have to later set the kernel for their new text notebook in a separate, follow-up step. But this is much lower priority than replacing the "Notebook" section (or at least moving the "Jupytext" section above it).

@ctcjab
Copy link
Author

ctcjab commented Mar 7, 2025

In the meantime, I've added this code to accomplish this from my own extension, in case it helps anyone else:

function fixJupytextIssue1344(app: JupyterFrontEnd) {
  (app.shell as ILabShell).layoutModified.connect(() => {
    const container = document.querySelector('.jp-Launcher-content');
    if (!container) {
      return;
    }
    const launcherSectionTitles = document.querySelectorAll('.jp-Launcher-sectionTitle');
    const jupytextSection = findLauncherSectionWithTitle('Jupytext', launcherSectionTitles);
    if (!jupytextSection) {
      return;
    }
    container.prepend(jupytextSection);
    findLauncherSectionWithTitle('Notebook', launcherSectionTitles)?.remove();
  });
}

function findLauncherSectionWithTitle(title: string, els: NodeListOf<Element>) {
  return Array.from(els)
    .find(el => el.textContent?.trim() === title)
    ?.closest('.jp-Launcher-section');
}

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant