3
$\begingroup$

I can't seem to figure out how to make the width of a Button smaller.

I tried change the first 26 below to a number like 10. But it doesn't seem to effect the width of the button. There seems to be a minimum size and won't let me make it any smaller. Can anyone help?

Button["C", Print[10!], ImageSize -> {26, 26}]
$\endgroup$
11
  • 2
    $\begingroup$ What is your operating system and Mathematica version? I can use any button size on Linux. $\endgroup$
    – ybeltukov
    Commented Dec 2, 2015 at 11:54
  • 2
    $\begingroup$ On Windows it works fine too. $\endgroup$
    – Kuba
    Commented Dec 2, 2015 at 11:58
  • $\begingroup$ This is strange. I typed in the exact same code. The height of my buttons change like yours but not the width. Any ideas? $\endgroup$
    – B flat
    Commented Dec 2, 2015 at 12:01
  • 1
    $\begingroup$ Oops missed that. I'm running OS X 10.11.1 using Mathematica 10.3. $\endgroup$
    – B flat
    Commented Dec 2, 2015 at 12:08
  • 1
    $\begingroup$ So I have a fix... if I change the appearance to "Palette" it works fine. I would have it appear as a button, but this will do unless anyone has any suggestions. $\endgroup$
    – B flat
    Commented Dec 2, 2015 at 12:15

3 Answers 3

1
$\begingroup$

Button Width cannot be minimized beyond a certain point when using an appearance of "Button". Consider using the appearance of "Pallete" to get smaller widths.

$\endgroup$
1
$\begingroup$

You can fake a button with a click pane, which will give complete control over appearance and has (almost) the same behavior as a button.

button =
  With[{size = {15, 30}},
    Graphics[
      {EdgeForm[Black], FaceForm[], 
       Rectangle[{0, 0}, size, RoundingRadius -> Scaled[.2]],
       Text["C", size/2]},
      ImageSize -> size]];

ClickPane[button, Print[10!] &]

button

3628800

$\endgroup$
3
  • $\begingroup$ The problem may be the lack of Method option $\endgroup$
    – Kuba
    Commented Dec 2, 2015 at 14:04
  • $\begingroup$ @Kuba. That could be a problem, but not with the example the OP gives. $\endgroup$
    – m_goldberg
    Commented Dec 2, 2015 at 14:18
  • $\begingroup$ Yep, just wanted to point that out. $\endgroup$
    – Kuba
    Commented Dec 2, 2015 at 14:21
0
$\begingroup$
Table[Button["C", Print[10!], ImageSize -> {k, k}], {k, 10, 50, 10}]

Seems to work for me ! I am using 10.3

enter image description here

$\endgroup$
2
  • $\begingroup$ Looks like a comment not an answer. $\endgroup$
    – Kuba
    Commented Dec 2, 2015 at 11:57
  • 1
    $\begingroup$ Yes, but I couldn't see where I could upload an image inside comments. $\endgroup$
    – Lotus
    Commented Dec 2, 2015 at 11:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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