[comp.windows.x] Writing text to a widget

brp@dino.berkeley.edu (Bruce Raoul Parnas) (02/06/91)

 this is probably easy to do, but i am having a great deal of trouble trying
to implement it.  i would like to output information to the user (much as
one would  do with printf statements) and have it displayed in a widget,
any widget.  the Athena text widget is much more than i need.  how does one
write a string of text to a widget, and continue to write strings on
successive lines as they become appropriate?

thanx,
bruce
(brp@bandit.berkeley.edu)

gildea@expo.lcs.mit.EDU (Stephen Gildea) (02/06/91)

    From: brp@dino.berkeley.edu (Bruce Raoul Parnas)

		      i would like to output information to the user (much as
    one would  do with printf statements) and have it displayed in a widget,
    any widget.  the Athena text widget is much more than i need.


Perhaps the Label widget is what you want.  You can use XtSetValues to
update the text displayed.  And as of R4, you can display multiple
lines of text.

However, think carefully about whether the Text widget isn't what you
really want.  If you use Label, your users won't be able to cut text
out of your window.  If you're going to keep the information on the
screen for very long, that is not very social...

 < Stephen
   MIT X Consortium

morreale@bierstadt.scd.ucar.EDU (Peter Morreale) (02/06/91)

In article <1991Feb6.015649.28798@agate.berkeley.edu> you write:
>
> this is probably easy to do, but i am having a great deal of trouble trying
>to implement it.  i would like to output information to the user (much as
>one would  do with printf statements) and have it displayed in a widget,
>any widget.  the Athena text widget is much more than i need.  how does one
>write a string of text to a widget, and continue to write strings on
>successive lines as they become appropriate?
>
>thanx,
>bruce
>(brp@bandit.berkeley.edu)

Sounds like you actually have two requests here.  One for a simple
widget to display messages, and another for a widget for appending text.

What I use for simple one line informative messages is a label widget.
It is intended for output strings only (no editing of the string) and I
get to have the string auto-centered.  To set the label:

	     XtSetArg(arg, XtNlabel, "string");
	     XtSetValues( <widget>, arg, 1);

You can also "clear" the widget by setting the string to a null string:

	     XtSetArg(arg, XtNlabel, "");

For the second, still use the text widget, but check out the 
routines:  XawTextSourceRead(), XawTextSourceReplace().  These functions 
allow you to read and replace (or append) portions of the text buffer.

I haven't used these functions directly, so I cannot send any code
samples...

Hope this helps,
-PWM

-- 
------------------------------------------------------------------
Peter W. Morreale                  email:  morreale@ncar.ucar.edu
Nat'l Center for Atmos Research    voice:  (303) 497-1293
Scientific Computing Division     
Consulting Office
------------------------------------------------------------------