comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Updating existing IDL table widget
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Updating existing IDL table widget [message #31371] Wed, 10 July 2002 12:41
MKatz843 is currently offline  MKatz843
Messages: 98
Registered: March 2002
Member
> ColLabels = SINDGEN(5) & ColLabels(0) = STRING('Slice location') &
> ColLabels(1)= STRING('Slice number') &
> ColLabels(2)=STRING('Concentration') & ColLabels(3)=STRING('Approx.
> dia') & ColLabels(4)=STRING('Vol. sig.> bg')

I can't help you with the WIDGET_TABLE, but I can offser some
unsolicited IDL advice. You might consider re-writing the above code
to look like so...

ColLabels = ['Slice location', 'Slice number', 'Concentration',
'Approx. dia', 'Vol. sig.> bg']

In IDL, the pre-definition of arrays isn't required. Also the STRING()
typecast isn't required unless you're changing data from one type to
another (e.g. numeric to string).

Once ColLabels is defined, you can add Column Labels with this

ColLabels = [ColLabels, 'New Label']

and repeat that as much as you'd like, appending new elements each
time.

M. Katz
Re: Updating existing IDL table widget [message #31373 is a reply to message #31371] Wed, 10 July 2002 11:12 Go to previous message
Rick Towler is currently offline  Rick Towler
Messages: 821
Registered: August 1998
Senior Member
"Heather Williams" <heather.williams@physics.cr.man.ac.uk> wrote

> This table is initially blank, but I then want to add a new row of
> data to every time a particular .pro is run, so I can see the results
> I have as I go along. I then want to export data within the completed
> table in a format which can be read by Microsoft Excel, as I already
> have a spreadsheet which does further (graphical) analysis very
> nicely.


What platform and version? If you are not on win32 (or are opposed to a
platform specific solution) continue to use widget_table and look at
write_sylk to export you data to excel. For mixed data types you will need
to pass write_sylk an array of structures:

ok=write_sylk('test.slk',[{a:'cows',b:3.0},{a:'moo',b:2.0}])

The problem with comma delimited text files is that you will have to
"import" them into excel. Sylk files load just like an .xls file.


For the adventurous, in 5.5 on win32 (NT/2000) you could skip the table and
go straight to excel by using widget_activex. Look at the "Using ActiveX
controls in IDL" in the "What's new in 5.5" .pdf in your IDL docs directory.
There is an example of embedding an excel worksheet. I have included a few
properties and a method that aren't in the example. The "export" method is
key, you need it to save your data.

This example requires win2k and office2k. Earlier versions of office
probably have a excel worksheet control that you can insert but you will
have to find the class ID.


pro excel_test

;define the top level base widget and some menu bar items
tlb=widget_base(column=1, title='ActiveX Test')

;create an excel worksheet object
wAx=WIDGET_ACTIVEX(tlb, '{0002E510-0000-0000-C000-000000000046}', $
scr_xsize=800, scr_ysize=600)

WIDGET_CONTROL, tlb, /REALIZE

;get the excel control object reference
WIDGET_CONTROL, wAx, GET_VALUE = oAx

;remove the title bar
oax -> setproperty, displaytitlebar=0, enableevents=0

;other properties you may want to fool with:
;displaycolheaders
;displayhorizontalscrollbar
;displayrowheaders
;displaytoolbars
;displayverticalscrollbar


;main program action goes here

;add your data into the table following the example
;in what's new in 5.5


;when you are ready, save the data...

;get the activesheet object
oax -> getproperty, activesheet=asheet

;export the data to disk
asheet -> export, 'test.xls'
obj_destroy, asheet

;you may wish to stop things here to take a look
;stop

widget_control, tlb, /destroy

end

There are some memory management issues that I just ignored for this
example. You will notice that a few objects aren't cleaned up properly.
Who knows where they come from, but a little bit of sleuthing would probably
solve this problem.


This might not be for the faint of heart but it certainly wins in the style
points competition!


-Rick
Re: Updating existing IDL table widget [message #31379 is a reply to message #31373] Wed, 10 July 2002 06:35 Go to previous message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Heather Williams wrote:
>
> I have set up an IDL table widget within a larger IDL widget, like so:
>
> ColLabels = SINDGEN(5) & ColLabels(0) = STRING('Slice location') &
> ColLabels(1)= STRING('Slice number') &
> ColLabels(2)=STRING('Concentration') & ColLabels(3)=STRING('Approx.
> dia') & ColLabels(4)=STRING('Vol. sig.> bg')
> RoiDataTable = WIDGET_TABLE(roiBaseG, ALIGNMENT=1,
> COLUMN_LABELS=ColLabels, COLUMN_WIDTHS=(width*1.5)/5, EDITABLE=1,
> RESIZEABLE_COLUMNS=1, RESIZEABLE_ROWS=1, SCR_XSIZE=width*1.5, XSIZE=5,
> YSIZE=10)
>
> This table is initially blank, but I then want to add a new row of
> data to every time a particular .pro is run, so I can see the results
> I have as I go along. I then want to export data within the completed
> table in a format which can be read by Microsoft Excel, as I already
> have a spreadsheet which does further (graphical) analysis very
> nicely.

Dear Heather

Are you sure? I have never seen nice or very nice graphical analysis
by excel. IDL stands for Interactive Data Language. There is no limit
in interpretation, analysis or visualisation of data by idl.


PRO wid_test

tab=CREATE_STRUCT(name='slice','location',0.0,$
'number',0L,$
'concentration',0.0,$
'dia', 0L,$
'vol',0.0)

b=WIDGET_BASE()
t=WIDGET_TABLE(b,value=tab,uname='tab')
WIDGET_CONTROL,b,/realize

FOR i=0,10 DO BEGIN
WAIT,1
new_tab={slice}

new_tab.location=5.5+i
new_tab.number=10+i
new_tab.concentration=3.7+i
new_tab.dia=1+i
new_tab.vol=2+i

tab=[tab,new_tab]
WIDGET_CONTROL,t,set_value=tab

WIDGET_CONTROL,t,ysize=N_ELEMENTS(tab)
WIDGET_CONTROL,t,set_value=tab

WIDGET_CONTROL,t,column_labels=TAG_NAMES(tab)
ENDFOR

result=STRING(tab.(0))+','+STRING(tab.(1))+','+$
STRING(tab.(2))+','+STRING(tab.(3))+','+$
STRING(tab.(4))

OPENW,lun,'file.csv',/GET_LUN
PRINTF,lun,result
FREE_LUN,lun

END



>
> After several hours of trying various WIDGET CONTROL commands, setting
> VALUE equal to an array I then edit, etc. etc. I have been unable to
> add any data to this table. Looking at the past mailings, it seems
> these problems are not uncommon and many of you recommend avoiding
> widget tables altogether. Your advice as to how to display this data
> as it is acquired and then export it (with or without the use of
> widget table) would be much appreciated.

The table is quite new I believe only 3 years old. Most other widget
elements are known very well.

My example uses an arrayed structure, then the tabular column types
could be different. A comma separated list should be readable by excel
if it's not to long. There is a limit by 65534 lines for Excel.

All operation which you are known by clicks from ms software
could be simple commands in the script. Normally routines I wrote got no
interactive interface. Because if a user request has do be done by
someone
he or she all the time has to interact with the job the computer
normally could
do itself. Many of our routines can run with different data on several
computers
without an operator sitting behind a screen.
There are several ways to share input data with idl processes or idl
routines.


If you are interested in our idl library you'll get it from
http://www.fz-juelich.de/icg/icg-i/idl_icglib/idl_lib_intro. html


best regards

Reimar



>
> I look forward to hearing from you!
>
> Heather Williams
> Manchester PET Centre, UK

--
Reimar Bauer

Institut fuer Stratosphaerische Chemie (ICG-I)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
------------------------------------------------------------ -------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml
============================================================ =======
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Using idlrt.exe
Next Topic: Executable

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 03:35:52 PDT 2025

Total time taken to generate the page: 0.96172 seconds