PBToolboxAI v4 ← Site

progressbar — u_pbt_progressbar #

← Component reference · Guide contents

Themed progress bar: horizontal bar or ring, numeric value or waiting animation, percentage display, free choice of color.

▶ See it live — Demo application, Progress tile: the preview, the code behind it and this page, side by side.


At a glance #

Userobjectu_pbt_progressbar
Item class— (component without items)
Used forShowing how far a long operation has gone: import, export, printing, server call
Two use casesdeterminate (you know the progress) or indeterminate (you only know that work is in progress)

Quick start #

// window open event
uo_progress.ib_label = true          // shows the percentage next to the bar
uo_progress.id_maximum = ll_total    // the scale of the job : nothing to compute
// During the operation : give the raw value, row by row. It costs almost
// nothing : the bar is redrawn only when what it shows changes.
for ll_i = 1 to ll_total
    of_process_row(ll_i)
    uo_progress.id_value = ll_i
next

Properties #

PropertyTypeDefaultPurpose
id_valuedouble0Current progress, a RAW value on the id_minimum … id_maximum scale, read back as you last set it (not bounded). The label rounds down: 99.6 shows 99 %, 100 % means finished. Setting it on every row of a loop costs almost nothing: the bar is redrawn only when what it shows changes (a tenth of a percent)
id_minimumdouble0Lower bound of the scale. A double: a 0..1 fraction is a valid scale
id_maximumdouble100Upper bound of the scale. A double: a byte count over 2 GB is a valid scale. Empty or inverted range (min ≥ max): 100 % once the value reaches the maximum, 0 % before — an empty batch (id_maximum = 0, id_value = 0) shows as finished
is_modestring"linear"Shape of the component: linear (a horizontal bar that takes the whole width of the control and follows its height: it fits where an HProgressBar stood) or circular (ring) — constants MODE_LINEAR, MODE_CIRCULAR. An unknown value falls back to linear
ib_indeterminatebooleanfalseWaiting mode: a sliding bar, or a fixed arc spinning in circular mode; id_value is ignored but kept. When Windows asks for fewer animations, the waiting state pulses instead of moving
ib_labelbooleanfalseDisplays the percentage next to the bar or at the center of the ring, in the display language ("50%" in English, "50 %" in French). is_label_format changes what it says
is_label_formatstring""What the label says (ib_label). Empty = the percentage. Otherwise a text in which {percent}, {value}, {min} and {max} are replaced, numbers written in the display language; the rest is written as it stands, as plain text. The screen reader says the same text
is_statestring"normal"The meaning of the bar, like the Windows progress bar: STATE_NORMAL (accent color), STATE_PAUSED (yellow, the job waits) or STATE_ERROR (red, the job failed). Paused and error take the status colors of the theme, light or dark, and win over il_color; a busy bar stops moving. An unknown value counts as STATE_NORMAL
il_colorlong-1Fill color, in PowerBuilder RGB() format. -1 = accent color of the theme. When paused or in error (is_state), the state color wins
is_theme_stylestring""Visual style of the component (THEME_STYLE_* constants); empty = the application's, followed at every change
is_theme_modestring""Light or dark variant (THEME_MODE_* constants); empty = the application's, followed at every change
il_theme_accentlong-1Accent colour of this component (-1 = the application accent, or the theme's)

This component publishes no tooltip (is_tooltip, is_super_tooltip_*): a progress bar reads by itself, and a caption on hover would appear under the pointer at the very moment the user is looking elsewhere. Put the progress commentary in a statictext or a statusbar next to the bar.


Methods #

MethodPurpose
of_reset ( )Resets every property to its default (linear bar, 0–100 scale, value 0, percentage hidden, theme color). Returns 0 once applied, -2 when the component is not created
of_set_redraw (boolean)Groups a burst of changes into a single render. Returns 0 once applied, -2 when the component is not created
of_save_as_png (string) · of_save_as_jpg (string)Exports the rendering as an image. Returns 0 once the image is written, -4 when writing fails, -2 when the component is not created

Events #

EventRaised when
ue_ready ( )The component has finished loading; everything sent beforehand has been replayed
ue_runtime_missing ( )The WebView2 runtime is missing: the component stays empty
ue_bg_color (long al_color)The component has computed its theme background color; the userobject has already adopted it (backcolor)

Examples #

Determinate progress with a percentage #

// Show the percentage, then move the bar
uo_progress.ib_label = true
uo_progress.id_value = 75     // the bar fills up to three quarters

Indeterminate progress (unknown duration) #

// When the duration is unknown : the bar animates continuously
// and ignores id_value
uo_progress.ib_indeterminate = true
// Once the duration is known, switch back to determinate mode
uo_progress.ib_indeterminate = false
uo_progress.id_value = 20

Circular ring #

// Display mode : linear (bar) or circular (ring)
uo_progress.is_mode  = u_pbt_progressbar.MODE_CIRCULAR
uo_progress.ib_label = true
uo_progress.id_value = 40

Custom scale #

// Progress is not always a percentage : give the real scale
uo_progress.id_minimum = 0
uo_progress.id_maximum = ll_row_count    // e.g. 4820 rows to import

// Then report the row being processed
uo_progress.id_value = ll_current_row // raw value, not a percentage

The percentage displayed by ib_label is still computed against that scale.

Custom color and driving the value #

// Show the percentage next to the bar
uo_progress.ib_label = true

// The fill color accepts a standard PowerBuilder RGB()
uo_progress.il_color = RGB(/*red*/ 16, /*green*/ 137, /*blue*/ 62)

// The bar displays a value, it never computes one : your code moves it
uo_progress.id_value = 0
// timer event of the window, once a second
if uo_progress.id_value >= 100 then
	Timer(0)   // done : your code knows, it is the one that decided
	uo_status.of_panel(/*key*/ "main").is_text = "Import complete"
else
	uo_progress.id_value = uo_progress.id_value + 10
end if

Custom label and failed state #

// The label counts rows instead of a bare percentage
uo_progress.ib_label = true
uo_progress.id_maximum = 4820
uo_progress.id_value = 3120
uo_progress.is_label_format = "{value} of {max} rows ({percent})"

// The import failed at this row : the bar turns red where it stands
uo_progress.is_state = u_pbt_progressbar.STATE_ERROR

Best practices #

Inherited from the common base #

These members exist on every visual component — they are not specific to this one. They are detailed once, in the transverse chapters; this table only says where to read them.

MembersRoleDetailed in
of_resetPut the component back to zero3.6 Resetting a component: of_reset()
of_register_shortcut · of_clear_shortcutsThe component's keyboard chords3.5 Keyboard shortcuts
of_is_created · of_is_ready · of_get_last_errorWhether it was born, whether it is ready, what failed3.7 Diagnostics
of_save_as_png · of_save_as_jpgExport the rendering as an image3.8 Exporting the rendering as an image
of_set_redrawGroup changes into a single repaint3.10 Best practices
of_preload_iconsIcons shown with no delayInstant display: of_icon
of_set_translationTranslate one of the component's labels5.2 Adapting a label: of_set_translation
of_focus_webviewGive the component the focus6.4 Keyboard and focus
of_print · of_print_to_pdfPrint, or write a PDF6.9 Printing
of_set_property · of_get_property · of_component_nameDriving a property by its name3.1 The property engine

Two helpers are not inherited: of_icon and of_escape_markup live on n_pbt_utils. Declare one — n_pbt_utils lnv_utils, nothing to create — and call them on it.


← Component reference · Guide contents