Creating tabs in Lua.

Forum for OctaneRender Lua scripting examples, discussion and support.
Post Reply
User avatar
stratified
OctaneRender Team
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Hi All,

From release 1.27, you can have tabs in your lua user interface. Tabs are similar to groups or panel stacks. They take a list of children, one for each tab. The tab component is resized to fit it's largest child component. Here's an example script:

Code: Select all

--
-- Tabbed component creation example
--


local button = octane.gui.create
{
    type   = octane.gui.componentType.BUTTON,
    width  = 100,
    height = 24,
    x      = 20,
    y      = 20,
    text   = "Button",
}

local table = octane.gui.create
{
    type   = octane.gui.componentType.TABLE,
    header = { "animal", "friendly" },
    items  =
    { 
        "cat"     , "no" ,
        "dog"     , "yes",
        "dolphin" , "yes",
        "shark"   , "no" ,
        "tiger"   , "no" ,
        "bear"    , "no" ,
        "seal"    , "yes",
        "horse"   , "yes",
        "eagle"   , "no" ,
        "zebra"   , "no" ,
        "elephant", "no" ,
        "hippo"   , "no" ,
    }
    ,
    widths      = { 200, 200},
    height      = 400,
    selectedRow = 2,
}

local tabs = octane.gui.create
{
    type       = octane.gui.componentType.TABS,
    children   = { table, button },         -- components, 1 for each tab
    header     = { "Animals", "Button" },   -- text to appear on each tab
    currentTab = 1,                         -- the initially selected tab
    callback   = function(comp, evt) print("Current tab: ", comp:getProperties().currentTab) end
}


local window = octane.gui.create
{
    type     = octane.gui.componentType.WINDOW,
    width    = tabs:getProperties().width,
    height   = tabs:getProperties().height,
    children = { tabs },
    text     = "Tabs Example",
}

window:showWindow()
Here's how it looks:
tab component example
tab component example
cheers,
Thomas
User avatar
grimm
Licensed Customer
Posts: 1332
Joined: Wed Jan 27, 2010 8:11 pm
Location: Spokane, Washington, USA

Awesome Thomas! :D I was going to ask you about these but I didn't want to put too much on you plate, and there you go and beat me to it. :twisted:

Jason
Linux Mint 21.3 x64 | Nvidia GTX 980 4GB (displays) RTX 2070 8GB| Intel I7 5820K 3.8 Ghz | 32Gb Memory | Nvidia Driver 535.171
User avatar
stratified
OctaneRender Team
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

grimm wrote:Awesome Thomas! :D I was going to ask you about these but I didn't want to put too much on you plate, and there you go and beat me to it. :twisted:

Jason
They come in very handy when trying to structure more complex UIs. Having a single huge window doesn't scale.

cheers,
Thomas
Tugpsx
Licensed Customer
Posts: 1150
Joined: Thu Feb 04, 2010 8:04 pm
Location: Chicago, IL
Contact:

Sweet, it only gets better.
Win 11 64GB | NVIDIA RTX3060 12GB
Post Reply

Return to “Lua Scripting”