pydui.widgets package

Submodules

pydui.widgets.button module

class pydui.widgets.button.PyDuiButton

Bases: PyDuiLabel

Button widget

property bkimage_disable: str
property bkimage_hover: str
property bkimage_press: str
static build_name() str
draw_bkimage(ctx: Context, dirty_rect: PyDuiRect, clip_rect: PyDuiRect)
get_bindevents() List[str]
get_signals() List[str]
on_lbutton_click(x: float, y: float) None
on_lbutton_dbclick(x: float, y: float) None
on_lbutton_press(x: float, y: float) bool
on_lbutton_release(x: float, y: float) bool
on_lbutton_tripleclick(x: float, y: float) None
on_mouse_enter() None
on_mouse_leave(next_widget: Optional[PyDuiWidget]) None
on_rbutton_click(x: float, y: float) None
on_rbutton_dbclick(x: float, y: float) None
on_rbutton_tripleclick(x: float, y: float) None
parse_attrib(k: str, v: str)

Parse single attribute

Parameters:

attrib (Dict[str, str]) – attributes dict key=value …

class pydui.widgets.button.PyDuiButtonState(value)

Bases: Enum

Button State

HOVER = (1,)
NORMAL = (0,)
PRESS = (2,)

pydui.widgets.edit module

class pydui.widgets.edit.PyDuiEdit

Bases: PyDuiPGView

static build_name() str
draw(ctx: Context, dirty_rect: PyDuiRect, clip_rect: PyDuiRect)
property editable: bool
get_font() str
get_fontsize() int
get_signals() List[str]
get_textpadding() PyDuiEdge
layout(x: float, y: float, width: float, height: float, constraint: PyDuiLayoutConstraint)
on_post_init()
parse_attrib(k: str, v: str)

Parse single attribute

Parameters:

attrib (Dict[str, str]) – attributes dict key=value …

set_font(font: str)
set_fontsize(fontsize: int)
set_textpadding(text_padding: PyDuiEdge)
property text: str

pydui.widgets.icon module

class pydui.widgets.icon.PyDuiIcon

Bases: PyDuiLabel

static build_name() str
parse_attrib(k: str, v: str)

Parse single attribute

Parameters:

attrib (Dict[str, str]) – attributes dict key=value …

pydui.widgets.label module

class pydui.widgets.label.PyDuiLabel

Bases: PyDuiPGView

Label widget

font

font family name

Type:

str

fontsize

fontsize in pt unit

Type:

int

fontcolor

font color

Type:

Gdk.RGBA

ellipsis

ellipsis mode, [NONE, START, MIDDLE, END], default is END

Type:

str

wrap

wrap mode, [NONE, WORD, CHAR, WORD_CHAR], default is WORD

Type:

str

halign

horizontal TextAlign, [CENTER, STAET, END], default is CENTER

Type:

str

valign

vertical TextAlign, [CENTER, STAET, END], default is CENTER

Type:

str

line_spacing

line spacing

Type:

float

autofit

text is autofit or not

Type:

bool

autofit_padding

when autofit is set, autofit area padding

Type:

Rect

text_padding

text padding

Type:

Rect

static build_name() str
draw(ctx: Context, dirty_rect: PyDuiRect, clip_rect: PyDuiRect)
draw_text(ctx: Context, dirty_rect: PyDuiRect, clip_rect: PyDuiRect)
estimate_size(parent_width: float, parent_height: float, constraint: PyDuiLayoutConstraint) Tuple[float, float]
parse_attrib(k: str, v: str)

Parse single attribute

Parameters:

attrib (Dict[str, str]) – attributes dict key=value …

property text: str

pydui.widgets.listview module

class pydui.widgets.listview.PyDuiListNode

Bases: object

class pydui.widgets.listview.PyDuiListView

Bases: PyDuiLayoutWithPogaSupport

add_child(child: PyDuiWidget)

Add child widget.

if child has been added, ignore.

Parameters:

child (PyDuiWidget) – child widget

add_child_at(child: PyDuiWidget, index: int)

Add child widget at index

if the index overbound, it will add widget to last position.

Parameters:
  • child (PyDuiWidget) – child widget

  • index (int) – target index

