View Full Version : I need help with paragraph and listbox
nopal
08-17-2008, 01:34 PM
First sorry fot my english, I try to explain as well as I can.
Iīm doing a project with various albums and I want to see the cover of the album and a little description below the cover. I change between albums with the listbox and with a button a load the mp3(or m3u)
I have everything except the paragraph, I donīt know how to make to show a little description in the paragraph for each album.
thank in advance
Ulrich
08-19-2008, 11:51 AM
This can be done a similar way to a recent post (http://www.indigorose.com/forums/showthread.php?t=24648) I placed here. There are certainly other ways. Here are the modifications I made in your project:
In the ListBox dialog, you are setting just the image file name. I suggest that you set there as well the text you want to display, or the filename of the text you want to show in the Paragraph object.
So, instead of just setting "pic1.jpg" as Item Data, set it as "pic1.jpg|This is the text for the first option", for example.
http://www.mindquake.com.br/files/ams/SNAG-080819-01.png
Then, using Lua, split the information appart and use them in the Image and Paragraph:
tSelected = ListBox.GetSelected("ListBox1");
if tSelected then
sFile = ListBox.GetItemData("ListBox1", tSelected[1]);
-- split the text of the Item Data: separate the image name and paragraph text (or file name, see below)
separator = String.Find(sFile, "|");
image = String.Mid(sFile, 1, separator-1);
text = String.Mid(sFile, separator+1, -1);
-- Load filename into Image object
Image.Load("Image1", "AutoPlay\\Images\\" .. image);
-- set the text of the paragraph object
Paragraph.SetText("Paragraph1", text);
-- if the text should be a filename instead, just modify accordingly,
-- using something like this (modify to fit your needs):
-- textfile = TextFile.ReadToString("AutoPlay\\Docs\\" .. text);
-- Paragraph.SetText("Paragraph1", textfile);
end
Ulrich
nopal
08-19-2008, 02:53 PM
ok, thanks a lot upeters. I try to do this solution with the "pipe" but I didnīt resolve it.
I add the lines for open the mp3 or m3u with the button "open", while you see the cover and the description of the album.
thank you upeters again and sorry for my english ;)
Ulrich
08-20-2008, 11:54 AM
I looked at your recent post, and compared it with the version I left here for you. You reinstated several lines from your original project which made no sense at all, showing that you yet didn't understand the new code and just copied what I had done.
You asked to show text in a Paragraph object, and change a certain image, after a single click in a ListBox, and that help was provided. Now you are saying that it "didn't resolve it" because actually you wish to do something new, like linking to a certain audio file as well.
Although your new request certainly may use the same mechanism I showed you (simply by adding one more separator and field of information to the List Box entry, setting the ItemData to something like albumart.jpg|Album description|audiofile.mp3), I find that you might want to prefer using a database for this project. A SQL database would allow you to build a much cleaner solution, where you can insert and update new info, without having to rebuild your project. You better should set up a table with one record for each album, with fields for the album name, art, description, and maybe track listing, then fetch the data and display it in your application.
I made several modifications to your former project. I would suggest that you study what I did and try to understand it before you start to add stuff. Upon clicking an entry in the ListBox (now shown as "Album 1", "Album 2" and "Album3"), the corresponding image to the album is loaded into Image1. At the same time, the text of Paragraph1 is set to the album description. And last, a variable is set, allowing to play an audio clip in a MediaPlayer object corresponding to the album which was selected. As I said, I would suggest that you use SQL if you need further info, as splitting ItemData will quickly become unpractical.
Ulrich
Imagine Programming
08-20-2008, 02:25 PM
What do you use to make those nice screenshots?:p
This can be done a similar way to a recent post (http://www.indigorose.com/forums/showthread.php?t=24648) I placed here. There are certainly other ways. Here are the modifications I made in your project:
In the ListBox dialog, you are setting just the image file name. I suggest that you set there as well the text you want to display, or the filename of the text you want to show in the Paragraph object.
So, instead of just setting "pic1.jpg" as Item Data, set it as "pic1.jpg|This is the text for the first option", for example.
http://www.mindquake.com.br/files/ams/SNAG-080819-01.png
Then, using Lua, split the information appart and use them in the Image and Paragraph:
tSelected = ListBox.GetSelected("ListBox1");
if tSelected then
sFile = ListBox.GetItemData("ListBox1", tSelected[1]);
-- split the text of the Item Data: separate the image name and paragraph text (or file name, see below)
separator = String.Find(sFile, "|");
image = String.Mid(sFile, 1, separator-1);
text = String.Mid(sFile, separator+1, -1);
-- Load filename into Image object
Image.Load("Image1", "AutoPlay\\Images\\" .. image);
-- set the text of the paragraph object
Paragraph.SetText("Paragraph1", text);
-- if the text should be a filename instead, just modify accordingly,
-- using something like this (modify to fit your needs):
-- textfile = TextFile.ReadToString("AutoPlay\\Docs\\" .. text);
-- Paragraph.SetText("Paragraph1", textfile);
end
Ulrich
Ulrich
08-20-2008, 02:30 PM
For screenshots I use SnagIt, currently at version 9.
Ulrich
Imagine Programming
08-20-2008, 04:05 PM
For screenshots I use SnagIt, currently at version 9.
Ulrich
Thanks:yes
nopal
08-20-2008, 04:25 PM
thank you upeters
nopal
06-26-2009, 06:37 AM
Now, In this project I would like to open a folder bedides opening m3u from the same listbox , how i do it?:rolleyes
Powered by vBulletin™ Version 4.0.6 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.