How to split a Jupyter notebook into several slides? - jupyter

Jupyter allows to produce slides either via nbconvert or (even better) dynamically and within a notebook with RISE.
However, when I launch RISE on my notebook or create slides with nbconvert, it creates only a single (potentially huge) slide. I thought it would/could automatically split at every header lines, but it does not.
How can I split the notebook into different slides?

You need to bring in a specific tool that is not shown by default. In the notebook, go to
View > Cell Toolbar > Slideshow
and a drop-down menu now appears at the right end of each cell, showing a "slide label" (my terminology).
By default, the label is -, meaning that the cell is part of the same block than the cell above.
If you change the label to slide, the cell is now the first cell of a new slide. (new slide would probably be a better label indeed).
You will find other labels too that closely follow Reveal.js' way of working:
The subslide label correspond also to a new slide, but placed in a "vertical stack" so dear to Reveal.js. fragments are used for progressive display of the elements of a slide. skip cells are not displayed, and notes are for speaker notes.

Related

I want to Collapse a VSCode tree view programatically

is there any way to collapse the tree view programatically.
I want to collapse my tree view when a button is clicked
PFA Screenshot.
I want Minimise the Firmware Layout View when 'Locate in Project View' is clicked.
There is a commit with a new command which may help, see 157410 Add Command to Fully Collapse Tree Items and in that commit this command:
list.collapseAllToFocus
[Update: now that I can test this I don't think this new command does what you need - it doesn't get to the top of the view and collapse that. It does collapse any included item and any of its included subItem items (so collapsing recursively - which is new) - but not at the top level, which is what you need.]
Here is an issue on this: API to programatically expand/collapse tree view
You can collapse that view - its contents only - but it appears you can't actually close the view itself - so it is reduced to a single line. Which I think is what you want. To collapse the contents so they are not visible (but still taking up their previous vertical space) read on. If there were a way to focus that view header which I believe it is called, then it would be easy to collapse the entire thing with the list.collapse command.
If you have your extension running, either in the Extension Host for testing or an installed version, look in the Keyboard Shortcuts and type collapse. You will see that vscode automatically creates a command like this:
workbench.actions.treeView.*******.collapseAll with your treeView id where the asterisks are.
So you could call that command the usual way with:
vscode.commands.executeCommand('workbench.actions.treeView.IDHere.collapseAll');
By the way, vscode also creates a
workbench.actions.treeView.someTreeViewIDHere.refresh command for all custom TreeViews.

Add a cell renderer using Glade

I'm using Glade to build a GTK user interface for my Rust program.
The issue is that items that are added to the ListStore are not showing up. I have horizontal lines set up that show up, but the text of the items is not showing up. I Googled and I suspect it's because of the cell renderers. I have tried to add a cell renderer in Glade, however I didn't see anywhere where could I do that. I right click on the treeview, click Edit, right click on the row/column but nothing about cell renderers is displayed.
How can I add a cell renderer using Glade?
$ glade --version
glade 3.22.1
It's very hard to find. I search lots of tutorial but many of them are very old, so the interface was quite different.
Right click GtkTreeView and choose "Edit"
On top left sub area, click blue "+" sign to add a new column.
right click newly created column, choose add child text
You will see Cell Render area showing up to the right.
In "Properties and Attributes", set "Text" properties to the column you wish to present.

NSOutlineView disclosure triangle vertically off center

