Results 1 to 3 of 3

Thread: Widget help

  1. #1

    Widget help

    can someone help me get the value of my file section to be displayed in the 'text' field after selection? I assume I use WwSetValue but I can never get it. Thank you.

    PRO GUI
    top=WwInit('Optical_Mapping', 'Examples', layout, /Vertical, Spacing=5, Border=3)
    label=WwText(layout, /Label, Text='This is Label')
    text=WwText(layout, 'TextCB', Cols=40, left=label)
    btn1=WwButtonBox(layout,'Browse', 'fileSearchCB', left=text)
    status=WwSetValue(top, /Display)
    WwLoop
    END
    ;************************************************* ********************************
    PRO fileSearchCB, wid, data
    file = WwFileSelection(wid,'fileOK', 'fileCancel', Title='Browse')
    END

    PRO fileOK, wid, shell
    value = WwGetValue(wid)
    status = WwSetValue(shell, /Close)
    END

    PRO fileCancel, wid, shell
    PRINT, 'File Cancel'
    END

  2. #2
    Grand Poobah donb's Avatar
    Join Date
    Aug 2005
    Location
    Colorado
    Posts
    147

    widget help

    Hi green12,

    In order to set the value of the text field, you need the widget ID of the text widget, and then you need to set the value of that widget after you have the filename from the file selection widget.

    You can either use COMMON blocks to pass widget IDs between routines (callbacks), or you can use the Userdata keywords. Below is a modified version of your code that uses COMMON blocks, and hopefully accomplishes what you're trying to do.

    Cheers, Don B.

    Code:
    ;*************************************************
    PRO fileSearchCB, wid, data
    file = WwFileSelection(wid,'fileOK', 'fileCancel', Title='Browse')
    END
    
    PRO fileOK, wid, shell
    common gui_ids, text   ;;; added the common here so this callback
                           ;;; has access to the widget id we want to update
    value = WwGetValue(wid)
    status = WwSetValue(shell, /Close)
    status = WwSetValue(text, value)   ;;; set the widget value (the filename)
                                       ;;; into the text widget
    END
    
    PRO fileCancel, wid, shell
    PRINT, 'File Cancel'
    END
    
    PRO GUI
    common gui_ids, text    ;;; added this commom to get the text widget id
    top=WwInit('Optical_Mapping', 'Examples', layout, /Vertical, Spacing=5, Border=3)
    label=WwText(layout, /Label, Text='This is Label')
    text=WwText(layout, 'TextCB', Cols=40, left=label)
    btn1=WwButtonBox(layout,'Browse', 'fileSearchCB', left=text)
    status=WwSetValue(top, /Display)
    WwLoop
    END
    Don Boughey
    PV-WAVE Advocate

  3. #3
    Thank you, that did work!

    Does the wid parameter automatically send through functions? I don't see how that parameter is passed between CBs.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •