set images as button icon (multiple images and buttons)
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
set images as button icon (multiple images and buttons)
Hi everybody
currently I am tring to create a media player using Livecode and CasparCG. I have almsot eveything done except of some minor details.
I choose the folder I want to use.
I list all my media files to a list.
I choose the file from the list and it plays.
Now my problem is how to create snapshots(icons) of those media files. I thought to set a space in my app, put multiple buttons or rectangles, then set the icon of x button to the id of the image chosen. But it takes lot of time, plus you have to do it each and every time you select a new folder. What I really want to do is, to set icons of buttons or rectangles to the fileneame of my list.
....if this is possible
Thanks in advance
Pajito
currently I am tring to create a media player using Livecode and CasparCG. I have almsot eveything done except of some minor details.
I choose the folder I want to use.
I list all my media files to a list.
I choose the file from the list and it plays.
Now my problem is how to create snapshots(icons) of those media files. I thought to set a space in my app, put multiple buttons or rectangles, then set the icon of x button to the id of the image chosen. But it takes lot of time, plus you have to do it each and every time you select a new folder. What I really want to do is, to set icons of buttons or rectangles to the fileneame of my list.
....if this is possible
Thanks in advance
Pajito
-
- Livecode Opensource Backer
- Posts: 9380
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: set images as button icon (multiple images and buttons)
I am having a problem understanding what you mean by
"create snapshots(icons) of those media files"
as they probably all look the same: can you explain a bit more?
"create snapshots(icons) of those media files"
as they probably all look the same: can you explain a bit more?
Re: set images as button icon (multiple images and buttons)
richmond62 wrote:I am having a problem understanding what you mean by
"create snapshots(icons) of those media files"
as they probably all look the same: can you explain a bit more?
Hi
I am really sorry about that. So I have a programm. I need to import some pictures from a folder and set them as icons to buttons. Not manually.
If you nees any further explanation please do not hesitate.
Regards
Pajito
-
- Livecode Opensource Backer
- Posts: 9380
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: set images as button icon (multiple images and buttons)
Hi againrichmond62 wrote:Hope this helps:
unfortunatelly no, my problem is that I need to load multiple pictures and set them to muliple buttons.
I want to thank you anyway, probably your code will help me later building the app.
thanks again
-
- Livecode Opensource Backer
- Posts: 9380
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: set images as button icon (multiple images and buttons)
The underlying principles of what you want to do are contained within my stack.
Import your multiple pictures; assign predetermined names to them as they are imported (P1, P2, P3 . . . .).
Create new buttons on the fly as the pictures are imported, set each image as an icon to each button.
Import your multiple pictures; assign predetermined names to them as they are imported (P1, P2, P3 . . . .).
Create new buttons on the fly as the pictures are imported, set each image as an icon to each button.
Re: set images as button icon (multiple images and buttons)
Ora space in my app, put multiple buttons or rectangles, then set the icon of x button to the id of the image chosen. But it takes lot of time, plus you have to do it each and every time you select a new folder. What I really want to do is, to set icons of buttons or rectangles to the fileneame of my list.
- Use Object > New Control > Image to create a new blank image.
Assign it a name as Richmond suggested, e.g. 'P1'
Set its lockloc to true.
Edit > Duplicate Objects to create your grid of images. You can use the arrow keys to reposition.
Increment the name of each new image, e.g. 'P2', 'P3', etc.
The code below assumes you have already gotten the list of image files in the selected folder and put it into a variable called imageList.
And that you have set the default folder to the selected folder.
Code: Select all
on populateImageGrid
lock screen
repeat with x = 1 to 15 (or however many images you have made in the grid)
set the filename of image ('P' & x) to line x of imageList[/indent]
end repeat
unlock screen
end populateImageGrid
It is also smart if the image files in the folder are already the correct thumbnail size for the grid, so that LiveCode doesn't need to resize them.
Of course, if different folders have different numbers of images you will want to make sure your grid contains the maximum number of possible images.
If a folder has less images than the maximum you will want to set the filename of any extra images in the grid to empty and perhaps hide them as well.
Jim Lambert
Re: set images as button icon (multiple images and buttons)
ignore that [/indent]