On Feb 1, 7:02 am, vanessa_c <cjncvc2...@gmail.com> wrote:
> I am trying to create a widget using the new IDL 8 plot function and
> widget_window. I'd like to be able to display different plots in the
> widget window and each time I choose a different menu button, have a
> fresh plot appear. I am using /current to make each plot appear in
> the same widget window. However, I'm having trouble with the plots
> simply being plotted over each other within the graphics window. I've
> played around with using /overplot but I don't think it helps because
> I need to have multiple plots on the screen. There isnt this problem
> when I use the old graphics (widget_draw), with the code not very
> different to the one I am using now. Perhaps I am missing something
> that clears the current plot?
>
> Thanks.
>
> PRO
> barebones_event, ev
> WIDGET_CONTROL, ev.id, GET_UVALUE = uval
> WIDGET_CONTROL, ev.top, GET_UVALUE = state
> case uval of
> 'menu1': BEGIN
> ; Retrieve the newly-created Window object.
> WIDGET_CONTROL
> , state.Draw, GET_VALUE = graphicWin
> ; Make sure this is the current window
> graphicWin.
> SELECT
> p=
> plot([0,10],[5,5],title='plot1',/current,yrange=[0,6],layout =[2,2,1])
> p=
> plot([0,10],[5,5],title='plot1',/current,yrange=[0,6],layout =[2,2,4])
> END
> 'menu2': BEGIN
> WIDGET_CONTROL
> , state.Draw, GET_VALUE = graphicWin
> ; Make sure this is the current window
> graphicWin.
> SELECT
> p2=
> plot([0,10],[15,15],title='plot2',/
> current,yrange=[0,20],layout=[2,2,2])
> p2=
> plot([0,10],[15,15],title='plot2',/
> current,yrange=[0,6],layout=[2,2,4])
> END
> ;buttons
> 'Cancel': WIDGET_CONTROL, ev.top, /DESTROY
>
> ELSE :
> ENDCASE
> WIDGET_CONTROL, state.base, SET_UVALUE = state
> END
>
> PRO
> barebones
> ; menu bar widget
> base =
> WIDGET_BASE(MBAR=bar, TITLE='test', row = 1)
> menu1 =
> WIDGET_BUTTON(bar, VALUE='menu', UVALUE='menu', /MENU)
> men1but1 =
> WIDGET_BUTTON(menu1, VALUE='menu1', UVALUE='menu1')
> men1but2 =
> WIDGET_BUTTON(menu1, VALUE='menu2', UVALUE='menu2')
> draw = WIDGET_WINDOW(base, UVALUE='draw', UNAME='DRAW')
> bbase =
> WIDGET_BASE(base, column = 1, frame =1, title = 'OPTIONS')
> bsize =
> 75
> buttb =
> widget_button(bbase, value = 'Cancel', uvalue = 'Cancel', $
> xsize = bsize, /align_center, yoffset =
> 30)
>
> DEVICE, decomposed=0
> state = { base:base, $
> draw:draw $
>
> }
>
> WIDGET_CONTROL, base, SET_UVALUE = state
> WIDGET_CONTROL, base, /REALIZE
> XMANAGER, 'barebones', base
> END
I think what you want is the p.hide property.
|