Returns:

return widget object.

Return type:

PyDuiWidget

static build_name() str
reload()
remove_child(child: PyDuiWidget)

Remove child widget.

Parameters:

widget (PyDuiWidget) – widget object

remove_child_at(index: int)

Remove child widget at index

if the index overbound, do nothing.

Parameters:

index (int) – widget index

remove_child_by_id(widget_id: str)

Remove child widget by widget_id

Parameters:

widget_id (str) – widget id

set_datasource(datasource: PyDuiListViewDataSource)
class pydui.widgets.listview.PyDuiListViewDataSource(*args, **kwargs)

Bases: Protocol

abstract item_count() int
abstract item_node(index: int) PyDuiListNode
class pydui.widgets.listview.PyDuiListViewDelegate(*args, **kwargs)

Bases: Protocol

abstract create_item_by_node(index: int, node: PyDuiListNode) PyDuiWidget
abstract item_height(index: int) float

pydui.widgets.pgview module

class pydui.widgets.pgview.PyDuiPGView

Bases: PyDuiWidget, PogaView

bounds_size() Tuple[float, float]

Return the layout bounds size.

Returns:

bounds size, mainly equal the frame size.

Return type:

Tuple[float, float]

static build_name() str
draw(ctx: Context, dirty_rect: PyDuiRect, clip_rect: PyDuiRect)
frame_origin() Tuple[float, float]

Return frame position.

Returns:

Return frame (x, y) position.

Return type:

Tuple[float, float]

is_container() bool

Return current view is container or not.

Returns:

Return True is container.

Return type:

bool

parse_attrib(k: str, v: str)

Parse single attribute

Parameters:

attrib (Dict[str, str]) – attributes dict key=value …

poga_layout() PogaLayout

Return PogaLayout

Returns:

PogaLayout object

Return type:

PogaLayout

set_frame_position_and_size(x: float, y: float, width: float, height: float)

Set the frame position and size.

Parameters:
  • x (float) – Frame x position

  • y (float) – Frame y position

  • width (float) – Frame width

  • height (float) – Frame height

size_that_fits(width: float, height: float) Tuple[float, float]

Calculate the frame size.

Parameters:
  • width (float) – Parent layout width.

  • height (float) – Parent layout height.

Returns:

Return frame size (width, height).

Return type:

Tuple[float, float]

subviews() List[PogaView]

Return subviews, subview type must be PogaView.

Returns:

subviews

Return type:

Iterable[PogaView]

subviews_count() int

Return subviews count.

Returns:

subviews count

Return type:

int

pydui.widgets.picture module

class pydui.widgets.picture.PyDuiPicture

Bases: PyDuiLabel

static build_name() str
parse_attrib(k: str, v: str)

Parse single attribute

Parameters:

attrib (Dict[str, str]) – attributes dict key=value …

pydui.widgets.scrollbar module

class pydui.widgets.scrollbar.PyDuiScrollbar

Bases: PyDuiLayout

static build_name() str
draw(ctx: Context, dirty_rect: PyDuiRect, clip_rect: PyDuiRect)

Draw layout and children widgets.

Parameters:
  • ctx (cairo.Context) – draw context, replace cairo.Context to DrawContext later.

  • dirty_rect (PyDuiRect) – dirty rect, relative to root

  • clip_rect (PyDuiRect) – clip rect, relative to root

get_signals() List[str]
layout(x: float, y: float, width: float, height: float, constraint: PyDuiLayoutConstraint)
Parameters:
  • x (float) – x offset relative to parent

  • y (float) – y offset relative to parent

  • width (float) – widget width

  • height (float) – widget height

  • constraint (PyDuiLayoutConstraint) – layout constraint

on_post_init()
parse_attrib(k: str, v: str)

Parse single attribute

Parameters:

attrib (Dict[str, str]) – attributes dict key=value …

property scroll_position: float
set_scrollbar_type(type: PyDuiScrollbarType)
update_scroller(size: float)
class pydui.widgets.scrollbar.PyDuiScrollbarType(value)

Bases: Enum

An enumeration.

HScrollbar = 1
VScrollbar = 0

Module contents

Widget Module