Re: Loading picture into compound widget [message #31879 is a reply to message #31875] |
Tue, 27 August 2002 04:56  |
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
|
|
|