Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a stand alone Manipulator (it is not in a Manipulate) and would like to know how to alter the style of the label. There are no explicit styling options for Manipulator so I tried wrapping it in Style:

Style[
 Manipulator[0.5, AppearanceElements -> None,
  Appearance -> {"Labeled"}, ImageSize -> Small],
 FontSize -> 20]

this didn't work.

I have also noticed that I cannot set an image size other than a named size. In other words ImageSize does not accept a number!

Manipulator[0.5, AppearanceElements -> None,
  Appearance -> {"Labeled"}, ImageSize -> 100]

and

Manipulator[0.5, AppearanceElements -> None,
  Appearance -> {"Labeled"}, ImageSize -> 400]

produce the same output. Are these issues possible bugs or am I overlooking something?

Q1. How can I change the font size (and other font styling but mainly font size) for the Manipulator label?

Q2. How can I make ImageSize accept a number rather than a name?

Edit

My question is not about what alternatives exist to using Manipulator. I have posted an example with AppearanceElements -> None so as to make the label the sole focus. However I want the possibility of being able to add back in the AppearanceElements is desired/required. The setting AppearanceElements -> None obviously looks like a stand alone slider and has led to readers thinking in terms of sliders rather than "fixing" the Manipulator.

Edit #2

In situations when no Manipulator controls are wanted Slider is an alternative but it also has some strange behaviour:

Framed@Slider[Dynamic[x], Appearance -> "Labeled", BaseStyle -> FontSize -> 20, ImageSize -> 100]
Framed@Slider[Dynamic[x], Appearance -> "Labeled", BaseStyle -> FontSize -> 20, ImageSize -> 200]

enter image description here

So it appears that the label occupies the same image size as the slider! This presents a problem in a GUI layout but there is a work around:

Framed@Pane[Slider[Dynamic[x], Appearance -> "Labeled", 
BaseStyle -> FontSize -> 20, ImageSize -> 200], ImageSize -> 260]

enter image description here

But the image space allocated to the label looks like a bug or something unintended. This doesn't address my question but I add it here because slider answered have been given.

FWIW:

enter image description here

Edit #3

Tech support confirm that the strange image sizing for Slider when a label is used is a bug.

share|improve this question
2  
You may have checked it already, but inspecting the code for Manipulator04 in the file MiscExpressions.tr in $InstallationDirectory/SystemFiles/FrontEnd/TextResources directory may suggest an explanation for your frustrations. Basically, several parts of the elements you wish to control (such as FontSize, InlineInputField and InputField sizes with option settings are hard coded in Manipulator04. The code is not too long, and perhaps, with some effort, you can modify it make your own custom manipulator and/or define your custom styledata to use as the setting for BaseStyle ... –  kguler Jun 25 '12 at 7:38
    
I think I found the code fragment: If[#9,{InputFieldBox[#1, Expression,FieldSize -> {{4,10},{1,2}},Enabled -> #6,Appearance -> {"Frameless", #8},BaseStyle -> "Manipulator"]}, {}]... But when I changed it in a text editor Mma wouldn't start up. It suggests that a stylesheet is the only way to change this. –  Mike Honeychurch Jun 25 '12 at 8:15
add comment

5 Answers

I suppose you could roll your own, as in

s = 0.5;
Row[{Manipulator[Dynamic[s]], " ", 
  Style[Dynamic[s], FontSize -> 16]}]
share|improve this answer
add comment

Use Slider in which case you can use numerical values for ImageSize.

Row[{Slider[Dynamic[n], {0, 100, 1}, ImageSize -> {150, 50}, 
   ImageMargins -> 10], Style[Dynamic[n], FontSize -> 16]}]
share|improve this answer
add comment

A Slider seems to have the options you want

Slider[0.5, Appearance -> "Labeled", BaseStyle -> FontSize -> 20, ImageSize -> 100]

enter image description here

I'm not sure of the differences between a Slider and a Manipulator

share|improve this answer
    
@belisarius I humbly apologize to those who posted alternatives for my criticism of the alternatives. –  Mike Honeychurch Jun 25 '12 at 3:31
    
If you want to play the reputation game, there's a lot of time pressure to get an answer in. You will always have to expect a bunch of quick, incomplete and approximate answers. –  wxffles Jun 25 '12 at 3:41
    
@wxffles I can't speak for others but when I post a question I am looking for a considered answer not the fastest answer. No offense but posting the first thing that comes into your head is unhelpful ...as you can also see from my own edits and comments -- which also added nothing to the discussion. –  Mike Honeychurch Jun 25 '12 at 3:45
    
@ wxffles your first comment seems now appearing out of thin air –  belisarius Jun 25 '12 at 4:48
    
@MikeHoneychurch I edited the post for you –  belisarius Jun 25 '12 at 5:05
show 1 more comment

To add to the spectrum of solutions here I suggest these approaches.

1) ----------- Magnify -----------

Magnify will uniformly change the size of Manipulator, its numeric label and everything that is related to that. It will work inside an interface too:

Manipulate[

 DynamicModule[{f = 1}, 
  Column@{Magnify[
     Manipulator[Dynamic[f], {0.25, 5}, AppearanceElements -> None, 
      Appearance -> "Labeled"], x], 
    Dynamic[Plot[Sin[f x], {x, -2 \[Pi], 2 \[Pi]}, ImageSize -> 500]]}]

 , {{x, 1, "Magnification of Manipulator"}, .5, 2, 
  Appearance -> "Labeled"}]

enter image description here

Disadvantage of course is that you cannot change the size of individual elements separately.

2) ----------- Ctrl+Shift+E -----------

