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

Home » Public Forums » archive » Re: Loading picture into compound 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: Loading picture into compound widget [message #31875] Tue, 27 August 2002 08:32
MKatz843 is currently offline  MKatz843
Messages: 98
Registered: March 2002
Member
David's correct (goes without saying). Learning to code your own
widgets is the way to go. In the mean time, I think I can offer a
simple, perhaps ugly, fix. (Note: I would never recommend this as a
way to begin programming widgets, it's just a suggestion to get you up
and running with what you've already got.)

It seems that the widget code does not make use of the very useful
UVALUE (User Value) field in the widgets. One can store important
information there--any type.

So as a temporary fix, once you learn the window number (index) you
can store it in the UVALUE of one of your widgets, like this. In the
line following

WIDGET_CONTROL, drawViewer, GET_VALUE = index

put

WIDGET_CONTROL, menuFileOpen, SET_UVALUE=index ;-- new line

I've chosen to store the value in the menuFileOpen widget because
that's
the one that's generated the event. We'll know its ID from within the
event handler routine and it's in the Event structure as Event.ID.
So, change your OnOpen routine to

pro OnOpen, Event
ImageIsRead=DIALOG_READ_IMAGE(DIALOG_PARENT=Event.top, $
FILE=FileName, FILTER_TYPE='.tif, .tiff', IMAGE=PhotoArray, $
TITLE='Choose the photo file')
IF (ImageIsRead EQ 1) THEN BEGIN
;--- Ask the menuFileOpen widget to give you back the index value
; you stored.
WIDGET_CONTROL, Event.ID, GET_UVALUE=uval
WSET, uval
TVSCL, PhotoArray
ENDIF
end

It ain't pretty, but that should work for now.

M. Katz
Re: Loading picture into compound widget [message #31879 is a reply to message #31875] Tue, 27 August 2002 04:56 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Evgeny Turchin (evgturchin@narod.ru) writes:

> I want the picture which is opened when choosing "Open" item
> in "File" menu to be loaded into the draw widget but in my program
> it is loaded into a separate window. What should I change in my programs?
> Thanks in advance. I'm sorry for bothering the readers of the newsgroup
> with such simple thing.

Alas, using the GUI Builder to write widget programs
doesn't free you from the responsibility of knowing
what you are doing when you write GUI programs, it
just makes it much harder to read your code. :-)

The bottom line is this: you must know what window
you are drawing into when you write a widget program.
This means every widget program that draws graphics
*must* do a WSET to the window index number of the
window they want to draw into.

Your program does this, but not in the program
module where you are drawing your graphics! You need
a "WSET, index" in the ONOPEN procedure. But, as you
will no doubt discover, "index" isn't defined there,
but is defined in the BASE procedure.

Now you come upon the fundamental problem of widget
programming: information you need in one procedure
is actually stored or available somewhere else. The
GUI Builder's response to this is "Duh, I only *build*
widgets and write dumb widget code. I don't know anything
about making them work!"

My suggestion is to get ahold of a good IDL programming
book and read about "info" structures for passing information
required to run widget programs around in widget program
modules. Sooner or later it won't be just the index
that you need, you might actually want to do some work
on that image as well!

Cheers,

David

P.S. Let's just say putting all of the information you
need to run your program in one place and passing the
location of that place around to your widget program
modules is a MUCH better solution than common blocks!

Whoops! Does that sound like a pointer!? Oh, dear. We
are heading far afield now. :-(

--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: new link for examples
Next Topic: replacement for insight

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

Current Time: Fri Oct 10 12:48:49 PDT 2025

Total time taken to generate the page: 0.47250 seconds