MathGroup Archive 2004

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

Search the Archive

Re: Re: text size in GUIKit

  • To: mathgroup at smc.vnet.net
  • Subject: [mg50972] Re: [mg50872] Re: [mg50862] text size in GUIKit
  • From: Jeff Adams <jeffa at wolfram.com>
  • Date: Thu, 30 Sep 2004 04:52:18 -0400 (EDT)
  • References: <200409240841.EAA21793@smc.vnet.net> <200409250555.BAA05036@smc.vnet.net> <415A30FA.7020809@math.umass.edu>
  • Sender: owner-wri-mathgroup at wolfram.com

On Sep 28, 2004, at 10:50 PM, Murray Eisenberg wrote:

> OK.  But now how do I change the font size of a field label?
>
> I tried replacing the label with a StyleForm expression, but that is 
> not accepted.  For example, in your "first variant", I edited it to 
> be:
>
> GUIRun[
>    Widget["Panel", {
>        {Widget["Label", {"text" -> StyleForm["Input:", FontSize -> 
> 36]}],
>          Widget["TextField", {"text" -> "Some text.",
>              "columns" -> 12}, Name -> "myText"]},
>        Script[
>          fnt = PropertyValue[{"myText", "font"}];
>          newFnt = InvokeMethod[{fnt, "deriveFont"}, 36];
>          SetPropertyValue[{"myText", "font"}, newFnt];
>          ]
>        }, WidgetLayout -> {"Border" -> {{5, 5}, {5, 10}}}]
>    ]
>
> An error message ensued:
>
>    Widget::deferr: Input: is not valid GUI definition content.
>
> (with the word 'Input' in 36-point type!), and of course then the 
> subsequent error message:
>
>    GUIRun::nvalid: The GUI definition contains invalid content.

Hello,

Valid GUiKit widget definitions are defined with a small set of valid 
elements,
essentially made up of a hierarchy of Widget, PropertyValue, 
SetPropertyValue, BindEvent and Script expressions.
Arbitrary Mathematica code and symbols work within Script[] blocks but 
not a part
of the widget definition expression itself, which is the reason for the 
StyleForm error.

You can change the label's font in the same way you change the 
textfield's font
since most components that display text have a "font" property that you 
can set.

A quick change of the example by giving the label widget a name and 
setting its
"font" property is as follows:

GUIRun[
   Widget["Panel", {
    {Widget["Label", {"text" -> "Input:"}, Name -> "myLabel"],
     Widget["TextField", {"text" -> "Some text.", "columns" -> 12}]},
    Script[
      fnt = PropertyValue[{"myLabel", "font"}];
      newFnt = InvokeMethod[{fnt, "deriveFont"}, 36];
      SetPropertyValue[{"myLabel", "font"}, newFnt];
      ]},
   WidgetLayout -> {"Border" -> {{5, 5}, {5, 10}}}]
   ]

Another variant which I hinted at in the previous correspondence was 
that
you might want to define one named font and use this with multiple 
widgets within
one interface.  In the version below I create and name one instance of 
a new font
in one Script block and then refer to this named font when assigning it 
as the "font"
property to both the label and text field:

GUIRun[
   Widget["Panel", {
       {Widget["Label", {"text" -> "Input:"},
           Name -> "myLabel"],
         Widget["TextField", {"text" -> "Some text.", "columns" -> 12},
            Name -> "myText"]},
       Script[
         InvokeMethod[{
               PropertyValue[{"myLabel", "font"}], "deriveFont"}, 36,
             Name -> "sharedFont"];
         ],
       SetPropertyValue[{"myLabel", "font"}, 
WidgetReference["sharedFont"]],
       SetPropertyValue[{"myText", "font"}, 
WidgetReference["sharedFont"]]
       }, WidgetLayout -> {"Border" -> {{5, 5}, {5, 10}}}]
   ]


Thanks,
Jeff Adams
Wolfram Research



  • Prev by Date: Re: unevaluated, hold, holdform
  • Next by Date: Re: Newbie question about the behavior of NMaximize
  • Previous by thread: Re: Re: text size in GUIKit
  • Next by thread: Programing operations with lists