Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*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 smc.vnet.net
  • Subject: [mg50958] Re: [mg50872] Re: [mg50862] text size in GUIKit
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Wed, 29 Sep 2004 03:15:41 -0400 (EDT)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <200409240841.EAA21793@smc.vnet.net> <200409250555.BAA05036@smc.vnet.net>
  • Reply-to: murray at math.umass.edu
  • Sender: owner-wri-mathgroup at wolfram.com

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.


Jeff Adams wrote:
> On Sep 24, 2004, at 3:41 AM, Murray Eisenberg wrote:
> 
> 
>>With the GUIKit, is there some way to force a larger font size for text
>>input fields?
> 
> 
> Hello,
> 
> Most widgets that display text have a "font" property that you can get 
> or set.
> 
> You can either construct a new instance of a font with an appropriate 
> call to
> Widget["Font", InitialArguments -> {...}] but normally you want to 
> modify the
> existing font used by the widget so that you preserve the chosen look 
> and feel
> font for any given platform.
> 
> A convenient method on Widget["Font"] is InvokeMethod[{font, 
> "deriveFont"}, fontSize_]
> which returns a new instance of the font with only the size changed.
> 
> Here are a few examples that modify this basic user interface:
> 
> GUIRun[
>    Widget["Panel", {
>        {Widget["Label", {"text" -> "Input:"}],
>          Widget["TextField", {"text" -> "Some text.",
>              "columns" -> 12}, Name -> "myText"]}
>        }, WidgetLayout -> {"Border" -> {{5, 5}, {5, 10}}}]
>    ]
> 
> to highlight how you can use the "deriveFont" method or create a
> new Widget["Font"] instance based on an existing font or constructed 
> anew:
> 
> In this first variant we use "deriveFont" with the default font of the 
> text field
> and change its font size to 36:
> 
> GUIRun[
>    Widget["Panel", {
>        {Widget["Label", {"text" -> "Input:"}],
>          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}}}]
>    ]
> 
> 
> Here, we construct a new instance of Widget["Font"] but use the 
> existing properties
> of the default font again, increasing its current size by 5:
> 
> GUIRun[
>    Widget["Panel", {
>        {Widget["Label", {"text" -> "Input:"}],
>          Widget["TextField", {"text" -> "Some text.",
>              "columns" -> 12}, Name -> "myText"]},
>        Script[
>          fnt = PropertyValue[{"myText", "font"}];
>          args = {PropertyValue[{fnt, "fontName"}], PropertyValue[{fnt, 
> "style"}],
>              PropertyValue[{fnt, "size"}] + 5};
>          newFnt = Widget["Font", InitialArguments -> args];
>          SetPropertyValue[{"myText", "font"}, newFnt];
>          ]
>        }, WidgetLayout -> {"Border" -> {{5, 5}, {5, 10}}}]
>    ]
> 
> 
> Lastly, you can also construct a new font from literal names and sizes 
> though this
> may not work on all platforms depending upon what font names you use:
> 
> GUIRun[
>    Widget["Panel", {
>        {Widget["Label", {"text" -> "Input:"}],
>          Widget["TextField", {"text" -> "Some text.",
>              "columns" -> 12}, Name -> "myText"]},
>        Script[
>          args = {"Monospaced", PropertyValue[{"class:java.awt.Font", 
> "Bold"}], 18};
>          newFnt = Widget["Font", InitialArguments -> args];
>          SetPropertyValue[{"myText", "font"}, newFnt];
>          ]
>        }, WidgetLayout -> {"Border" -> {{5, 5}, {5, 10}}}]
>    ]
> 
> 
> In all cases above, once you construct a new font instance you can use 
> this single font and
> set it as the font property value for all or as many widgets in your 
> user interface as you want.
> You can also give this font instance a name using the Name -> "myFont" 
> option and
> reference this font in the rest of your user interface using a 
> WidgetReference["myFont"] call
> 
> Jeff Adams
> Wolfram Research
> 
> 

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305


  • Prev by Date: Re: problem with very slow matrix function
  • Next by Date: Re: Hyperbolic function identity
  • Previous by thread: Re: text size in GUIKit
  • Next by thread: Re: Re: text size in GUIKit