I finally created my first extension, where I load a cube and copy it to 100 rows and 100 columns. It takes quite a while, like 5 minutes or more to create 10,000. Not sure if there is any way to speed this up.
A progress bar would be nice to show, but I don’t know how to create / use it.
I tried looking through docs, but I haven’t found it yet.
@DataJuggler There is an omni.ui.ProgressBar in the omni.ui doc. Here is the snippet:
progressbar = ui.ProgressBar(width=300)
progressbar.model.set_value(progress) # Set float value, and maximum is 100.
progressbar.get_value_as_float() # Get its progress.
Or you can define it’s model to customize the format string of progress.
class CustomProgressModel(ui.AbstractValueModel):
def __init__(self):
super().__init__()
self._value = 0.0
def set_value(self, value):
"""Reimplemented set"""
try:
value = float(value)
except ValueError:
value = None
if value != self._value:
# Tell the widget that the model is changed
self._value = value
self._value_changed()
def get_value_as_float(self):
return self._value
def get_value_as_string(self): # Format string
return str(int(self._value * 100)) + "%"
Then, you can initialize progress bar like progressbar = ui.ProgressBar(CustomProgressModel(), width=300).