Chili:Example Hello World: Difference between revisions

From Spring
Jump to navigationJump to search
Flozi (talk | contribs)
categorise
Gajop (talk | contribs)
Line 3: Line 3:
This is the 'Hello World' example of a Chili widget, to accompany the [[Chili:Tutorial|Chili Tutorial]].
This is the 'Hello World' example of a Chili widget, to accompany the [[Chili:Tutorial|Chili Tutorial]].


<code><pre>  
<syntaxhighlight lang="lua">
function widget:GetInfo()
function widget:GetInfo()
   return {
   return {
Line 49: Line 49:
   }
   }
end
end
</pre></code>
</syntaxhighlight>


[[Category:Libraries]][[Category:Tutorial]]
[[Category:Libraries]][[Category:Tutorial]]

Revision as of 01:21, 11 June 2016

Chili Hello World

This is the 'Hello World' example of a Chili widget, to accompany the Chili Tutorial.

<syntaxhighlight lang="lua"> function widget:GetInfo()

 return {
   name    = "Chili Hello World",
   desc    = "",
   author  = "",
   date    = "",
   license = "GNU GPL v2",
   layer   = 0,
   enabled = true
 }

end

local Chili, Screen0

local helloWorldWindow local helloWorldLabel

function widget:Initialize()

 if (not WG.Chili) then
   -- don't run if we can't find Chili
   widgetHandler:RemoveWidget()
   return
 end
 -- Get ready to use Chili
 Chili = WG.Chili
 Screen0 = Chili.Screen0
 -- Create the window
 helloWorldWindow = Chili.Window:New{
   parent = Screen0,
   x = '40%',
   y = '40%',
   width  = '20%',
   height = '20%',	
 }	
 -- Create some text inside the window
 helloWorldLabel = Chili.Label:New{
   parent = helloWorldWindow,
   width  = '100%',
   height = '100%',
   caption = "Hello world",
 }

end </syntaxhighlight>