Re: widget_text set_value problem [message #18091] |
Wed, 01 December 1999 00:00 |
Ralf Srama
Messages: 2 Registered: December 1999
|
Junior Member |
|
|
Hi Frank,
your string is not an array. It contains
only one element. You can look at the
variable "lines" with "help,lines".
You need to create an array of strings with e.g.
lines=strarr(10)
lines[0]='first line'
lines[1]='second line'
...
Then it should work.
Ralf
---------
Your example cannot work, your string it not
an array.
IDL> first_line='My first line'
IDL> separator=string(10b)
IDL> lines=string(first_line,separator,'My second line')
IDL> help,lines
LINES STRING = 'My first line
My second line'
IDL>
---------
p3qa3@yahoo.com wrote:
>
> Hi all,
> I want to set a value for a text widget. In my small example this is a
> strarr. I would like to make the widget displaying each string in the
> array in a separate line.
>
> <--------------- SNIP --------------->
>
>> myValue=('first_line','second_line','third_line')
>
>> wid_ID=widget_base()
>> wid_text_ID=widget_text(wid_ID,value=myValue,xsize=200,ysize =10)
>> widget_control,wid_ID,/realize
>
> <--------------- SNAP --------------->
>
> The widget shows the contents of the array in ONE line without newlines.
>
> I tried:
> a) using keywords on widget creation:
> /NO_NEWLINE
> /WRAP
> .... no change.
>
> b) creating a string that contains '\n' (string(10b))
>
> <--------------- SNIP --------------->
>
>> first_line='My first line'
>> separator=string(10b)
>> lines=string(first_line,separator,'My second line')
>> widget_control,wid_text_ID,set_value=lines
>
> <--------------- SNIP --------------->
>
> Now the text widget displays:
> 'My first line|My second line' still in one line.
>
>> print,lines
> results in the correct output.
>
> If I use
>
>> widget_info,wid_text_ID,get_value=myTestValue
>
> myTestValue contains a strarr(1), whatever the size of the original
> strarr
> was that has been used for the widget creation.
>
> Any suggestions/comments appreciated !!
>
> Regards, Frank
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
--
ralf.srama@mpi-hd.mpg.de Tel 49-6221 516 423 Fax 49-6221 516 324
Max-Planck-Institut fuer Kernphysik, Saupfercheckweg 1, 69117
Heidelberg, Germany
CDA-Homepage http://galileo.mpi-hd.mpg.de/cassini
Dust-Group http://galileo.mpi-hd.mpg.de
|
|
|
Re: widget_text set_value problem [message #18092 is a reply to message #18091] |
Wed, 01 December 1999 00:00  |
Marc Schellens
Messages: 14 Registered: November 1999
|
Junior Member |
|
|
p3qa3@yahoo.com wrote:
>
> Hi all,
> I want to set a value for a text widget. In my small example this is a
> strarr. I would like to make the widget displaying each string in the
> array in a separate line.
>
> <--------------- SNIP --------------->
>
>> myValue=('first_line','second_line','third_line')
>
>> wid_ID=widget_base()
>> wid_text_ID=widget_text(wid_ID,value=myValue,xsize=200,ysize =10)
>> widget_control,wid_ID,/realize
>
> <--------------- SNAP --------------->
>
> The widget shows the contents of the array in ONE line without newlines.
>
> I tried:
> a) using keywords on widget creation:
> /NO_NEWLINE
> /WRAP
> .... no change.
>
> b) creating a string that contains '\n' (string(10b))
>
> <--------------- SNIP --------------->
>
>> first_line='My first line'
>> separator=string(10b)
>> lines=string(first_line,separator,'My second line')
>> widget_control,wid_text_ID,set_value=lines
>
> <--------------- SNIP --------------->
>
> Now the text widget displays:
> 'My first line|My second line' still in one line.
>
>> print,lines
> results in the correct output.
>
> If I use
>
>> widget_info,wid_text_ID,get_value=myTestValue
>
> myTestValue contains a strarr(1), whatever the size of the original
> strarr
> was that has been used for the widget creation.
>
> Any suggestions/comments appreciated !!
>
I tried your example (replacing the "('first_line..." with
"['first_line...")
As what you wrote is syntactically not correct, I suspect that you
changed something before posting and did not really ues the posted code?
However for me it works fine under Solaris IDL 5.2.
Only I made the experience that if the widgets YSIZE is set to 1 I got
same behaviour as you.
:-) marc
|
|
|