Re: text size in GUIKit
- To: mathgroup at smc.vnet.net
- Subject: [mg50872] Re: [mg50862] text size in GUIKit
- From: Jeff Adams <jeffa at wolfram.com>
- Date: Sat, 25 Sep 2004 01:55:12 -0400 (EDT)
- References: <200409240841.EAA21793@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
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
- Follow-Ups:
- Re: Re: text size in GUIKit
- From: Murray Eisenberg <murray@math.umass.edu>
- Re: Re: text size in GUIKit
- References:
- text size in GUIKit
- From: Murray Eisenberg <murray@math.umass.edu>
- text size in GUIKit