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$
  • 2
    $\begingroup$ What is your operating system and Mathematica version? I can use any button size on Linux. $\endgroup$ – ybeltukov Dec 2 '15 at 11:54
  • 2
    $\begingroup$ On Windows it works fine too. $\endgroup$ – Kuba Dec 2 '15 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$ – Michael McCain Dec 2 '15 at 12:01
  • 1
    $\begingroup$ Oops missed that. I'm running OS X 10.11.1 using Mathematica 10.3. $\endgroup$ – Michael McCain Dec 2 '15 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$ – Michael McCain Dec 2 '15 at 12:15
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$
  • $\begingroup$ The problem may be the lack of Method option $\endgroup$ – Kuba Dec 2 '15 at 14:04
  • $\begingroup$ @Kuba. That could be a problem, but not with the example the OP gives. $\endgroup$ – m_goldberg Dec 2 '15 at 14:18
  • $\begingroup$ Yep, just wanted to point that out. $\endgroup$ – Kuba Dec 2 '15 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$
  • $\begingroup$ Looks like a comment not an answer. $\endgroup$ – Kuba Dec 2 '15 at 11:57
  • $\begingroup$ Yes, but I couldn't see where I could upload an image inside comments. $\endgroup$ – Lotus Dec 2 '15 at 11:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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