Failed to find image in widget button

Hello,
I’m storing number of image name in an array like
Photo={photo1,photo2,photo3}

for i=1,#Photo do
button=widget.newbutton(
{
id=i,
defaultFile=“Images/”…".png",
width=100,
height=100
}
)
end

I wanted to display number of button images but I’m getting failed to find image photo1.png.

I checked case sensitive for the image names.its same as what’s written in the array.Image exists in the Images folder

I’m fedup with this problem. Please help me out to solve this problem.

Thank you

You are not referencing the image location. This code: defaultFile=“Images/”…".png" returns this “Images/.png”

Try this code:

defaultFile="Images/".. Photo[i] .. ".png"

Also the table must be populated like this:

Photo={"photo1","photo2","photo3"}

Best regards,

Tomas

Hi @Vasanthbalaji883,

In addition to what Tomas says, I think that your photo names should be strings, not variables (which would be nil unless you set them to something else earlier). So, like this:

[lua]

Photo = { “photo1”, “photo2”, “photo3” }

[/lua]

Brent

Try this code out instead:

local Photos = { "Photo1", "Photo2", "Photo3"} for i = 1, #Photos, 1 do local image\_location = "Images/" .. Photos[i] .. ".png" print("image\_location", image\_location) -- YOUR BUTTON LOGIC GOES HERE end

You are not referencing the image location. This code: defaultFile=“Images/”…".png" returns this “Images/.png”

Try this code:

defaultFile="Images/".. Photo[i] .. ".png"

Also the table must be populated like this:

Photo={"photo1","photo2","photo3"}

Best regards,

Tomas

Hi @Vasanthbalaji883,

In addition to what Tomas says, I think that your photo names should be strings, not variables (which would be nil unless you set them to something else earlier). So, like this:

[lua]

Photo = { “photo1”, “photo2”, “photo3” }

[/lua]

Brent

Try this code out instead:

local Photos = { "Photo1", "Photo2", "Photo3"} for i = 1, #Photos, 1 do local image\_location = "Images/" .. Photos[i] .. ".png" print("image\_location", image\_location) -- YOUR BUTTON LOGIC GOES HERE end