Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could the notebook StyleSheet change the code behaviour?

I'd like to ask if someone had such a problem before. I have version 8.01, on windows 7, 64 bit. SP1.

I have been trying to find why I get Mathematica kernel crash when I added a Tooltip[] command to some code I am writing.

The notebook has the Wolfram Demonstration Style sheet (the Example style sheet which one uses to make demonstrations from). It is a Manipulate, all in one cell.

When I copy the code into a new notebook with default style sheet, the crash goes away! I can't reproduce the crash in the new notebook.

No code change at all. Just copied the whole cell and pasted it in a new notebook. Only difference is one has the Demonstration style sheet, and one is the default style sheet. When I change the stype sheet of the new notebook to Demostration, I notice the Tooltip does not work as well as before. When I use the Example notebook in this style, the minute I start moving the mouse with the toolstip, Kernel crashes.

To make sure, I did this few times. Same result. Once I add the Tooltip[], kernel crash right away only when the style sheet is demonstration.

My question: Has anyone seen such a behavior? I can make the two notebooks available if that is ok.

The crash I get is:

Problem signature:
  Problem Event Name:   BEX64
  Application Name: Mathematica.exe
  Application Version:  8.0.31.32201
  Application Timestamp:    4d65e0e8
  Fault Module Name:    StackHash_2766
  Fault Module Version: 0.0.0.0
  Fault Module Timestamp:   00000000
  Exception Offset: 0000000000000001
  Exception Code:   c0000005
  Exception Data:   0000000000000008
  OS Version:   6.1.7601.2.1.0.768.3
  Locale ID:    1033
  Additional Information 1: 2766
  Additional Information 2: 2766660d255034f6e73a8cd527b6f51e
  Additional Information 3: 8ab7
  Additional Information 4: 8ab74987ae95fade363a8e7256e3890f

I did send a bug report to WRI.

My question is: Has anyone had such a problem where a Style sheet change can make the code behave differently? Why would style sheet change cause such a problem?

Update 1:

I was able to make small example that shows part of the problem. I am working on making another small example that shows the crash itself. But this example below shows the problem, which is that Tooltip do not work the same when the style sheet is demonstration. First, here is a screen shot, side by side, same code, the left is in default style sheet, and the right is in Demonstration style

(below the image, I paste the source code, with steps how to reproduce the problem)

enter image description here

Manipulate[

EventHandler[Dynamic[Graphics[
{
Circle[{0,0},1],
Dynamic@Tooltip[Text[Style["O",Red,16] ,pt],Style[pt]]
},
ImageSize->250, PlotRange->{{-1,1},{-1,1}}
],ContinuousAction->True],

"MouseDragged":>
( pt=MousePosition["Graphics"] )
],

{{pt,{0,0}},ControlType->None},

TrackedSymbols:> {None},
ContinuousAction->True
]

steps:

  1. Paste the above code in new style sheet, style default. Drag the point, you should see the coordinates display all the time, as you drag the point with the mouse.
  2. File->New->Demonstration, and paste the same code in the Manipulate cell there replacing small template already there.
  3. Now do the same, drag the point. You will see that the tooltip DO NOT display as the mouse is dragged. it only displays when holding the mouse steady over the point.

there is different behavior in dynamics that seems to cause this, or something else in this style.

I tried different style sheets, and the tooltip works ok there. only with Demonstration style sheet I get this problem with the tooltip.

If someone has a solution to this, it will be great. As I'd like to use tooltip in a demo.

I'll try to make an example that causes the crash also.

Update:

I've got back respsonce from WRI technical support. It is a Style sheet issue. Meanwhile, as a work around this is the suggestion From tech support:

I was able to reproduce the kernel crash. It looks like a demonstration
stylesheet issue related to imagesize fit. 
At the top of the demonstration notebook there is tab called 'Tools',
clicking on it gives you an option called 'Resize Notebook to Fit'. On
resizing the notebook and saving it the kernel crash does not happen.

Thanks to WRI tech support.

update dec 2 2011 Based on John Fultz answer below, I am closing this question now. Thanks John.

like image 297
Nasser Avatar asked Jul 23 '11 01:07

Nasser


People also ask

How do I edit stylesheet in Mathematica?

Open a new notebook. Select the menu item Format ► Edit Stylesheet. An empty Style Definitions notebook will open. Alter the style for each cell type you wish to modify.

How do I enable dark mode in Mathematica?

Mathematica has a built-in ReverseColor stylesheet for users who prefer a darker mode. To select it as your current notebook's stylesheet, go to the menu item Format ► Stylesheet ► ReverseColor.


1 Answers

(This answer is actually due to John Fultz -- see the comments under the original question. I'm turning it into an answer so that this question stops showing up on the unanswered-questions list. Clearly it's actually John who deserves any reputation points for this; John, if you post an answer here then I'll vote it up and delete mine.)

The reason why your tooltip isn't appearing in the demonstration version is that the Demonstration stylesheet puts a nonzero delay on tooltips, so that they only appear after hovering over them for a certain length of time. In particular, this means that they won't appear while dragging.

You can reverse this by setting the delay to zero on your Manipulate; do this by adding the following option to the Manipulate call.

BaseStyle -> {TooltipBoxOptions -> {TooltipDelay->0}}
like image 108
Gareth McCaughan Avatar answered Oct 08 '22 00:10

Gareth McCaughan