TGUI Forum

General Category => Help requests => Topic started by: eugustus on 29 December 2020, 18:55:21

Title: How to use file form generated by GUI_BUILDER?
Post by: eugustus on 29 December 2020, 18:55:21
Hi. I can't find anywhere how to use the form generated by gui_builder.
Is there a guide, an example or maybe someone can tell me, how I can use the generated code?
Thank you.

P.S. I use TGUI version 0.8.8
Title: Re: How to use file form generated by GUI_BUILDER?
Post by: texus on 29 December 2020, 18:58:24
You can call gui.loadWidgetsFromFile(filename).
You can also call the function on a Container widget instead of on the Gui, in case you want the form to be loaded inside a child window.

The only place where this is currently mentioned is the tgui homepage (https://tgui.eu/). It doesn't belong there, but I placed it there to have it at least mentioned somewhere :)
Title: Re: How to use file form generated by GUI_BUILDER?
Post by: eugustus on 29 December 2020, 19:22:10
So, the generated form looks like this:

Panel."panel-quick" {
    Size = (110, 400);

    Renderer {
        backgroundcolor = #7F7F7F;
        bordercolor = black;
        font = "/home/denis/projects/test-sfml/data/ubuntu_font/Ubuntu-C.ttf";
        padding = (2, 2, 2, 2);
        texturebackground = None;
    }
}


Loading:

m_tgui->loadWidgetsFromFile("/home/denis/projects/test-sfml/data/themes/test.txt", true);

I'm getting this error:

tgui/src/TGUI/Container.cpp:218: virtual void tgui::Container::add(const Ptr&, const sf::String&): Assertion `widgetPtr != nullptr' failed.

:)



         
         
Title: Re: How to use file form generated by GUI_BUILDER?
Post by: eugustus on 29 December 2020, 19:27:24
Sorry it's OK. I had a typo in the code ...

Thank you for your help!