为什么我不能在此小部件上使用 get_children_by_id()
Why can't I use get_children_by_id() on this widget
我想访问内部小部件,但它给我一个错误,我无法为 nil 值编制索引。
我的插件:
local previewWidget = wibox()
previewWidget:setup {
widget = wibox.widget {
{
widget = wibox.widget {
{
widget = awful.widget.clienticon,
client = "",
id = "clientIcon"
},
{
widget = wibox.widget.textbox,
id = "titleText"
},
nil
},
layout = wibox.layout.align.horizontal,
id = "titleBox"
},
{
widget = wibox.widget.imagebox,
id = "clientImage"
},
nil
},
id = "previewBox",
layout = wibox.layout.align.vertical,
border_width = 10,
border_color = "FF0000",
}
这条命令没有报错:
local previewBox = previewWidget:get_children_by_id("previewBox")[1]
但是这样做:
local titleBox = previewWidget:get_children_by_id("titleBox")[1]
local clientIcon = previewWidget:get_children_by_id("clientIcon")[1]
我做错了什么?
local previewWidget = wibox.widget {
{
{
widget = awful.widget.clienticon,
client = "",
id = "clientIcon"
},
{
widget = wibox.widget.textbox,
id = "titleText"
},
nil,
layout = wibox.layout.align.horizontal,
id = "titleBox"
},
{
widget = wibox.widget.imagebox,
id = "clientImage"
},
nil,
layout = wibox.layout.align.vertical,
id = "previewBox",
}
我错误地使用了布局:
所有 3 个小部件都需要位于调用布局的位置
local some_widget = wibox.widget {
{ widget nr.1 },
{ widget nr.2 },
{ widget nr.3 },
layout = wibox.layout.align.vertical
}
P.S。声明一个没有小部件的布局就足够了
我想访问内部小部件,但它给我一个错误,我无法为 nil 值编制索引。
我的插件:
local previewWidget = wibox()
previewWidget:setup {
widget = wibox.widget {
{
widget = wibox.widget {
{
widget = awful.widget.clienticon,
client = "",
id = "clientIcon"
},
{
widget = wibox.widget.textbox,
id = "titleText"
},
nil
},
layout = wibox.layout.align.horizontal,
id = "titleBox"
},
{
widget = wibox.widget.imagebox,
id = "clientImage"
},
nil
},
id = "previewBox",
layout = wibox.layout.align.vertical,
border_width = 10,
border_color = "FF0000",
}
这条命令没有报错:
local previewBox = previewWidget:get_children_by_id("previewBox")[1]
但是这样做:
local titleBox = previewWidget:get_children_by_id("titleBox")[1]
local clientIcon = previewWidget:get_children_by_id("clientIcon")[1]
我做错了什么?
local previewWidget = wibox.widget {
{
{
widget = awful.widget.clienticon,
client = "",
id = "clientIcon"
},
{
widget = wibox.widget.textbox,
id = "titleText"
},
nil,
layout = wibox.layout.align.horizontal,
id = "titleBox"
},
{
widget = wibox.widget.imagebox,
id = "clientImage"
},
nil,
layout = wibox.layout.align.vertical,
id = "previewBox",
}
我错误地使用了布局:
所有 3 个小部件都需要位于调用布局的位置
local some_widget = wibox.widget {
{ widget nr.1 },
{ widget nr.2 },
{ widget nr.3 },
layout = wibox.layout.align.vertical
}
P.S。声明一个没有小部件的布局就足够了