0

I have a wibox with vertical layout and two text widgets:

local w = wibox {
    width = 300,
    height = 80,
    ontop = true,
    screen = mouse.screen,
}

w:setup {
    {
        id = 'header',
        widget = wibox.widget.textbox
    },
    {
        id = 'body',
        widget = wibox.widget.textbox
    },
    id = 'text',
    layout = wibox.layout.flex.vertical,
}

When string in 'body' textbox is short everything is ok, the widgets looks this way:

widget with short string

But if string is long, the size of the wibox is not enough to display it all so part of the string is cut out:

widget with long string

Is it possible to make wibox size change dynamically depending on size of the content?

streetturtle
  • 5,472
  • 2
  • 25
  • 43

1 Answers1

1

I'm not quit sure what you want. If you want to adjust the height of the wibox for the content:

After you change the text of the textboxes, run something like the following code:

local t1 = w:get_children_by_id("header")[1]
local t2 = w:get_children_by_id("body")[1]
local h1 = t1:get_height_for_width(w.width, w.screen)
local h2 = t2:get_height_for_width(w.width, w.screen)
w.height = h1 + h2

If you want some extra empty space like in your first screenshot, you could add some number to the height. 42 is always a good answer. ;-)

Uli Schlachter
  • 9,337
  • 1
  • 23
  • 39