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

Home » Public Forums » archive » Re: CW_FIELD question
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_FIELD question [message #54210] Sat, 26 May 2007 18:46
markb77 is currently offline  markb77
Messages: 217
Registered: July 2006
Senior Member
The programming weirdness continues! I am forging ahead with my non-
standard and completely upside down IDL programming style - ie. Widget
programs without a separate event handler. I have figured out a
couple of things about querying the state of TEXT and BUTTON widgets
without relying on events generated by them.

Check out this example:

PRO Example

tlb = Widget_Base(Column=1)

field1 = WIDGET_TEXT(tlb, /EDITABLE)

field2 = FSC_INPUTFIELD(tlb)

button_wid = CW_BGroup(tlb, 'SET', /Col, /NonExclusive, Set_Value
= 1)


WIDGET_CONTROL, tlb, /REALIZE
XManager, 'example', tlb, /NO_BLOCK

quita = 0


while quita ne 1 do begin

event2 = WIDGET_EVENT(button_wid, /NOWAIT)
event1 = WIDGET_EVENT(tlb, /NOWAIT)

WIDGET_CONTROL, field1, GET_VALUE=f1val

f2val = field2->Get_Value()

WIDGET_CONTROL, button_wid, GET_VALUE=bval

print, f1val, f2val, bval

if f1val eq 'q' then quita = 1

wait, .1

endwhile

WIDGET_CONTROL, tlb, /DESTROY

END


This fixes the earlier problem I had with not being able to read out
the value of FSC_INPUTFIELD, and a later problem I encountered where I
could not read out the current state of a checkbox button that I had
created with CW_BGROUP.

It seems that the presence of the calls to WIDGET_EVENT are necessary
for both of these things to work. Without the second call to
WIDGET_EVENT we are unable to query the FSC_INPUTFIELD value. Without
the first call, we are unable to query the state of the button.

There's more! Reverse the order of the calls to WIDGET_EVENT and it
doesn't work!

I cannot convince myself that switching to a traditional event handler
application structure is worth the work. I would have to "drag
around" hundreds of variables in some sort of application state
structure or common block. It certainly could be done, but wouldn't
it be easier if we could just query the values of these widgets
without the necessity of some kind of event handler, which it seems is
the current situation? Notice that I'm not using the events for
anything in the code, but the WIDGET_EVENT call is necessary just to
get the subsequent WIDGET_CONTROL.. GET_VALUE queries to work.

Great fun.
Mark
Re: CW_FIELD question [message #54225 is a reply to message #54210] Fri, 25 May 2007 12:40 Go to previous message
Jean H. is currently offline  Jean H.
Messages: 472
Registered: July 2006
Senior Member
markb77@gmail.com wrote:
> Thanks for the responses!
>
> Does it have something to do with the /NO_BLOCK keyword to Xmanager?
>
> Let's say I wanted to include an event handler to handle events from
> these input fields only, leaving the rest of my code unchanged. What
> would that look like? Would I read the contents of the fields in the
> event manager and write them into a common block variable that my code
> could read? I still don't see where the necessity for an event
> manager comes in here - why can't I simply read the values of the
> fields from within my code using WIDGET_CONTROL, field2,
> GET_VALUE=value?
>

Use a pointer instead of a common block. You can create the pointer in
the main program, store it as the Uvalue of the text field, modify its
content in the event handler and read it back in your main program...

Jean
Re: CW_FIELD question [message #54227 is a reply to message #54225] Fri, 25 May 2007 12:40 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
markb77@gmail.com writes:

> Does it have something to do with the /NO_BLOCK keyword to Xmanager?

I don't know what it has to do with. I've been consulting my
Ouija board for the last half hour, without result. :-(


> I still don't see where the necessity for an event
> manager comes in here - why can't I simply read the values of the
> fields from within my code using WIDGET_CONTROL, field2,
> GET_VALUE=value?

Good question. I just don't know. Karl!?

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: CW_FIELD question [message #54228 is a reply to message #54225] Fri, 25 May 2007 12:30 Go to previous message
markb77 is currently offline  markb77
Messages: 217
Registered: July 2006
Senior Member
Thanks for the responses!

Does it have something to do with the /NO_BLOCK keyword to Xmanager?

Let's say I wanted to include an event handler to handle events from
these input fields only, leaving the rest of my code unchanged. What
would that look like? Would I read the contents of the fields in the
event manager and write them into a common block variable that my code
could read? I still don't see where the necessity for an event
manager comes in here - why can't I simply read the values of the
fields from within my code using WIDGET_CONTROL, field2,
GET_VALUE=value?
Re: CW_FIELD question [message #54230 is a reply to message #54228] Fri, 25 May 2007 11:59 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
markb77@gmail.com writes:

> The text widget seems to work so I could just go with that, but I'm
> still wondering if there is a way to get either CW_FIELD or David
> Fanning's FSC_INPUTFIELD to work the way I'm trying to use them.

Well, I don't think so, but I'm having a hell of a time
thinking why not. :-(

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: CW_FIELD question [message #54231 is a reply to message #54230] Fri, 25 May 2007 11:35 Go to previous message
markb77 is currently offline  markb77
Messages: 217
Registered: July 2006
Senior Member
The reason for not using an event manager is that I'm modifying a
large piece of pre existing code and adding a few widgets to it. Re-
writing in terms of processing "events" from the gui would be a major
overhaul.

The text widget seems to work so I could just go with that, but I'm
still wondering if there is a way to get either CW_FIELD or David
Fanning's FSC_INPUTFIELD to work the way I'm trying to use them.

For those familiar with Labview, what I want is simply a numeric input
control for which you can simply read it's value at any point in the
program.
Re: CW_FIELD question [message #54233 is a reply to message #54231] Fri, 25 May 2007 11:19 Go to previous message
cmancone is currently offline  cmancone
Messages: 30
Registered: May 2007
Member
On May 25, 2:01 pm, mark...@gmail.com wrote:
> I know there must be something basically wrong with my thinking on
> this, but I can't figure out why this doesn't work. I'm writing a
> program that makes use of DRAW and TEXT widgets without an event
> handling routine. I would like some widgets to be used as numeric
> entry fields in which the user can enter numeric data to be read by
> the program. These should not be modal widgets.
> Here is an example of what I'm trying to do:
>
> PRO Example
>
> tlb = Widget_Base(Column=1)
>
> field1 = WIDGET_TEXT(tlb, /EDITABLE)
>
> field2 = CW_FIELD(tlb, /FLOATING)
>
> WIDGET_CONTROL, tlb, /REALIZE
> XManager, 'example', tlb, /No_block
>
> quita = 0
>
> curval=''
>
> WIDGET_CONTROL, field1, GET_VALUE=curval
>
> while quita ne 1 do begin
>
> WIDGET_CONTROL, field1, GET_VALUE=f1val
> WIDGET_CONTROL, field2, GET_VALUE=f2val
>
> if f1val ne curval then begin
> curval = f1val
> print, curval
> print, f2val
> if curval eq 'q' then quita = 1
> endif
> wait, 0.1
>
> endwhile
>
> WIDGET_CONTROL, tlb, /DESTROY
>
> END
>
> When you run this program, the WIDGET_TEXT field is editable and
> behaves as expected, but the CW_FIELD field is not editable. What is
> going on? There must be something basic that I'm missing here.
>
> Thanks,
> Mark



Why don't you want to use an event manager? That would be my first
question. If you re-write it without that last part, it works fine:

PRO Example

tlb = Widget_Base(Column=1)

field1 = WIDGET_TEXT(tlb, /EDITABLE)

field2 = CW_FIELD(tlb, /FLOATING)

WIDGET_CONTROL, tlb, /REALIZE
XManager, 'example', tlb, /No_block

quita = 0

curval=''

WIDGET_CONTROL, field1, GET_VALUE=curval


END


I'm not an expert on this (I'm very new to widgets myself) but it
seems like you have to do this properly. Apparently, as long as you
are in the while loop and are using the wait, the cw_field doesn't
work. I can hazard a guess why that is. I have a suspicion that
cw_field isn't just a regular input box. It actually has some pre-
processing before it allows anything to populate it's field - that's
how it forces you to only input numeric values in the text box. I'm
guessing that somehow the "infinite" while/wait loop you have going
prevents it from executing this functionality and actually putting
text into the input box. If so, I'm guessing you're simply stuck, and
have to do it another way.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Anyone using IUE software library in IDL?
Next Topic: Re: Anyone using IUE software library in IDL?

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

Current Time: Wed Oct 08 11:43:37 PDT 2025

Total time taken to generate the page: 0.00729 seconds