Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #7502 > unrolled thread

Creating dialogs, right-aligning buttons

Started bySzabolcs Horvát <szhorvat@gmail.com>
First post2012-01-01 07:29 +0000
Last post2012-01-02 07:46 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Creating dialogs, right-aligning buttons Szabolcs Horvát <szhorvat@gmail.com> - 2012-01-01 07:29 +0000
    Re: Creating dialogs, right-aligning buttons Armand Tamzarian <mike.honeychurch@gmail.com> - 2012-01-02 07:46 +0000

#7502 — Creating dialogs, right-aligning buttons

FromSzabolcs Horvát <szhorvat@gmail.com>
Date2012-01-01 07:29 +0000
SubjectCreating dialogs, right-aligning buttons
Message-ID<jdp21c$rp6$1@smc.vnet.net>
Hello,

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"}]

CreateDialog[
  Column[
   {"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 
fixed?


-- 
Szabolcs Horvát
Mma QA site proposal: http://area51.stackexchange.com/proposals/37304

[toc] | [next] | [standalone]


#7526

FromArmand Tamzarian <mike.honeychurch@gmail.com>
Date2012-01-02 07:46 +0000
Message-ID<jdrncu$8vp$1@smc.vnet.net>
In reply to#7502
On Jan 1, 6:29 pm, Szabolcs Horv=E1t <szhor...@gmail.com> wrote:
> Hello,
>
> 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"}]
>
> CreateDialog[
>   Column[
>    {"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
> fixed?
>
> --
> Szabolcs Horv=E1t
> Mma QA site proposal:http://area51.stackexchange.com/proposals/37304


Use Grid for this:

CreateDialog[
Grid[{
   {"Some message here"},
  {image},
   {Item[ChoiceButtons[{"Do it!"}, {doIt[]; DialogReturn[]}],
Alignment -> Right]}
   }, Alignment -> {Left, Center}]
]


Mike

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web