Creating a counter using UI elements

Typically: "How do I... ", "How can I... " questions
Post Reply
mohtashem
Posts: 15
Joined: 17 Apr 2017, 20:03

Creating a counter using UI elements

Post by mohtashem »

Hello,

I wanted to create a counter (with deletion box) just like the ones in blobDetectionWithPickAndPlace.ttt using the Qt-based custom UI's (Since the scene is based on OpenGl-based custom UI which seems to have been removed a while back) . Is there any example or scene that one could use as a tutorial or a reference? If not, any hints as to which functions to use?

Cheers,

mohtashem

fferri
Posts: 1217
Joined: 09 Sep 2013, 19:28

Re: Creating a counter using UI elements

Post by fferri »

You can create a label and change its text with simUI.setLabelText, e.g.:

Code: Select all

function sysCall_init()
    ui=simUI.create([[<ui>
            <label id="100" text="Count:" />
            <label id="101" text="0" style="font-size: 30px" />
        </ui>]])
    count=0
end

function sysCall_actuation()
    count=count+1
    simUI.setLabelText(ui,101,''..count)
end
Image

mohtashem
Posts: 15
Joined: 17 Apr 2017, 20:03

Re: Creating a counter using UI elements

Post by mohtashem »

Exactly what's needed. Thank you so much.

Cheers,
mohtashem

Post Reply