Package dtk :: Package ui :: Module listview :: Class ListView

Class ListView

source code


Powerful listview widget.

Instance Methods
 
__init__(self, sorts=[], drag_data=None, enable_multiple_select=True, enable_drag_drop=True, drag_icon_pixbuf=ui_theme.get_pixbuf("listview/drag_preview.png"), drag_out_offset=50)
Initialize ListView widget.
source code
 
set_expand_column(self, column)
Set expand column.
source code
 
add_titles(self, titles, title_height=24)
Add titles.
source code
 
get_title_sizes(self)
Get title sizes.
source code
 
add_items(self, items, insert_pos=None, sort_list=False)
Add items in listview.
source code
 
sort_items(self, compare_method, sort_reverse=False)
Sort items with given method.
source code
 
redraw_item(self, list_item)
Redraw item.
source code
 
update_item_index(self)
Update index of items.
source code
 
set_title_height(self, title_height)
Set title height.
source code
 
get_column_sort_type(self, column)
Get sort type with given column index.
source code
 
set_column_sort_type(self, column, sort_type)
Set sort type with given value.
source code
 
get_cell_widths(self)
Get cell width of columns.
source code
 
set_cell_width(self, column, width)
Set cell width with given value.
source code
 
reset_cursor(self)
Reset cursor type.
source code
 
get_offset_coordinate(self, widget)
Get viewport offset coordinate and viewport.
source code
 
draw_shadow_mask(self, cr, x, y, w, h)
Shadow mask interface for overwrite.
source code
 
draw_mask(self, cr, x, y, w, h)
Draw mask interface.
source code
 
draw_item_hover(self, cr, x, y, w, h)
Draw item hover interface.
source code
 
draw_item_select(self, cr, x, y, w, h)
Draw item select interface.
source code
 
draw_item_highlight(self, cr, x, y, w, h)
Draw item highlight interface.
source code
 
keep_select_status(self)
Handy function that change listview and keep select status not change.
source code
 
is_in_visible_area(self, event)
Is event coordinate in visible area.
source code
 
emit_item_event(self, event_name, event)
Wrap method for emit event signal.
source code
 
get_coordinate_row(self, y)
Get row with given y coordinate.
source code
 
get_event_row(self, event, offset_index=0)
Get row at event.
source code
 
select_first_item(self)
Select first item.
source code
 
select_last_item(self)
Select last item.
source code
 
scroll_page_up(self)
Scroll page up.
source code
 
scroll_page_down(self)
Scroll page down.
source code
 
select_prev_item(self)
Select preview item.
source code
 
select_next_item(self)
Select next item.
source code
 
select_to_prev_item(self)
Select to preview item.
source code
 
select_to_next_item(self)
Select to next item.
source code
 
select_to_first_item(self)
Select to first item.
source code
 
select_to_last_item(self)
Select to last item.
source code
 
select_all_items(self)
Select all items.
source code
 
delete_select_items(self)
Delete select items.
source code
 
update_vadjustment(self)
Update vertical adjustment.
source code
 
double_click_item(self)
Double click item.
source code
 
clear(self)
Clear all list.
source code
 
get_current_item(self)
Get current item.
source code
 
set_highlight(self, item)
Set highlight with given item.
source code
 
clear_highlight(self)
Clear highlight status.
source code
 