I'm working with an NSOutlineView on a macOS app and it provides disclosure triangles for items that can be expanded.
I'm also creating custom NSTableCellView items rather than using basic cell items. This allows me to create the cell how I want visually.
My issue is that when they're displayed, the disclosure triangle on the left is not centered vertically.
Notice how the disclosure triangles are not aligned properly. They're a bit lower than they should be. If you scroll away and come back, sometimes, they automatically align themselves correctly. Has anyone been able to fix this issue before?
For what it's worth, I'm using the following code as well for the cells.
self.outlineView.rowHeight = CGFloat(integerLiteral: 66)
self.outlineView.usesAutomaticRowHeights = true
It's hard to figure out what the problem is without seeing how you've set up your project, but I'm going to give it shot.
First, when usesAutomaticRowHeights is set to true, the outline view uses Auto Layout to position the cell views. Thus, you need to be utilizing constraints in your Storyboard or Nib file, or things will behave strangely (see: your picture). If I had to guess, the prototype cell view you set up in Interface Builder is having its autoresizingMask translated into Auto Layout constraints (which, generally, causes a boatload of problems).
What I would do is this:
Open up the Storyboard or Nib document containing the outline view.
Locate the prototype NSTableCellView instance that contains the street name text field in the Document Outline to the left of the canvas. (If you don't see the Document Outline, you can open it by clicking the item at Editor » Show Document Outline in the main menu).
Next, see if you have any constraints in place. If you do, remove them by selecting Editor » Resolve Auto Layout Issues » Clear Constraints under the menu item "section" that's titled All Views in ${YOUR_SCENE}.
Now, depending on what you're going for, there are different ways to go about setting up constraints, but here's what I would suggest. Assuming you want the street name to be centered vertically with the disclosure triangle, I would add a vertical constraint between the text field and its parent cell view like so:
With the text field selected in the Document Outline, click the Align icon in the lower right-hand corner of Interface Builder's main canvas area (see image).
In the popover that appears, check the checkbox next to Vertically in Container.
In the text field on the right side of the popover, enter a value of “0”.
Finally, click the “Add 1 Constraint” button.
You’ll probably see a red error (or yellow warning) sign show up, as the view has now opted into Auto Layout, but it only has a metric for its vertical position. So we now need to add some constraints to describe where the text field should be positioned on the x axis. Like before, we’ll define the constraints using the popover buttons on the lower right-hand side of the canvas:
Click the Add New Constraints button (the one to the right of the Align button).
On the diagram at the top of the popover, click the faint red lines on the left and right side of the white rectangle. This is telling Interface Builder we want to add leading and trailing constraints.
Now, enter the desired padding you want on each side of the text field. In the example image, I went with “4” points on both sides, but obviously, you can use whatever value(s) you think works best with your layout.
Finally, click the “Add 2 Constraints” button.
Any warning(s) that were present should now disappear, as we've added enough constraints to describe the position of the text field. In theory, you should now be able to build and run your project, and the text fields should be aligned with the disclosure triangles. With that said, there are plenty of other reasons a layout can get finicky, and considering usesAutomaticRowHeights is a new API in macOS High Sierra (and Steve Jobs is no longer there to beat it into Apple developers to make everything Just Work™), there could be issues that I'm unaware of.
Alternatively, you can set usesAutomaticRowHeights to false and have some object (e.g. a view controller, a NSObject subclass, etc.) conform to the NSOutlineViewDelegate protocol and implement the outlineView(_:heightOfRowByItem:) method to return any arbitrary height you want for different rows. The nice thing about sizing rows this way is that you can allow certain rows to be larger or smaller, depending on the role of the corresponding item. There are lots of tutorials on this, so I won't regurgitate a half-baked explanation here, but feel free to Google “Conforming to NSOutlineViewDelegate protocol” for more info.
Anyway, try the steps above, and see if they do anything for you, and if they don't, let me know. I can go as deep into the rabbit hole with you as you need, so just ask. Good luck!
For those like me who stumbled upon this issue many years later, here's the fix that worked for me, and requires a lot less work.
NSOutlineView has a function frameOfOutlineCell(atRow:) and the documentation states: You can override this method in a subclass to return a custom frame for the outline button cell
You can override the method in order to provide a frame that's actually in the vertical center of the row. And an important point that I learned from trial and error, is that you don't even need to provide that updated frame. Not sure if this is a bug or what, but for me, just calling super.frameOfOutlineCell(atRow: row) in the function override was enough to make the disclosure indicator appear in the correct location.
So my subclass of NSOutlineView is this:
class MyOutlineView: NSOutlineView {
override func frameOfOutlineCell(atRow row: Int) -> NSRect {
super.frameOfOutlineCell(atRow: row)
}
}
That's all. Hopefully that works for others as well!

ipython notebook navigate between cells

is there a way in ipython notebook to navigate between cells which are far apart? For example if I have a large notebook and I want to move from a cell near the top of the notebook and then back to one at the bottom. Can I do this? I was thinking there might be a "goto cell 23" command or if not something similar to the mark command in vim.
thanks
You can create internal hyperlinks to navigate between cells. Here's how you can do that:
First, define the destination in the cell you want to link with a html anchor tag and give it an Id. For example:
<a id='another_cell'></a>
Note - When you run the above cell in markdown, it will become invisible. You can add some text above the anchor to identify the cell.
Second, create the internal hyperlink to the destination created above using Markdown syntax in another cell and run it:
[Another Cell](#another_cell)
Now, clicking on link should take you to the destination.
There is a table-of-content extension which uses the heading cells to generate a floating toc with hyperlinks. This is quite similar to marks in vim. You can find it here. This extension is also discussed in this question and looks e.g like

how to add a disclosure panel to a cellTable column in GWT

I have a cellTable with 5-6 columns. I want to put a plus icon in each row on clicking of which will display the details maybe in a disclosure panel. I have been looking around for a while now and I cannot find any information on how to achieve this. Could someone point me in the right direction?
i suspect i probably have to add a cellTree to the column? how do i go about this?
Thank you for your response in advance.
There is work in progress to allow expandable rows in CellTable among other features (maybe GWT 2.3). You can see more details here:
http://groups.google.com/group/google-web-toolkit-contributors/browse_thread/thread/b4a8a6e3c98ac061#
If that is not enough or you can not wait untill it is released I can think of two ways to achieve it:
As you said, using a CellTree.
Creating a custom cell that stores
state (open/close). Depending on the
state the cell will render
differently. In same way it is
similar to how EditTextCell works, in
"edit" state it renders an input
field while in "normal" state it renders
simple text.
I'm trying to do that too ... I managed to mimic that functionality toying with the html and a custom cell class that allows clickable pictures.
It is working for normal content such as text but if you'd like to get an asynchronous data to show in the expended line, I don't know how to do it ... (I'm trying to do exactly that).
Also, it doesn't look good because the columns don't align well ...
So what I've done is:
- create a custom cell class to display a picture (right pointing triangle, looking like the triangle in the disclosure panel)
In the click event get the HTML code of the selected row and copy it. Replace the content of the row (all cells) in the table with only one cell with its colspan set to number of columns. In the cell, add a table with first line the copied row and second line the content to display as expanded.
Get the image to sink an event for closing. In event, reset the original row that we copied.
I hope it helps.