Apologies for making something that is probably trivial my first question here but I just realized I do not know how to style the font within the input field in a Manipulator control. None of the options for this function are for styling within the input field (AFAIK). I wondered whether an input field option would work:
Style[Manipulator[0.5, Appearance -> {"Open", Tiny}],
DefaultOptions -> {InputField -> {BaseStyle -> Directive[Red, 16]}}]
but it didn't. I'm assuming this is trivial but it has me stumped.
Edit
I have tried using a local Manipulator style
Cell[StyleData["Manipulator"],
ShowStringCharacters->False,
NumberMarks->False,
FontFamily:>CurrentValue["PanelFontFamily"],
FontSize->24,
FontColor->RGBColor[1,0,0],
FontWeight->"Bold"]
This is changing the font colour and weight (I do not want these changed in my application, just testing what works and what doesn't) but still not changing the font size. If this stylesheet solution worked I guess it would suffice for now but ultimately I would like to have a tiny manipulator in a Manipulate:
{{x, 40, "Hello World"}, 20, 100, 5, Appearance -> "Open",
AppearanceElements -> {"InputField", "StepLeftButton", "StepRightButton",
"HideControlsButton"}, ImageSize -> Tiny}
but with a non-tiny font in the input field, and achieve this by direct coding.
The only way I know to change the size of the text in the field is to hit the entire thing with Magnification. Using Simon's guidance above to do this with Style:
Style[
Manipulator[0.5, Appearance -> {"Open", Tiny}],
DynamicBoxOptions -> {BaseStyle -> Magnification -> 2}
]
Related
Is there a way to create and edit notebooks (sequences of cells) in a tabbed interface? Could such an interface be made with TabView or some other tool? I assume this would be possible if I made a front-end from scratch, but is there a way within the standard Wolfram front-end?
Two things motivate me to ask this. First, I would like to create a replacement for Microsoft Office OneNote with Mathematica notebooks. Second, when I'm working in Mathematica I find myself wondering whether a tabbed interface would work better than having numerous separate windows open.
While Mathematica doesn't support tabbed notebook windows directly, it is possible to reproduce something of the effect using DockedCells. The Virtual Book/Function Navigator interface (from the help menu) does this...it's essentially a slide show with two slides, one holding the VB and the other containing the FN, with a DockedCells navigation interface driven by NotebookFind that looks a bit like tabs.
Here's the gist of how you might go about making such a notebook on your own. Sorry, there are some kind of advanced concepts here...if there's any parts of this solution which you want to learn more about, maybe you can spin off more questions.
(* make a single page of the notebook *)
page[tag_String] :=
Cell#CellGroupData[{Cell["", "SlideShowNavigationBar",
CellTags -> {tag}], Cell[tag, "Title"]}];
(* make a single tab-like button which selects the page *)
button[tag_String] :=
Button[Dynamic[
Setter[Dynamic[
CurrentValue[EvaluationNotebook[], {TaggingRules, "page"},
tag]], tag]],
CurrentValue[EvaluationNotebook[], {TaggingRules, "page"}] = tag;
NotebookLocate[tag],
Appearance -> None];
(* make a notebook based upon a list of strings which are names of tabs *)
makeTabbedNotebook[nameList_List] :=
NotebookPut#Notebook[page /# nameList,
DockedCells ->
ToBoxes[ExpressionCell[Row[button /# nameList],
"DockedCell"]][[1]],
ScreenStyleEnvironment -> "SlideShow"];
makeTabbedNotebook[{"First", "Second", "Third"}]
Edit: changed NotebookFind[ButtonNotebook[],tag,All,CellTags], which appears to not always scroll the slideshow correctly, to NotebookLocate[tag]. See discussion in comments. The two bits of code should, in theory, be equivalent, but a bug in Mathematica 8 appears to make them behave differently sometimes.
I am trying to have a LocatorPane with more than one Locator using LocatorAutoCreate option.
But I'd also like to set AutoAction->True, so that when the mouse is over a locator, it moves automatically with the mouse. i.e. works like dragging.
I am basically trying to just have the dragging feature of LocatorPane, and do not want the clicking feature of LocatorPane, as it complicate something else I am doing.
i.e. I just want to be able to just drag points across a locator pane. Clicking on the locatorPane should do nothing. One way to do that I found is by setting AutoAction->True. Is there a better way to disable Clicking effect on LocatorPane?
The problem is that, when I have more than one locator, Mathematica kernel crashes right away.
So, I am asking if there is a way to use AutoAction->True with LocatorPane with more LocatorAutoCreator at the same time. Or if there is a way to just allow dragging, and clicking should do nothing.
Here is an example
LocatorPane[{{0,0},{.4,.5}},
Graphics[{Gray,Disk[]}],
AutoAction->True,
LocatorAutoCreate->{1,5}]
Make sure you save your work before running the above, as it will crash Mathematica once the mouse is over the Pane.
Version 8.0.1, Windows 7.
Update:
FYI; I got a reply from WRI tech support on this today. The problem has been reproduced and send to Mathematica development team to investigate.
You may try:
LocatorPane[{{0, 0}, {.4, .5}, {.1, .1}},
Graphics[{Gray, Disk[]}],
AutoAction -> True, LocatorAutoCreate -> {All}]
How do you change the $ContextPath of a cell without using Prepend:
$ContextPath = Prepend[$ContextPath, "PackageName`"]
I was looking around at the Documentation for $ContextPath and I decided to evaluate the first input cell in there.
Before Evaluation:
After Evaluation:
I'm guessing that the difference here is that when this documentation was being written WebServices was not enabled for the person writing it. We can see that Global is in the context of that cell because this has been explicitly mentioned. Look at the expression by going to Cell > Show Expression.
The option CellContext is set to Global. Now, lets make a new cell and evaluate $Context.
This means that inside that cell I cannot use any of the global objects that I have created in other notebooks. We can maybe add Global by changing the CellContext option of the cell. We do this by showing the expression and editing. When you evaluate you will see that the context has changed to global. Now, just for the heck of it lets try this in the cell in which we just changed the context to global.
Print["Outside Module = ", $ContextPath]
Module[{},
Print["Inside Module = ", $ContextPath];
Manipulate[
Print["Inside Manipulate = ", $ContextPath];
Row[{
Plot[x, {x, -3, 3}, PlotRange -> {{-3, 3}, {-3, 3}}]
}],
{{p1, {-1, 2}}, Locator, Appearance -> "L1"}
]
]
Do you get something like this:
Why does the context change inside Manipulate? Inside other notebooks this doesn't happen. I'm guessing it has to do with the settings of the reference stylesheet but I just can't figure it out. How can we change the settings of the documenation notebook temporarly so that we can use the global context everywhere throughout the notebook?
So, if I understand you correctly, you're running some commands in a documentation center notebook - and you don't understand the behaviour of context?
The documentation center uses a style sheet (Reference.nb) where the Cell[StyleData["Input"]... has the option CellContext->CellGroup. This can also be seen using the Option Inspector on the pages of the documentation center:
This setting is really hand for the documentation center, since it means that all of the examples in there won't interfere with each other or with your Global` definitions.
You can also set the default context for any particular notebook via the Evaluation menu:
In this simple control object in mathematica like the following,
Control[{x, 0, 1}]
we have to bring the mouse pointer to the right upper corner of the object to get the hint called "Show Animation Controls" and then click it to see the animation controls like play, step forward etc. Is there a way by setting some options to get all the animation controls OPEN by default so that when one opens a notebook containing dynamic object the animation controls remains open?
Anybody knows such a magic option in Mathematica?
As suggested the following code from documentation center
Manipulator[0.3, Appearance -> "Open"]
looks fine and does suits my purpose but how the same can be done with in the following? How can we keep the animation control in Manipulate open by default?
Manipulate[Plot[Sin[a x + b], {x, 0, 6}], {a, 1, 4}, {b, 0, 10}]
This was my actual question that still baffles me unfortunately.
For example, Manipulator[Dynamic[x], {0, 2}, Appearance \[Rule] "Open"].
Can you give more details on what you are trying to do?
EDIT: Does this
Manipulate[
Plot[Sin[a x + b], {x, 0, 6}],
{a, 1, 4, Appearance \[Rule] "Open"}, {b, 0, 10, Appearance \[Rule] "Open"}]
do what you want?
Control is a magical command which guesses the type of controller you want from the arguments you give it. The default one you produced with Control[{x,0,1}] is actually a Manipulator - to have it open from the start you want
Manipulator[x, {0, 1}, Appearance -> "Open"]
Of course x should normally by a Dynamic object.
Another option, if you really want to have a control to simply animate something, is to use
Animator[Dynamic[x], {0, 1}, (*AnimationRunning -> False*)]
where you can uncomment the option if you don't want the animation running when the output is created.
Aside: I had completely misread what acl said in his answer - and it turned out to be the same as what I ended up saing. I should probably just move my comments to a comment in his answer...
When Mathematica evaluates a cell, it gives the Input cell and Output cell the CellLabels In[$Line]:= and Out[$Line]= where $Line is a counter that gets incremented on each evaluated input.
If you input something like TraditionalForm[expr] or TeXForm[expr] (or any other *Form from $OutputForms) then the name of the form also gets added to the Output cell's label. eg Out[1]//TraditionalForm=.
I can't find any way of customising these labels.
They can be disabled in the Preferences dialog.
They don't seem to be in the
StyleSheet options for Input and
Output cells - although the options
pertaining to the CellLabel behaviour
are there.
Nor in the Notebook options -
although in the Option Inspector: Notebook Options >
Evaluation Options >
EvaluationCompletionAction can modify
the CellLabels by adding a TimeStamp.
It can also show the Timing in the StatusArea,
bit it gets removed as soon as something else prints there.
Nor any of the init.m type
configuration files.
So, does anyone know where these CellLabels are generated?
In particular, I am interested in adding the Timing to the CellLabel for Output cells.
Another way of doing this would be to set EvaluationCompletionAction -> "ShowTiming" which will display timing information in the status bar of the notebook window after each evaluation.
OK, the discussion on Physics Forums has lead to this quite hackish solution (now cleaned up a little):
SetAttributes[Timeit, HoldAll]
Timeit[x_] := With[{t = Timing[x]}, Module[{out, form},
If[TrueQ[MemberQ[$OutputForms, Head[t[[2]]]]],
out = First[t[[2]]]; form = "//" <> ToString[Head[t[[2]]]],
out = t[[2]]; form = ""];
If[out === Null, Null,
CellPrint[ExpressionCell[t[[2]], "Output", CellLabelAutoDelete -> False,
CellLabel -> StringJoin["(", ToString[t[[1]]], ")",
"Out[", ToString[$Line], "]", form, "="]]];
Unprotect[Out]; Out[$Line] = out; Protect[Out]; out;]];]
$Pre = Timeit;
To make the CellLabels persistent so that you don't lose the timing when you Save and Load the notebook, you can modify the stylesheet so that the Output cells have the option CellLabelAutoDelete -> True. (Edit: Now added to the CellPrint command.)
Any better solutions are more than welcome.
It's possible to add evaluation timestamps to Mathematica cell labels by selecting "AddTimeStamp" in the option inspector settings for EvaluationCompletionAction. Moreover, a list of options can be given by editing the entry, so using {"ShowTiming","AddTimeStamp"} I get both an evaluation duration in the status bar and input and output timestamps in the cell labels.