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

cocalc-jupyter ipywidgets: fully implement GridBoxModel and other layouts #5228

Closed
williamstein opened this issue Mar 2, 2021 · 8 comments
Closed

Comments

@williamstein
Copy link
Contributor

  1. Put this code in a notebook:
from ipywidgets import Button, GridBox, Layout, ButtonStyle

header  = Button(description='Header',
                 layout=Layout(width='auto', grid_area='header'),
                 style=ButtonStyle(button_color='lightblue'))
main    = Button(description='Main',
                 layout=Layout(width='auto', grid_area='main'),
                 style=ButtonStyle(button_color='moccasin'))
sidebar = Button(description='Sidebar',
                 layout=Layout(width='auto', grid_area='sidebar'),
                 style=ButtonStyle(button_color='salmon'))
footer  = Button(description='Footer',
                 layout=Layout(width='auto', grid_area='footer'),
                 style=ButtonStyle(button_color='olive'))

GridBox(children=[header, main, sidebar, footer],
        layout=Layout(
            width='50%',
            grid_template_rows='auto auto auto',
            grid_template_columns='25% 25% 25% 25%',
            grid_template_areas='''
            "header header header header"
            "main main . sidebar "
            "footer footer footer footer"
            ''')
       )
  1. It should look like this (in jupyter classic):

image

  1. But in CoCalc it looks like this:

image

This is not surprising given the code in src/smc-webapp/jupyter/output-messages/widget.tsx which explicitly says this isn't fully implemented.

@williamstein
Copy link
Contributor Author

WORKAROUND: Use JupyterLab or Jupyter Classic in CoCalc.
https://doc.cocalc.com/jupyter.html#classical-versus-cocalc

@williamstein
Copy link
Contributor Author

Better link to the code -- https://github.com/sagemathinc/cocalc/blob/master/src/smc-webapp/jupyter/output-messages/widget.tsx#L419

It's probably not hard to actually implement this properly... I should really do it soon.

@williamstein
Copy link
Contributor Author

@jasongrout check out how I fixed this via 4dfb08a if you want to be really annoyed! 🤷

@haraldschilly
Copy link
Contributor

I'm reverting this, this breaks those controls.

@jasongrout
Copy link
Contributor

@jasongrout check out how I fixed this via 4dfb08a if you want to be really annoyed! 🤷

Ouch :).

@williamstein
Copy link
Contributor Author

@jasongrout check out how I fixed this via 4dfb08a if you want to be really annoyed! 🤷

Ouch :).

3405032

@williamstein
Copy link
Contributor Author

I disabled the ipywidgets thing again since it evidently subtly broke something -- no clue why. In any case, another approach is instead of moving the widgets up one level in the DOM (thus replacing their parents), I can copy the CSS and styles up one level, so that the parents enforce the right layout. Maybe that is enough. I don't know. My guess is that the current approach confuses cleanup the phosphor widgets and causes a crash.

@williamstein
Copy link
Contributor Author

This is fixed by #7687

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants