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

Home » Public Forums » archive » Re: draw widgets and programming
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: draw widgets and programming [message #4505] Wed, 14 June 1995 00:00
knighton is currently offline  knighton
Messages: 12
Registered: June 1995
Junior Member
In <CHARLES.95Jun12140540@omcen.berkeley.edu> charles@omcen.berkeley.edu (charles bartels 515) writes:


> Hi,

> I'm currently trying to write a widget program using the widget
> builder. I had no problem actually getting the template of the widget
> made. What I'm having trouble with is connecting the program to the
> widgets. Specifically, having a "button press" event wset to a draw
> widget and then plotting some data. The widget *.pro contains the
> lines:

> COMMON DRAW5_Comm, DRAW5_Id
> WIDGET_CONTROL, DRAW5, GET_VALUE=DRAW5_Id

> when the button event is pressed I tried to

> wset, DRAW5_Id
> etc...

> but that didn't work at all. IDL said that the variable "DRAW5_Id"
> was undefined.

> Does anyone know what the problem is?

I fired up the widget builder and created a base with only a draw widget. The
following code was produced:

PRO MAIN13_Event, Event
WIDGET_CONTROL,Event.Id,GET_UVALUE=Ev
CASE Ev OF
'DRAW2': BEGIN
Print, 'Event for DRAW2'
END
ENDCASE
END

PRO test, GROUP=Group
IF N_ELEMENTS(Group) EQ 0 THEN GROUP=0
junk = { CW_PDMENU_S, flags:0, name:'' }
MAIN13 = WIDGET_BASE(GROUP_LEADER=Group, $
COLUMN=1, $
MAP=1, $
TITLE='Test', $
UVALUE='MAIN13')
DRAW2 = WIDGET_DRAW( MAIN13, $
BUTTON_EVENTS=1, $
MOTION_EVENTS=1, $
RETAIN=0, $
UVALUE='DRAW2', $
XSIZE=100, $
YSIZE=100)
WIDGET_CONTROL, MAIN13, /REALIZE

; Get drawable window index

COMMON DRAW2_Comm, DRAW2_Id
WIDGET_CONTROL, DRAW2, GET_VALUE=DRAW2_Id

XMANAGER, 'MAIN13', MAIN13
END

It looks like the event handler (MAIN13_Event) doesn't have the common block
DRAW2_Comm which is defined in the widget definition procedure (test). This
means that when an event occurs and the event handler is called, the window
id DRAW2_Id is not defined. In IDL all variables are local unless they
are exported through a common block or are system variables.

Try putting the statement:

COMMON DRAW2_Comm

in the event handler. Or better yet, simply call a procedure from the event
handler to perform the desired action and put the common block in that procedureinstead.

I hope that this helps.

Ken Knighton

General Atomics, Fusion Division
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Generating MPEG with WAVE
Next Topic: linking with call_external

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

Current Time: Wed Oct 08 13:41:35 PDT 2025

Total time taken to generate the page: 0.00605 seconds