displaying a requested image

Started by Damian on 23-May-2013/2:09:17-7:00
Hi! I would like to display a thumbnail of a pic chosen by the user. Following Nick's tutorial (thanks!) I know that this is possible: view layout [image load to-file request-file] but this calls for the Select File dialog box before displaying the GUI. So I was hoping that something like this could work: view layout [ a: image 160x120 btn "Load" [ a load to-file request-file show a ]] But no image is displayed. What am I doing wrong? Thanks for your help!
Untested, but you need to assign the image correctly to A: view layout [ a: image 160x120 btn "Load" [ a/image: load to-file request-file show a ]] The image size will also need to be adjusted, if your thumbnails aren't of equal size.
Thanks Henrik, it does work. Is this /image some kind of refinement for, well, image? If I wanted to change width or height, can I access the coordinates through some other refinement (like, for example: a/width)? Where can I find a list of the refinements available to widgets? Thanks again!
Hi Damian, Most of what you need to know about VID can be found by exploring: help system/view/vid That's the same as: ? svv Start by taking a look at this: ? svv/vid-styles or to read it more easily: editor svv/vid-styles Take a look at this example: view layout [ a: image 160x120 btn "Load" [ a/image: logo.gif a/size: 50x50 show a ]] A really useful tool to help explore is: do http://www.rebol.it/romano/anamonitor300.r Click view > VID > vid-styles > image (object)
No, it's simpler than that: Faces are objects and you access their properties directly using refinements. The image is simply the bitmap that is assigned to that face, and with the code a/image: .... we simply assign the image manually. You cannot set the size like this, as the assignment is "dumb". You will then need to set the size afterwards, but you will then also need to move the button manually. If you escape your little program to the console and: ? a you will get the face object content dumped on the console and you'll see the image assigned to that face. You can also read the docs available here: http://hmkdesign.dk/project.rsp?id=vid-ext-kit&page=docs They are docs for an extended VID, but there is a good share of information that is related to plain VID as well, including how styles are built, how to access properties in them, etc.
Thanks so much to both!

Reply