Updating text in Eto Progress Bar

Hello, is it possible to dynamically update the text of an Eto progress bar?

Here my code:

import System
import Rhino
import Rhino.UI
import Eto.Drawing as drawing
import Eto.Forms as forms
import scriptcontext as sc


class SampleEtoModelessForm(forms.Form):
    
    # Initializer
    def __init__(self):
        self.m_selecting = False
        
        self.Title = title
        self.Padding = drawing.Padding(5)
        self.Resizable = True
        self.Maximizable = False
        self.Minimizable = False
        self.ShowInTaskbar = False
        self.Topmost = True
        self.MinimumSize = drawing.Size(500, 100)
        # FormClosed event handler
        self.Closed += self.OnFormClosed

        # Create Progress Bar
        self.m_progressbar = forms.ProgressBar()
        self.m_progressbar.MinValue = min
        self.m_progressbar.MaxValue = max
        self.m_textbox = forms.TextBox(Text = None)

        layout = forms.DynamicLayout()
        layout.Padding = drawing.Padding(10)
        layout.Spacing = drawing.Size(5, 5)
        layout.Rows.Add(forms.Label(Text = text))
        layout.AddRow(None) # spacer
    
        layout.AddRow(self.m_progressbar)
        self.Content = layout

    def updateProgressBar(self, value):
        
        self.m_progress = val
        if self.m_progress > max:
            self.m_progress = max
        self.m_progressbar.Value = self.m_progress

    def OnFormClosed(self, sender, e):

        if sc.sticky.has_key(title):
            form = sc.sticky[title]
            if form:
                form.Dispose()
                form = None
            sc.sticky.Remove(title)


if run:
    if sc.sticky.has_key(title):
        pass
    else:
        form = SampleEtoModelessForm()
        form.Owner = Rhino.UI.RhinoEtoApp.MainWindow
        form.Show()
        sc.sticky[title] = form
        
    form.updateProgressBar(val)


if reset:
    sc.sticky.clear()

if close:
    form.Dispose()

Screenshot_1

Can anyone help me with this? Maybe @curtisw ?

@Belen all you need to do is capture the label when you create it, something like:

myLabel = forms.Label(Text = text)

Then to update the text:

myLabel.Text = "Some New Text"

2 Likes

thank you @curtisw!