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

Home » Public Forums » archive » Re: CW_FORM: Can't seem to get SET_VALUE to work
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: CW_FORM: Can't seem to get SET_VALUE to work [message #41370] Tue, 26 October 2004 04:53
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Lloyd Watkin writes:

> One question being, how do I get the data out?

One thing at a time, Lloyd, one thing at a time!

> I'm assuming it's something along the lines of
> widget_control,species,uvalue=species1 but I haven't had much contact
> with all this widget stuff so have no idea (only looked at a structure
> for the first time yesterday!).

Oh, dear. Lot's to learn this week, then. :-)

I think what you are looking for is a way to write
what is sometimes called a popup or modal dialog
widget. Something you can call to collect information
from the user and return it to you.

Here is an example of a very simple one:

http://www.dfanning.com/widget_tips/popup.html

I think you will find the code easy to extend to
your needs. But, if not, then just keep asking
questions. :-)

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http:/www.dfanning.com/
Phone: 970-221-0438, IDL Book Orders: 1-888-461-0155
Re: CW_FORM: Can't seem to get SET_VALUE to work [message #41371 is a reply to message #41370] Tue, 26 October 2004 03:18 Go to previous message
lloyd is currently offline  lloyd
Messages: 16
Registered: February 2003
Junior Member
Andrew,

That's really great.

One question being, how do I get the data out?

I'm assuming it's something along the lines of
widget_control,species,uvalue=species1 but I haven't had much contact
with all this widget stuff so have no idea (only looked at a structure
for the first time yesterday!).

Thanks

Lloyd
Re: CW_FORM: Can't seem to get SET_VALUE to work [message #41374 is a reply to message #41371] Mon, 25 October 2004 17:40 Go to previous message
andrew.cool is currently offline  andrew.cool
Messages: 47
Registered: July 2003
Member
lloyd@evilprofessor.co.uk (Lloyd Watkin) wrote in message news:<c3f97ff.0410250640.61eab55e@posting.google.com>...
> Hi all,
>
> In advance, thanks for all the wonderful help that everyone always
> passes my way.
>
> I've started to venture into using CW_FORM to make quick forms for a
> program I am writing. I think I have it almost done. I have a couple
> of problems that I need to fix first though.
>
> I have two text fields into which I want to place values that the user
> can edit if they desire. Have placed the SET_VALUE keywords in, but am
> still not getting any values printed there! Any ideas (have posted the
> SHORT code at the end of this post).
>
> Also if anyone could help on getting my checkboxes to line up that
> would be great too.
>
> Thanks
>
> Lloyd Watkin

Hi Lloyd,

I've re-written your code to use CW_BGROUP (which seems to have a
slight
bug of its own), however I think the code is clearer and easier than
that
god-awful Cw_Form mush...

Andrew

Pro test_species_event,ev

widget_control,ev.id,Get_Uvalue = Uvalue
widget_control,ev.id,Get_Value = Value


Case Uvalue Of

'SPECIES SELECTION' : $
Begin
If ev.value EQ ' ' Then Begin
; dummy spacer button - now de-sensitised
return
Endif Else begin
print,'Selected species ' + ev.value
Endelse
End

'MAX STEP SIZE' : $
Begin
max_step_size = ev.value
print,'New Max Step Size = ',max_step_size
End


'MIN STEP SIZE' : $
Begin
min_step_size = ev.value
print,'New Min Step Size = ',min_step_size
End


'OK' : $
Begin
Widget_control,ev.top,/Destroy
End


'CANCEL' : $
Begin
Widget_control,ev.top,/Destroy
End



ELSE : Begin
Message,'Invalid Uvalue : ' + string(uvalue)
End

End ; of Case


End

;........................................................... ......................


pro test_species

; Revamp of Lloyd Watkins post. A.D. Cool DSTO Adelaide, Oz

max_step = 1.0e-1
min_step = 1.0e-9


species1 = ['H2O','CO2','O3','N2O','CO','CH4','O2']
species2 = ['NO','SO2','NO2','NH3','HNO3','OH','HF']
species3 = ['HCl','HBr','HI','ClO','OCS','H2CO','HOCl']
species4 = ['N2', 'HCN', 'CH3Cl', 'H2O2', 'C2H2', 'C2H6', 'PH3']
species5 = ['COF2','SF6','H2S','HCOOH','HO2','O','CIONO2']
;species6 = ['NO+','HOBr','C2H4','CH3OH']
; Hmmm. Needs padding out with dummy buttons - incorrect behaviour -
bug?
; I would have thought that the first 5 columns should all fill up
with
; 7 buttons?

species6 = ['NO+','HOBr','C2H4','CH3OH',' ',' ',' ']

btn_vals = [species1,species2,species3,species4,species5,species6]

TLB = Widget_base(/col,Title='Species test')
base1 = Widget_base(TLB,/row,/frame)

btn_grp = Cw_BGROUP(base1,btn_vals,Button_uvalue=btn_vals,col=6,/NONEX CLUSIVE,$
IDS =
species_ids,/NO_Release,Uvalue='SPECIES SELECTION')


base2 = Widget_base(TLB,/Col,/Frame)

