Skip to main content
12 of 24
added 1044 characters in body
Kuba
  • 137.7k
  • 13
  • 289
  • 751

Guidelines for planning custom GUI in Mathematica

##Intro

Usually I don't have to care (it hurts my brain though) about misaligned details, additional/missing pixels. But currently I'm participating in a project where the design matters and I have to follow examples made by a graphics designer.

I have to workaround 10 "features" per hour, and I'm not talking about fancy stuff.

##Let me show you couple of examples:

  • ###MMA doesn't care about your resolution (dpi):

Unless you force it, but are you allowed to do this for the customer front end?

Let's say you have to create something according to the plan with pixel measures, do you know that MMA assumes you have 72dpi screen?

Fontsize is too small

What is a printer's point?

  • ###Painful mix of units

    Printer points and font size units (good luck with tracking what is the current one) are only options. And not both but you have to align two different worlds.

    How to convert between various ItemSize/ImageSize units?

  • ###Lack of full control/documentation of Kernel initialization/deinitialization:

Handling Kernel start. Autoload place in init stack.

Handling Kernel quit

How to clean up after a package?

[...] What you cannot do is to make assumptions about the order in which subsequent DynamicModule or Dynamic expressions will fire, or even if they will fire (if they're not in the same position). [...] [...] NotebookDynamicExpression not firing in new kernel sessions [...]

  • ###Dynamic based GUI will not digest Kernel quit well, and you can't do much about that because of the previous point.

Dynamic cells after Kernel restart/quit.

  • ###Ignored options

    Grid - problem with ItemSize being ignored

    SetOptions[GraphicsGrid, Frame -> True]; GraphicsGrid@Array[Graphics@Circle[] &, {2, 2}]

     ![Mathematica graphics](https://i.sstatic.net/Q8Mog.png)
    
  • ###Misaligned frames:

      test = Framed[  "TEST",
        Background -> Red, FrameStyle -> Blue, ImageSize -> {100, 100}
      ]
    

enter image description here

  • ###Lack of a precise control over the output size:

      ImageDimensions @ Rasterize @ %
    
 {100, 102} (*I could live with {102, 102} ... *)
  • ###Additional pixels everywhere:

      test = Framed[   "TEST",   Background -> Red,   FrameStyle -> #  ] &;
    
      Column[{
          #, #,
          Column[{#, #}, Spacings -> 0]
         }, Spacings -> 0] & /@ {test[Blue], test[None]}
    

enter image description here

  • ###"Features" everywhere

When you go with bitmap based GUI you think it's going to be lovely day, and then e.g. Grid cuts my images or Transparent bitmaps in controllers bug..

TabView Alignment problem for content larger than a view area

Notebook's WindowSize interference with contents' Dynamic ImageSizes

Problem with CurrentValue["MouseOver"] and Deploy

Create a notebook and save it without prompting Dynamics

  • ###OS dependent features

From my experience it is impossible to create precise GUI for Win and Mac. Not all features are OS dependent, and often workaround for one will give you headache in the other.

Grid layout problems: different sizes when rendering on Mac and Windows


Give me couple of days and I will make this post 3 times bigger (just saying, don't have time for that).

##Question

Are there any guidelines to make GUI creation process more stable?

Quick workarounds are not general enough and I don't have time to spend 1 day to align a simple grid.

If not, what should I tell the designer/manager about requirements?

People are used to the fact that you can create very nice layout with css in no time, how to explain that it is impossible, or not worth the time spent, in Mathematica? How to explain why getting rid of "white line" in some secondary menu took me half a day, and I've failed?

Kuba
  • 137.7k
  • 13
  • 289
  • 751