I figured it out only for the Manipulator ImageSize, not the label. Maybe it is possible for label too. When you get you Manipulator select its cell, press CTRL+SHIFT+E, put numeric size as shown below, press CTRL+SHIFT+E again.

enter image description here

share|improve this answer
    
The Magnify approach doesn't fly, since as you have observed it magnifies the entire Manipulator. The ShowExpression stuff is interesting for trying to understand how this works -- but I'm not sure how it could be used for writing code. I guess you could do a replace on the underlying expression once the GUI has been generated. There doesn't seem to be anything that looks like a label size in the underlying expression (?) –  Mike Honeychurch Jun 25 '12 at 6:18
    
@MikeHoneychurch yeah, Magnify is too constrained, but is a nice thing to know. Especially for people who need simpler things. Neat that it works inside interfaces. I could not track the label style either. Future will tell. –  Vitaliy Kaurov Jun 25 '12 at 7:05
    
I'm logging it with tech support along with what looks to be the slider imagesize bug. –  Mike Honeychurch Jun 25 '12 at 7:07
add comment
up vote 7 down vote accepted

Based on the code digging by @kguler the internal code controlling this is:

FEPrivate`If[#9, {InputFieldBox[#1, Expression, 
   FieldSize -> {{4, 10}, {1, 2}}, Enabled -> #6, 
   Appearance -> {"Frameless", #8}, BaseStyle -> "Manipulator"]}, {}]

so it looks like you can change some of this via a style sheet -- for a notebook wide solution:

Cell[StyleData["Manipulator"],
 FontSize->18,
 Background->RGBColor[1,1,0]]

enter image description here

This still has its obvious limitations: it is notebook wide not local, (and if you wanted to adjust FieldSize to you can't), and the image size problem can't be solved by this approach. I don't regard this as a complete answer to the question but may be of interest.

Edit

Tech support confirm what can be inferred from the code that @kguler found -- namely that the label styling and numerical image size can not be set by the user programmatically.

To alter the label you have to use a stylesheet as per this answer. To alter the image size you would have to do that by changing the underlying expression in the output cell as per @Vitaliy's answer.

share|improve this answer
    
Looks like time to Accept this one to me. :-) –  Mr.Wizard Jun 30 '12 at 7:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.