putting image in label

Naito
Posts: 18
Joined: Thu Aug 12, 2010 1:36 pm

Re: putting image in label

Post by Naito »

I then looked over the coding for the image of the compass. I assume that all I need from it is the following:
Code: [show] | [select all] lua
gfx_path = [[/home/thomasprice/gfx]]
string = gfx_path .. sep 
setBackgroundImage("north", string ..  sep .. "n.png");
Correct?

Which I then fixed up to fit my coding and my images:
Code: [show] | [select all] lua
gfx_path = [[/home/thomasprice]]
string = gfx_path
setBackgroundImage("Aeon", string .. "Button.png");
But this isn't working... so is there some of the coding that I need and am missing?

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: putting image in label

Post by Heiko »

Code: [show] | [select all] lua
createLabel("xpBar",0,0,0,0,1);
setBackgroundColor("xpBar",32,124,215,100)
setBackgroundImage("xpBar", graphics_path .. "compass.png")
moveWindow("xpBar", 22,offset)
resizeWindow("xpBar",55,10)
That's just good practice and less error prone.

Keep in mind that only png images can be used on all platforms. Other image formats don't work on all systems.

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: putting image in label

Post by Heiko »

simple bug in your script:
Code: [show] | [select all] lua
gfx_path = [[/home/thomasprice/]]
setBackgroundImage("Aeon", gfx_path .. "Button.png");

Naito
Posts: 18
Joined: Thu Aug 12, 2010 1:36 pm

Re: putting image in label

Post by Naito »

Kay, I changed it around a little to try and get it easier for me here's what it looks like:
Code: [show] | [select all] lua
gfx_path = [[/home/thomasprice/]]

createLabel("Aeon",960,33,280,30,1);
  moveWindow("Aeon",960,33,280,30,1)
  setBackgroundImage("Aeon", gfx_path .. "Button.png");
  echo("Aeon", "<strong style=\"font-size: 125%;\"><center>Aeon</center></strong></p>")
I even changed the Button image to scale it back down to 280 Width and 30 Width, But it does nothing. It makes it so that 'Aeon' no longer has a blue color to it, it's pretty much just a word sitting where it normally should just minus the box around it >.>.... So I can't figure out whats wrong, the path is correct, the coding looks correct... It's just not working >.<

EDIT: Sorry thats 280 Width and 30 HIEGHT Heh

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: putting image in label

Post by Heiko »

You are the stubborn type :)
Code: [show] | [select all] lua
gfx_path = [[/home/thomasprice/]]

createLabel("Aeon",0,0,0,0,1);
setBackgroundColor("Aeon",255,0,0,100)
resizeWindow("Aeon", 300, 200)
moveWindow("Aeon", 250, 100 )
setBackgroundImage("Aeon", gfx_path .. "Button.png");
--echo("Aeon", [[<font color="yellow" size=20>Hello <b><font size=40 color="blue"><center>World!</center></b>]])
You'll see the image and if you uncomment the echo line you'll see a nice hello world message, but the image will disappear. To display image + text you have to resort to css background image loading, but the recommended way is to use transparent label layering. The last created label is the top label, the first the lowest.

Post Reply