Re: widget with check table ?? [message #12590] |
Tue, 25 August 1998 00:00 |
J.D. Smith
Messages: 214 Registered: August 1996
|
Senior Member |
|
|
Martin Vissers wrote:
>
> I'm trying to create a dialog in which you can select
> several options within a table.
>
> Can this be done with widget programming ???
> an example:
>
> | AA | BB | CC |
> --------------------------|
> 1 | x | | |
> --------------------------|
> 2 | | | x |
> --------------------------|
> 3 | x | x | x |
> --------------------------|
> 4 | | | |
> --------------------------|
> 5 | | | x |
> --------------------------|
>
> so the user can select (with an x or a radio button) which
> options will be processed.
>
> Someone there with a good idea ???
How about the following:
pro testaw_event,ev
widget_control, ev.top, get_uvalue=barr,/NO_COPY
wh=where(ev.id eq barr) & wh=wh[0]
msg='Selected' & if ev.select eq 0 then msg='De-'+msg & msg=' '+msg
print,'ROW: '+strtrim(wh/3+1,2)+' COLUMN: '+ (['A','B','C'])[wh mod 3]+msg
widget_control, ev.top, set_uvalue=barr,/NO_COPY
end
pro testaw
b=widget_base(/COLUMN,/BASE_ALIGN_LEFT)
barr=lonarr(3,5)
lab=widget_label(b,value=string(FORMAT='(3A5)','A','B','C'))
for i=0,4 do begin
base=widget_base(b,/ROW)
lab=widget_label(base,value=string(i+1,FORMAT='(I1)'))
base=widget_base(base,/ROW,/NONEXCLUSIVE)
for j=0,2 do barr(j,i)=widget_button(base,value='')
endfor
widget_control, b,/REALIZE,set_uvalue=barr
XManager, 'testaw',b,/NO_BLOCK
end
Note that to get the column headings to line up we have to monkey with the
string format, and so the placement will depend on the font and system used. In
addition, to get buttons from row to row to line up, the row labels must occupy
the same space (which is easy enough to enforce for a mono-spaced font). This is
of course frustrating but I see no simple workaround. Likely a large amount of
code which test widget size and employs [XY]OFFSET could accomplish this in a
more portable way, but it would be ugly. This works well on my Linux IDL v5.1
with a mono-spaced font (10pt). To accomodate longer column headings you can
use spaces in the button values.
JD
--
J.D. Smith |*| WORK: (607) 255-5842
Cornell University Dept. of Astronomy |*| (607) 255-6263
304 Space Sciences Bldg. |*| FAX: (607) 255-5875
Ithaca, NY 14853 |*|
|
|
|
Re: widget with check table ?? [message #12592 is a reply to message #12590] |
Tue, 25 August 1998 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Martin Vissers (martin.vissers@users.whh.wau.nl) writes:
> I'm trying to create a dialog in which you can select
> several options within a table.
>
> Can this be done with widget programming ???
> an example:
>
> | AA | BB | CC |
> --------------------------|
> 1 | x | | |
> --------------------------|
> 2 | | | x |
> --------------------------|
> 3 | x | x | x |
> --------------------------|
> 4 | | | |
> --------------------------|
> 5 | | | x |
> --------------------------|
>
> so the user can select (with an x or a radio button) which
> options will be processed.
Oh, of course this can be done with widget programming. What can't? :-)
I would set the ALL_EVENTS keyword to 1 and turn off the
EDITABLE keyword. Then, when the user tries to type something
in the field I would know about it and write an X into the
field (no matter what they are trying to actually type).
The documentation says that the EDITABLE keyword suppresses
all events, but I am certain this is not true, and in any
case is belied by the little chart further in the documentation
that shows you how the two keywords interact.
If you would like to see an example of how to write an event
handler that works with ALL_EVENTS on and EDITABLE off, download
the program GETIMAGE from my web page and look at the module
GETIMAGE_INTEGER_ONLY. This event handler only allows the
user to type integer values into a text widget. The principle
here is exactly the same.
Cheers,
David
----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438, Toll-Free Book Orders: 1-888-461-0155
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|