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

Home » Public Forums » archive » Re: Linking buttons to plot windows
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Linking buttons to plot windows [message #42135 is a reply to message #42056] Wed, 22 December 2004 15:09 Go to previous message
Robert Barnett is currently offline  Robert Barnett
Messages: 70
Registered: May 2004
Member
And look ... it's possible to write an entire application demonstrating
this in little over half the code it took to write the event loop for
GUI builder. Apologies, the excess documentation makes it a little hard
to read.



David Fanning wrote:

> Clive Cook writes:
>
>
>> Thanks David, i'm pretty new to widget programming so i am not really sure
>> what to do. This is an example of the code that the GUIbuilder generates. I
>> assume that the first part of the code (WID_BASE_0_event) handles the
>> events, so when i press wid_button_1 the function contour1 is called. As i
>> mentioned before this plots in the last area designated for plots
>> (wid_draw_1). How can i specifically plot it in the first area (wid_draw_0)?
>>
>
> It is my humble (and mostly ignored) opinion that it
> is *impossible* to use the GUI_BUILDER to create widget
> programs. At least programs you can understand. And this
> code is like running your fingernails across the blackboard
> to me. But, your code will look something like this (assuming
> the CONTOUR event handlers aren't doing something weird):
>
> pro WID_BASE_0_event, Event
>
> wWidget = Event.top
>
> case Event.id of
>
> Widget_Info(wWidget, FIND_BY_UNAME='wid_button_0'): begin
> if( Tag_Names(Event, /STRUCTURE_NAME) eq 'WIDGET_BUTTON' )then $
> BEGIN
> drawID = WIDGET_INFO(wWidget, FIND_BY_UNAME='WID_DRAW_O')
> Widget_Control, drawID, Get_Value=wid
> WSET, wid
> contour1, Event
> ENDIF
> end
> Widget_Info(wWidget, FIND_BY_UNAME='WID_BUTTON_1'): begin
> if( Tag_Names(Event, /STRUCTURE_NAME) eq 'WIDGET_BUTTON' )then $
> BEGIN
> drawID = WIDGET_INFO(wWidget, FIND_BY_UNAME='WID_DRAW_1')
> Widget_Control, drawID, Get_Value=wid
> WSET, wid
> contour2, Event
> ENDIF
> end
> else:
> endcase
>
> end
>
> If that is not the ugliest code I've ever posted in a newsgroup,
> I don't know what is. :-(
>
> Cheers,
>
> David
>
> P.S. Really do yourself a favor and ditch the GUI_BUILDER. You
> (and your boss) will be glad you did. :-)
>


--

nrb@
Robbie Barnett
imag
Research Assistant
wsahs
Nuclear Medicine & Ultrasound
nsw
Westmead Hospital
gov
Sydney Australia
au
+61 2 9845 7223


; Robbies Tools (rt)
; Plot brown noise
; Present a "redraw" button to redraw the plot in the given window
; This code has absolutely now warranty at all and is not guarunteed
; to actually work.
; Written by Robbie Barnett, Westmead Hospital Sydney

; Draw the graph of the brown noise in the specified window
pro rt_brownian_draw, window
; Keep the seed as a global variable between calls
common rt_brownian, seed
; Set the window to draw in
wset, window
; Create the array which contains the values of the brown noise
values = lonarr(20)
for i=1,19 do values[i] = values[i] + (randomu(seed)-0.5)*10.0
; Plot the brown noise
plot, values
end

; Process an event generated from the widget_button
pro rt_brownian_event, ev
; Get the draw_id which has been packed in the user value of the
; widget button. If this problem were more complicated I would have
; packed a pointer to a structure or object.
widget_control, ev.id, GET_UVALUE=draw_id
; Get the window id which maps to the desired the draw_widget
widget_control, draw_id, GET_VALUE=window
; Draw onto the desired window
rt_brownian_draw, window
end

; Create a widget which allows the user to redraw a plot of brown
; noise.
function rt_brownian, PARENT=parent
; Create the "top level base" widget. This lays out the widget_button
; and widget_draw in a column. Allow for the possibility that the
; parent was not specified.
if (keyword_set(parent)) then tlb = widget_base(parent,COLUMN=1) $
else tlb = widget_base(COLUMN=1)
; Create the canvas (window) for drawing on to
draw_id = widget_draw(tlb,XSIZE=300,YSIZE=300)
; Create the button
button_id = widget_button(tlb,VALUE="redraw",UVALUE=draw_id)
; Realize the widget elements
widget_control, tlb, /realize
; Register for events
xmanager, "rt_brownian", button_id, /JUST_REG
; Return an id for referencing to this widget
return, tlb
end

; Create 3 widgets arranged in a row. Each widget is independant and
; allows the user to redraw a plot of brown noise in each
pro rt_brownians
; Create the parent widget for holding all of them
parent = widget_base(ROW=1)
; Create the independant plots arranged in a single row
a = rt_brownian(PARENT=parent)
b = rt_brownian(PARENT=parent)
c = rt_brownian(PARENT=parent)
end
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Widgets for dummies?
Next Topic: Linking buttons to plot windows

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

Current Time: Sat Oct 11 15:15:35 PDT 2025

Total time taken to generate the page: 0.00903 seconds