Max_step_fd = $
CW_field(base2,/Return_events,/Floating,Title='Maximum Step Size',$
Value = max_step,Uvalue='MAX STEP SIZE')

Min_step_fd = $
CW_field(base2,/Return_events,/Floating,Title='Minimum Step Size',$
Value = min_step,Uvalue='MIN STEP SIZE')

base3 = Widget_base(TLB,/row,/Frame)

OK_id = Widget_Button(base3,Value='OK',Uvalue='OK')
Cancel_id = Widget_Button(base3,Value='Cancel',Uvalue='CANCEL')


widget_Control,tlb,/real

; de-sensitise dummy spacer buttons - possible bug in layout of
CW_BGROUP?

widget_control,species_ids(39),Sensitive=0
widget_control,species_ids(40),Sensitive=0
widget_control,species_ids(41),Sensitive=0


Xmanager, 'test_species', TLB

End
Re: CW_FORM: Can't seem to get SET_VALUE to work [message #41380 is a reply to message #41374] Mon, 25 October 2004 14:47 Go to previous message
Andrew Meigs is currently offline  Andrew Meigs
Messages: 8
Registered: November 2000
Junior Member
On Mon, 25 Oct 2004 07:40:26 -0700, Lloyd Watkin wrote:

> Hi all,
>
> In advance, thanks for all the wonderful help that everyone always
> passes my way.
>
> I've started to venture into using CW_FORM to make quick forms for a
> program I am writing. I think I have it almost done. I have a couple
> of problems that I need to fix first though.
>
> I have two text fields into which I want to place values that the user
> can edit if they desire. Have placed the SET_VALUE keywords in, but am
> still not getting any values printed there! Any ideas (have posted the
> SHORT code at the end of this post).
>
> Also if anyone could help on getting my checkboxes to line up that
> would be great too.
>
> Thanks
>
> Lloyd Watkin
>
> -----------------------------------------
> pro test3
>
> max_step = 1.0e-1
> min_step = 1.0e-9
>
> desc = [ $
> '0, LABEL, Choose which species to vary:, CENTER', $
> '1, BASE,, COLUMN=7, FRAME', $
> '0, BUTTON, H2O|CO2|O3|N2O|CO|CH4|O2,' $
> + 'ROW, TAG=species1', $
> '0, BUTTON, NO|SO2|NO2|NH3|HNO3|OH|HF,' $
> + 'ROW, TAG=species2', $
> '0, BUTTON, HCl|HBr|HI|ClO|OCS|H2CO|HOCl,' $
> + 'ROW, TAG=species3', $
> '0, BUTTON, N2|HCN|CH3Cl|H2O2|C2H2|C2H6|PH3,' $
> + 'ROW, TAG=species4', $
> '0, BUTTON, COF2|SF6|H2S|HCOOH|HO2|O|ClONO2,' $
> + 'ROW, TAG=species5', $
> '0, BUTTON, NO+|HOBr|C2H4|CH3OH,width=200,' $
> + 'ROW, TAG=species6', $
> '0, TEXT, , LABEL_LEFT=Maximum step size:,SET_VALUE=max_step,
> WIDTH=20' $
> + 'TAG=maxstep', $
> '0, INTEGER, 0, LABEL_LEFT=Minimum step size:,SET_VALUE=min_step,
> WIDTH=20, TAG=minstep', $
> '1, BASE,, ROW', $
> '0, BUTTON, OK, QUIT,CENTER,' $
> + 'TAG=OK', $
> '2, BUTTON, Cancel, QUIT, CENTER']
>
> a = CW_FORM(desc, /COLUMN)
>
> ;HELP, /STRUCTURE, a
>
> if (a.ok EQ 0) then retall ;User has cancelled the fit
>
> species = [a.species1,a.species2,a.species3,a.species4,a.species5,a.sp ecies6]
> print, species
> max_step = a.maxstep
> min_step = a.minstep
> print, minstep, maxstep
> stop
> end

Lloyd,

Without access to idl right now but access to some of my old programs that
use cw_form so I might be wrong but here goes:

At your initialization for the text field:
> '0, TEXT, , LABEL_LEFT=Maximum step size:,SET_VALUE=max_step,
> WIDTH=20' $
> + 'TAG=maxstep', $
You need a comma (,) following the WIDTH=20

Also I would not try to set the value in this step (don't even know if
that works with cw_form). I would however put a default value in the blank
value field '0, TEXT, **Here**, Label_left=... And then do the following:
WIDGET_CONTROL, a, set_value={species1:0, species2:0, species3:0, $
species4:0, species5:0, max_step:maxstep, minstep:min_step, ...}
after the a = cw_form() step. Not sure what the quit/ok button setting
should be hence the ... This will initialize all of the fields/droplists
to a default of the first element and set your max and min steps.

Hope this helps. In idl 5.3 or so I found that cw_form has a few bugs
especially relating to droplist setting. I haven't used it under 5.5 or
6.0 to see if they fixed the bug (I reported it then). My old code uses a
modified version of cw_form which I could send you if you find problems
with the droplists.

Andy
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: building a .sav file using a project with objects
Next Topic: Installing PostScript Fonts in IDL

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

Current Time: Wed Oct 08 16:00:30 PDT 2025

Total time taken to generate the page: 0.00695 seconds