Git Product home page Git Product logo

Comments (5)

ArthurSonzogni avatar ArthurSonzogni commented on August 22, 2024

Is it possible to dynamically add elements/children to checkmarks like this?

Yes it is possible.


I will take a look later today.
Maybe you can upload a video or a terminal record reproducing what you are seeing? In particular the crash?

from ftxui.

dr-mrsthemonarch avatar dr-mrsthemonarch commented on August 22, 2024

Absolutely. It is random generally, but I happened to capture it in the first try. Usually it happens immediately, but in this case, it took some tries.

You can find the source code here: source If you want to look further in depth of my implementation, beyond the code I posted here.

and here is the recording. terminal record

from ftxui.

dr-mrsthemonarch avatar dr-mrsthemonarch commented on August 22, 2024

Here's a link to the asciinema to play it, if the above recording doesn't work correctly:
[recording](
the animator)

from ftxui.

dr-mrsthemonarch avatar dr-mrsthemonarch commented on August 22, 2024

Hello,

After some time, I've managed to have clients display dynamically as text, seen below:

Screenshot 2024-06-20 at 23 26 32

But I cannot get them to show up as actual checkboxes, only text, when trying with the following code, the list shows just empty.

   // -- client list
    // ----------------------------------------------------------------------
    std::array<bool, 10> states;
    auto lister = Renderer([&] {
        auto checkboxes = Container::Vertical({});
        Elements children = {};

        for (size_t i = std::max(0, (int) clientVec.vec.size() - 9); i < clientVec.vec.size(); ++i) {
            std::lock_guard<std::mutex> lock(clientVec.vecMutex);
            children.push_back(text(clientVec.vec[i]));
            checkboxes->Add(Checkbox(clientVec.vec[i], &states[i]));
        };
        return vbox(checkboxes) | size(HEIGHT, EQUAL, 3);
    });

    lister = Wrap("Clients", lister);

I'm unsure why this doesn't work...though my guess is that the checkboxes need to be updated/passed to the renderer in a different way.

Do you have any code examples/suggestions?

I have also since updated the source code to use cmake for compiling, should you want to look at the project again.

from ftxui.

dr-mrsthemonarch avatar dr-mrsthemonarch commented on August 22, 2024

image

I have successfully added achieved the checkboxes to update dynamically, with the following code:

    std::array<bool, 10> states;

    auto lister = Renderer([&] {
        Component clist = Container::Vertical({});
    for (size_t i = std::max(0, (int) clientVec.vec.size() - 9); i < clientVec.vec.size(); ++i) {
            std::lock_guard<std::mutex> lock(clientVec.vecMutex);
            clist ->Add(Checkbox(clientVec.vec[i], &states[i]));
        };
        return clist->Render() | size(HEIGHT, EQUAL, 3) | vscroll_indicator ;
    });
    ```

from ftxui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.