changed widget lib handling, pyload widget now ready to use

This commit is contained in:
don-philipe
2016-02-21 21:58:30 +01:00
parent 2c72f6c941
commit c143aa3f89
7 changed files with 529 additions and 284 deletions

31
testwidget.lua Normal file
View File

@@ -0,0 +1,31 @@
-- minimal widget to show how it works
local setmetatable = setmetatable
local wibox = require("wibox")
local testwidget = { mt ={} }
local w = wibox.widget.textbox()
-- cares about getting data and outputting it
local function updatedata()
w:set_text(tostring(os.time()))
end
-- setup the update cycle an call the functions that update the data
local function setupupdate(t)
mytimer = timer({timeout = t})
mytimer:connect_signal("timeout", function() updatedata() end)
mytimer:start()
end
-- create this widget
function testwidget.new(args)
w.update = setupupdate(tonumber(args.t))
return w
end
function testwidget.mt:__call(...)
return testwidget.new(...)
end
return setmetatable(testwidget, testwidget.mt)