visible_highlight(self)
Visible highlight item.
source code
Class Variables
  SORT_DESCENDING = False
  SORT_ASCENDING = True
  SORT_PADDING_X = 5
  TITLE_PADDING = 5
  __gsignals__ = {"delete-select-items":(gobject.SIGNAL_RUN_LAST...
Method Details

__init__(self, sorts=[], drag_data=None, enable_multiple_select=True, enable_drag_drop=True, drag_icon_pixbuf=ui_theme.get_pixbuf("listview/drag_preview.png"), drag_out_offset=50)
(Constructor)

source code 

Initialize ListView widget.

Parameters:
  • sorts - Sort function for column of listview.
  • drag_data - Drag data for drag data from listview, format: (targets, actions, button_masks)
  • enable_multiple_select - Whether allow user select multiple item, default is True.
  • enable_drag_drop - Whether allow user drag drop on listview, default is True.
  • drag_icon_pixbuf - Drag icon.
  • drag_out_offset - Out offset value to trigger drag action on listview, default is 50 pixel, if cursor not drag more than 50 pixel, listview won't think it is drag out action.

set_expand_column(self, column)

source code 

Set expand column.

Parameters:
  • column - Column index to expand space.

add_titles(self, titles, title_height=24)

source code 

Add titles.

Parameters:
  • titles - A list of title.
  • title_height - Height of title.

get_title_sizes(self)

source code 

Get title sizes.

Returns:
Return title size, as format (title_width, title_height).

add_items(self, items, insert_pos=None, sort_list=False)

source code 

Add items in listview.

Parameters:
  • items - A list of item.
  • insert_pos - The position to insert, default is None will insert new item at end of list.
  • sort_list - Whether sort list after insert, default is False.

sort_items(self, compare_method, sort_reverse=False)

source code 

Sort items with given method.

Parameters:
  • compare_method - Compare method to sort.
  • sort_reverse - Whether sort reverse, default is False.

redraw_item(self, list_item)

source code 

Redraw item.

Parameters:
  • list_item - List item need to redraw.

get_column_sort_type(self, column)

source code 

Get sort type with given column index.

Parameters:
  • column - Column index.
Returns:
Return sort type with given column index, return None if haven't found match column index.

set_column_sort_type(self, column, sort_type)

source code 

Set sort type with given value.

Parameters:
  • column - Column index.
  • sort_type - Sort type.

set_cell_width(self, column, width)

source code 

Set cell width with given value.

Parameters:
  • column - Column index.
  • width - Column width.

get_offset_coordinate(self, widget)

source code 

Get viewport offset coordinate and viewport.

Parameters:
  • widget - ListView widget.
Returns:
Return viewport offset and viewport: (offset_x, offset_y, viewport).

draw_shadow_mask(self, cr, x, y, w, h)

source code 

Shadow mask interface for overwrite.

Parameters:
  • cr - Cairo context.
  • x - X coordiante of draw area.
  • y - Y coordiante of draw area.
  • w - Width of draw area.
  • h - Height of draw area.

draw_mask(self, cr, x, y, w, h)

source code 

Draw mask interface.

Parameters:
  • cr - Cairo context.
  • x - X coordiante of draw area.
  • y - Y coordiante of draw area.
  • w - Width of draw area.
  • h - Height of draw area.

draw_item_hover(self, cr, x, y, w, h)

source code 

Draw item hover interface.

Parameters:
  • cr - Cairo context.
  • x - X coordiante of draw area.
  • y - Y coordiante of draw area.
  • w - Width of draw area.
  • h - Height of draw area.

draw_item_select(self, cr, x, y, w, h)

source code 

Draw item select interface.

Parameters:
  • cr - Cairo context.
  • x - X coordiante of draw area.
  • y - Y coordiante of draw area.
  • w - Width of draw area.
  • h - Height of draw area.

draw_item_highlight(self, cr, x, y, w, h)

source code 

Draw item highlight interface.

Parameters:
  • cr - Cairo context.
  • x - X coordiante of draw area.
  • y - Y coordiante of draw area.
  • w - Width of draw area.
  • h - Height of draw area.

keep_select_status(self)

source code 

Handy function that change listview and keep select status not change.

Decorators:
  • @contextmanager

is_in_visible_area(self, event)

source code 

Is event coordinate in visible area.

Parameters:
  • event - gtk.gdk.Event.
Returns:
Return True if event coordiante in visible area.

emit_item_event(self, event_name, event)

source code 

Wrap method for emit event signal.

Parameters:
  • event_name - Event name.
  • event - Event.

get_coordinate_row(self, y)

source code 

Get row with given y coordinate.

Parameters:
  • y - Y coordinate.
Returns:
Return row that match given y coordinate, return None if haven't any row match y coordiante.

get_event_row(self, event, offset_index=0)

source code 

Get row at event.

Parameters:
  • event - gtk.gdk.Event instance.
  • offset_index - Offset index base on event row.
Returns:
Return row at event coordinate, return None if haven't any row match event coordiante.

get_current_item(self)

source code 

Get current item.

Returns:
Return select row, or return None if not any item selected.

Class Variable Details

__gsignals__

Value:
{"delete-select-items":(gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (g\
object.TYPE_PYOBJECT,)), "button-press-item":(gobject.SIGNAL_RUN_LAST,\
 gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT, int, int, int)), "single-c\
lick-item":(gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_\
PYOBJECT, int, int, int)), "double-click-item":(gobject.SIGNAL_RUN_LAS\
T, gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT, int, int, int)), "motion\
-notify-item":(gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TY\
PE_PYOBJECT, int, int, int)), "right-press-items":(gobject.SIGNAL_RUN_\
...