MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Creating dialogs, right-aligning buttons

  • To: mathgroup at
  • Subject: [mg123943] Creating dialogs, right-aligning buttons
  • From: Szabolcs Horvát <szhorvat at>
  • Date: Sun, 1 Jan 2012 02:28:04 -0500 (EST)
  • Delivered-to:


What is the best way to create dialogs and align the different UI 
elements in them?

In particular, how can I create a dialog with right-aligned OK and 
Cancel buttons?

Here's a simplified model of what I'm actually doing:

image = Rasterize@ExampleData[{"AerialImage", "Earth"}]

   {"Some message here",
    image, (* this is obtained from Rasterize *)
    ChoiceButtons[{"Do it!"}, {doIt[]; DialogReturn[]}]}

Problems with this approach:

  * How can I right-align the buttons without
    right-aligning all other elements?

  * I do not know the size of the image beforehand.  It may be
    taller than the screen in my application.  In this case
    it will push the buttons off-screen.
    How can I protect against this?

There seem to be many ways to create dialogs in Mathematica.  There's 
CreateDialog (shown here), MessageDialog (which makes ugly small buttons 
where there's more than one button, and I'm having problems controlling 
the window size), ChoiceDialog (the buttons return values instead of 
doing something).

Can you show me example code based on the model above, with its problems 

Szabolcs Horvát
Mma QA site proposal:

  • Prev by Date: Does this make sense?
  • Next by Date: Erf funcion
  • Previous by thread: Re: Does this make sense?
  • Next by thread: Re: Creating dialogs, right-aligning buttons