1

Such details are driving me crazy while creating GUIs with Mathematica:

Panel[
  Panel["", Background -> Yellow, ImageMargins -> 0, ImageSize -> {26, 26}]
  , Background -> Black, Alignment -> Center]

enter image description here

Margins above are symmetric in vertical and horizontal direction, let's say I want to take control and specify FrameMargins:

Panel[
  Panel["", Background -> Yellow, ImageMargins -> 0, ImageSize -> {26, 26}]
  , Background -> Black, Alignment -> Center, FrameMargins -> {{1, 1}, {1, 1}}]

enter image description here

Now clearly they are not. I used 1 because then it is easily seen but the value does not matter.

Am I missing something?

Edit

With Framed it seems to be ok, but one have to add FrameStyle->None.

Kuba
  • 136,707
  • 13
  • 279
  • 740
  • 1
    On OS X, v 9.0.0.0 both examples are symmetric. Perhaps it is a bug with OS/MMA version that you're using. – C. E. Jan 13 '14 at 09:25
  • @Anon Probably, now I'm on winXP with MMA 9.0.1.0. – Kuba Jan 13 '14 at 09:27
  • 2
    it works ok on windows 7, V 9.01, screen shot: Mathematica graphics – Nasser Jan 13 '14 at 09:42
  • If you are using Panel with custom bg, it can be approximated with Graphics. Would this solve the problem? Graphics[{Black, Rectangle[{0, 0}, {26, 26}], Yellow, Rectangle[{0, 0} + 3, {26, 26} - 3]}, ImageSize -> 26, ImageMargins -> 0, ImagePadding -> 0] (related) – István Zachar Jan 13 '14 at 09:53
  • @IstvánZachar Only partially, now I have to care about image size when with Panel I didn't have to. – Kuba Jan 13 '14 at 10:45
  • 1
    I can reproduce this on Windows 2003. Very strange for this to be OS version-dependent. Same result in versions 8.0.4 and 7.0.1, albeit the asymmetry is less pronounced in the latter (the top margin is slightly thicker). – Oleksandr R. Jan 13 '14 at 10:51
  • 1
    I saw no problem with the FrameMargins version, when I evaluated it in V.9.0.1 on OS X 10.6.8 – m_goldberg Jan 13 '14 at 14:24
  • 1
    On Windows 7 x64 in MMa 8.0.4 both examples are symmetric. – Alexey Popkov Jan 13 '14 at 15:26

0 Answers0