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

Home » Public Forums » archive » Re: Error on shutdown of 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: Error on shutdown of widget !@$% [message #24626] Wed, 11 April 2001 03:00 Go to next message
R.Bauer is currently offline  R.Bauer
Messages: 1424
Registered: November 1998
Senior Member
Sean Heukels wrote:
>
> How do I get rid off, or catch this error ??
>
> When I shutdown my widget program by clciking exit, in my menubar, I can
> reset colors, structures, the whole thing.
> But when I click the Top-right-cross (Windows) And top-left=box on Unix,
> which shutsdown the current process, I get an error by widget_event,
> that this one ('named by number') is not defined.
>
> I wish to clean up the variables that I clean on pushing exit in the same
> way and dont want 2 create errors.
>
> How can this be done ??
>
> Thnks Sean

Another posibilty instead of KILL_NOTIFY described by Marc
is to supress this feature.

This is done by the keyword TLB_FRAME_ATTR to widget_base()

Value Meaning
1 Base cannot be resized, minimized, or maximized.
2 Suppress display of system menu.
4 Suppress title bar.
8 Base cannot be closed.
16 Base cannot be moved.



regards

Reimar

--
Reimar Bauer

Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg1/
=============================================
a IDL library at ForschungsZentrum J�lich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml

http://www.fz-juelich.de/zb/text/publikation/juel3786.html
Re: Error on shutdown of widget !@$% [message #24642 is a reply to message #24626] Tue, 10 April 2001 03:52 Go to previous messageGo to next message
marc schellens[1] is currently offline  marc schellens[1]
Messages: 183
Registered: January 2000
Senior Member
Sean Heukels wrote:
>
> How do I get rid off, or catch this error ??
>
> When I shutdown my widget program by clciking exit, in my menubar, I can
> reset colors, structures, the whole thing.
> But when I click the Top-right-cross (Windows) And top-left=box on Unix,
> which shutsdown the current process, I get an error by widget_event,
> that this one ('named by number') is not defined.
>
> I wish to clean up the variables that I clean on pushing exit in the same
> way and dont want 2 create errors.
>
> How can this be done ??
>
> Thnks Sean

The problem here is, that when you kill the widget by the
window-manager,
your widget doesn't exist anymore when you want to read data from it.
You can define a procedure for the top level base via the KILL_NOTIFY
keyword
which will be called when the widget dies, no matter how.
This procedure gets the widget ID of the dying widget as an argument.
Alternatively you define a cleanup procedure via the CLEANUP keyword to
xmanager,
which overrides the KILL_NOTIFY. It also gets the widget ID as its
argument.
Do the cleanup in one of these procedures and just kill the widget in
the
event handler (the cleanup routine will be called then also.

Cheers,
marc

Example:

pro testKill,ID
print,'testKill'
print,widget_info(/VALID_ID,ID)
end

pro xKill,ID
print,'xKill'
print,widget_info(/VALID_ID,ID)
end

pro test_Event,event
widget_control,event.top,/DESTROY
end

pro test

tlb=widget_base(/COL,KILL_NOTIFY='testKill')

wb=widget_button(tlb,VALUE='--------------OK------------')

widget_control,tlb,/REALIZE

;; uncomment the CLEANUP keyword for using xKill instead
xmanager,'test',tlb;,CLEANUP='xKill'
end
Re: Error on shutdown of widget !@$% [message #24649 is a reply to message #24642] Tue, 10 April 2001 03:12 Go to previous messageGo to next message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Sean Heukels (sean77=cuthere=@dds.nl) writes:

> How do I get rid off, or catch this error ??
>
> When I shutdown my widget program by clciking exit, in my menubar, I can
> reset colors, structures, the whole thing.
> But when I click the Top-right-cross (Windows) And top-left=box on Unix,
> which shutsdown the current process, I get an error by widget_event,
> that this one ('named by number') is not defined.
>
> I wish to clean up the variables that I clean on pushing exit in the same
> way and dont want 2 create errors.
>
> How can this be done ??

While it *sounds* like a good idea to put all
your cleanup in the Exit button event handler,
it never works, as you have discovered, because
nobody uses it. They kill widgets with the
mouse, not by clicking the Exit button.

So, take *all* your cleanup out of the Exit button
event handler and put it in a CLEANUP routine
associated with the top-level base widget by means
of a CLEANUP keyword on the XMANAGER command.
Make a *SEPARATE* event handler for your Exit
button that does nothing but destroy the TLB.

I say *SEPARATE* because your other problem, I'm
sure, stems from having all your event handler
code in the same procedure. The error you
get on exit is because you are trying to do
something with the top-level base after you
just killed it! (90% of the time people are
trying to put something into the user value of
the top-level base after they just killed it.)

While people who know what they are doing
(Stein Vidar comes to mind) can write code
with one huge event handler, I've never known
it to be anything but totally confusing for
people just getting started with IDL. You will
have a lot more luck writing widget programs
with lots of separate event handlers, but this
is especially true for your exit button.

If you are looking for examples, you can try
any of the widget programs on my web page.

And, although it sounds like a hell of a lot
of money, getting a good book to show you
the proper way of writing widget programs
saves an enormous amount of wear and tear,
not to mention frustration. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: Error on shutdown of widget !@$% [message #24772 is a reply to message #24626] Wed, 11 April 2001 15:31 Go to previous message
m.hadfield is currently offline  m.hadfield
Messages: 36
Registered: April 2001
Member
From: "Reimar Bauer" <r.bauer@fz-juelich.de>

> Another possibility instead of KILL_NOTIFY described by Marc
> is to suppress this feature.
>
> This is done by the keyword TLB_FRAME_ATTR to widget_base()
>

IMHO that's bad practice. Users expect to be able to close windows via the
controls on the window frame. The programmer should provide for this unless
there's a good reason not to.

---
Mark Hadfield
m.hadfield@niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield
National Institute for Water and Atmospheric Research


--
Posted from clam.niwa.cri.nz [202.36.29.1]
via Mailgate.ORG Server - http://www.Mailgate.ORG
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Function BYTSCL
Next Topic: IDL programming position in San Francisco

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

Current Time: Wed Oct 08 11:39:59 PDT 2025

Total time taken to generate the page: 0.00536 seconds