peng3d.gui.slider
- Slider and Progressbar Widgets¶
-
class
peng3d.gui.slider.
Progressbar
(name: Optional[str], submenu: SubMenu, window: Any = None, peng: Any = None, *, pos: Union[List[float], Callable[[float, float, float, float], Tuple[float, float]], layout.LayoutCell], size: Union[List[float], Callable[[float, float], Tuple[float, float]], None] = None, bg=None, nmin=0, nmax=100, n=0, border=None, 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
andn
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
.
-
-
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.
-
class
peng3d.gui.slider.
AdvancedProgressbar
(name: Optional[str], submenu: SubMenu, window: Any = None, peng: Any = None, *, pos: Union[List[float], Callable[[float, float, float, float], Tuple[float, float]], layout.LayoutCell], size: Union[List[float], Callable[[float, float], Tuple[float, float]], None] = None, bg=None, categories=None, offset_nmin=0, offset_nmax=0, offset_n=0, border=None, 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
andoffset_nmax
parameters are equivalent to the parameters of the same name minus theoffset_
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. likewidget[cat][1]=100
, requires a manual call toredraw()
.When setting the
nmin
,n
ornmax
properties, only an internal offset value will be modified. This may result in otherwise unexpected behavior if setting e.g.n
tonmax
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. UseupdateCategory()
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. UseaddCategory()
instead if you want to add a category.
-
-
class
peng3d.gui.slider.
Slider
(name: Optional[str], submenu: SubMenu, window: Any = None, peng: Any = None, *, pos: Union[List[float], Callable[[float, float, float, float], Tuple[float, float]], layout.LayoutCell], size: Union[List[float], Callable[[float, float], Tuple[float, float]], None] = None, bg=None, border=None, borderstyle=None, nmin=0, nmax=100, n=0, handlesize=None)[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=None, 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.
-
-
class
peng3d.gui.slider.
VerticalSlider
(name: Optional[str], submenu: SubMenu, window: Any = None, peng: Any = None, *, pos: Union[List[float], Callable[[float, float, float, float], Tuple[float, float]], layout.LayoutCell], size: Union[List[float], Callable[[float, float], Tuple[float, float]], None] = None, bg=None, border=None, borderstyle=None, **kwargs)[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
andborder
compared toSlider
.
-
class
peng3d.gui.slider.
VerticalSliderBackground
(widget, border=None, 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.
-