Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: Re: text size in GUIKit

  • To: mathgroup at
  • Subject: [mg50972] Re: [mg50872] Re: [mg50862] text size in GUIKit
  • From: Jeff Adams <jeffa at>
  • Date: Thu, 30 Sep 2004 04:52:18 -0400 (EDT)
  • References: <> <> <>
  • Sender: owner-wri-mathgroup at

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.


Valid GUiKit widget definitions are defined with a small set of valid 
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:

   Widget["Panel", {
    {Widget["Label", {"text" -> "Input:"}, Name -> "myLabel"],
     Widget["TextField", {"text" -> "Some text.", "columns" -> 12}]},
      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 
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:

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

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