peng3d.gui.slider - Slider and Progressbar Widgets

class peng3d.gui.slider.Progressbar(name, submenu, window, peng, pos=None, size=None, bg=None, nmin=0, nmax=100, n=0, border=[4, 4], borderstyle=None, colors=[[240, 119, 70], [240, 119, 70]])[source]

Progressbar displaying a progress of any action to the user.

By default, this Widget uses ProgressbarBackground as its Background class.

The border and borderstyle options are the same as for the peng3d.gui.button.Button Widget.

The two colors given are for left and right, respectively. This may be used to create gradients.

nmin, nmax and n represent the minimal value, maximal value and current value, respectively. Unexpected behavior may occur if the minimal value is bigger then the maximum value.

n

Property representing the current value of the progressbar.

Changing this property will activate the progresschange action.

nmax

Property representing the maximum value of the progressbar. Typically 100 to represent percentages easily.

nmin

Property representing the minimal value of the progressbar. Typically 0.

value

Alias to the n property.

class peng3d.gui.slider.ProgressbarBackground(widget, border, borderstyle, colors)[source]

Background for the Progressbar Widget.

This background displays a bar with a border similar to ButtonBackground. Note that two colors may be given, one for the left and one for the right.

init_bg()[source]

Called just before the background will be drawn the first time.

Commonly used to initialize vertex lists.

It is recommended to add all vertex lists to the submenu.batch2d Batch to speed up rendering and preventing glitches with grouping.

redraw_bg()[source]

Method called by the parent widget every time its Widget.redraw() method is called.

class peng3d.gui.slider.AdvancedProgressbar(name, submenu, window, peng, pos=None, size=None, bg=None, categories={}, offset_nmin=0, offset_nmax=0, offset_n=0, border=[4, 4], borderstyle=None, colors=[[240, 119, 70], [240, 119, 70]])[source]

Advanced Progressbar displaying the combined progress through multiple actions.

Visually, this widget is identical to Progressbar with the only difference being the way the progress percentage is calculated.

The offset_nmin, offset_n and offset_nmax parameters are equivalent to the parameters of the same name minus the offset_ prefix.

categories may be any dictionary mapping category names to 3-tuples of format (nmin,n,nmax).

It is possible to read, write and delete categories through the widget[cat] syntax. Note however, that modifying categories in-place, e.g. like widget[cat][1]=100, requires a manual call to redraw().

When setting the nmin, n or nmax properties, only an internal offset value will be modified. This may result in otherwise unexpected behavior if setting e.g. n to nmax because the categories may influence the total percentage calculation.

addCategory(name, nmin=0, n=0, nmax=100)[source]

Adds a category with the given name.

If the category already exists, a KeyError will be thrown. Use updateCategory() instead if you want to update a category.

deleteCategory(name)[source]

Deletes the category with the given name.

If the category does not exist, a KeyError will be thrown.

n

Property representing the current value of the progressbar.

Changing this property will activate the progresschange action.

nmax

Property representing the maximum value of the progressbar. Typically 100 to represent percentages easily.

nmin

Property representing the minimal value of the progressbar. Typically 0.

updateCategory(name, nmin=None, n=None, nmax=None)[source]

Smartly updates the given category.

Only values that are given will be updated, others will be left unchanged.

If the category does not exist, a KeyError will be thrown. Use addCategory() instead if you want to add a category.

class peng3d.gui.slider.Slider(name, submenu, window, peng, pos=None, size=[100, 24], bg=None, border=[4, 4], borderstyle=None, nmin=0, nmax=100, n=0, handlesize=[16, 24])[source]

Slider that can be used to get a number from the user.

By default, this Widget uses SliderBackground as its Background class.

Most options are the same as for Progressbar.

handlesize simply determines the size of the handle.

Note that scaling this widget on the y-axis will not do much, scale the handlesize instead.

p

Helper property containing the percentage this slider is “filled”.

This property is read-only.

class peng3d.gui.slider.SliderBackground(widget, border=[4, 4], borderstyle='flat', batch=None, change_on_press=None)[source]

Background for the Slider Widget.

This background displays a button-like handle on top of a bar representing the selectable range.

All given parameters will affect the handle.

getPosSize()[source]

Helper function converting the actual widget position and size into a usable and offsetted form.

This function should return a 6-tuple of (sx,sy,x,y,bx,by) where sx and sy are the size, x and y the position and bx and by are the border size.

All values should be in pixels and already include all offsets, as they are used directly for generation of vertex data.

This method can also be overridden to limit the background to a specific part of its widget.

init_bg()[source]

Called just before the background will be drawn the first time.

Commonly used to initialize vertex lists.

It is recommended to add all vertex lists to the submenu.batch2d Batch to speed up rendering and preventing glitches with grouping.

redraw_bg()[source]

Method called by the parent widget every time its Widget.redraw() method is called.

class peng3d.gui.slider.VerticalSlider(name, submenu, window, peng, pos=None, size=[24, 100], bg=None, border=[4, 4], borderstyle=None, nmin=0, nmax=100, n=0, handlesize=[24, 16])[source]

Vertical slider that can be used as a scrollbar or getting other input.

By default, this Widget uses VerticalSliderBackground as its Background class.

This widget is essentially the same as Slider, only vertical.

Note that you may need to flip the x and y values of size, handlesize and border compared to Slider.

class peng3d.gui.slider.VerticalSliderBackground(widget, border=[4, 4], borderstyle='flat', batch=None, change_on_press=None)[source]

Background for the VerticalSlider Widget.

This background uses the same technique as SliderBackground, simply turned by 90 Degrees.

getPosSize()[source]

Helper function converting the actual widget position and size into a usable and offsetted form.

This function should return a 6-tuple of (sx,sy,x,y,bx,by) where sx and sy are the size, x and y the position and bx and by are the border size.

All values should be in pixels and already include all offsets, as they are used directly for generation of vertex data.

This method can also be overridden to limit the background to a specific part of its widget.