note | wglist_output — A common block internal to WgList containing one variable, which is the item(s) selected by the user. When WgList is called stand-alone, it runs in its own event loop. Once the user finishes making their selection, control is passed back to the calling routine and the user's selection can be accessed through the variable chosen. However, if WgList is called from an existing widget application, the tool must use this calling widget's event loop. In this case, WgList is executed and control is passed back immediately to the calling widget application, before widget application that calls WgList to have access to the most recent items chosen by the user, include this common block in the calling widget application. |
items = FINDFILE('*.pro')
IF STRMATCH(GETPLATFORM(), 'win') THEN fnt = 'Forte, 10' $
ELSE fnt='-adobe-*-bold-*-*-*'
WgList, items, chosen, Visible=10, Position=[500,300], $
Back='Green', Fore='Blue', /Multi, Shell=theShellID, Font=fnt
IF chosen(0) NE -1 THEN PM, items(chosen), Title='You chose:' $
ELSE PM, 'Nothing chosen'
INFO, chosen
PRO BUTTONSCB, wid, which
COMMON teststuff2, workArea, items
COMMON wglist_output, choices
IF STRMATCH(GETPLATFORM(), 'win') THEN BEGIN
fnt = 'Forte, 10'
ENDIF ELSE fnt='-adobe-*-bold-*-*-*'
CASE which OF
1: WgList, items, chosen, Parent=workArea, $
Title='WgList', Font=fnt, Fore='Red', Pos=[100,600], $
Shell=shell, Visible=5, /Extended
2: BEGIN
IF N_ELEMENTS(choices) GT 0 THEN $
IF choices(0) NE -1 THEN PM, items(choices), $
Title="You've chosen:" ELSE PM, 'Nothing Chosen' $
ELSE BEGIN
PRINT, STRING(7B)
PRINT, 'Selections have not been made yet'
ENDELSE
END
ENDCASE
END
PRO WGLIST_TEST
COMMON teststuff, workArea, items
topShell = WwInit('WgList_test','WgList_test', workArea, $
/Vertical, Position=[256,256], Spacing=5, Height=100, $
Width=350)
buttons = WwButtonBox(workArea, ['Call wglist', $
'See result'], 'BUTTONSCB')
items = STRING(CINDGEN(20))
status=WwSetValue(topShell, /Display)
WwLoop
END
items = ['a','b','c','d','e','f']
; Font choice syntax different for Windows or Unix...
IF STRMATCH(GETPLATFORM(), 'win') THEN fnt = 'Forte, 10' $
ELSE fnt='-adobe-*-bold-*-*-*'
WgList, items, chosen, Visible=5, Position=[500,300], $
Back='Green', Fore='Blue', /Multi, Shell=theShellID, $
Font=fnt, Title='Full list'
IF chosen(0) NE -1 THEN PM, items(chosen), Title='You chose:' $
ELSE PM, 'Nothing chosen'
INFO, chosen
; Now call WgList again, but hide what choices the user
; previously selected
WgList, items, chosen2, Hide=chosen, Visible=5, $
Position=[500,300], Back='Green', Fore='Blue', /Multi, $
Shell=theShellID, Font=fnt, Title='Remaining list'
IF chosen2(0) NE -1 THEN PM, items(chosen2), Title='You chose:' $
ELSE PM, 'Nothing chosen'
INFO, chosen2