Package dtk :: Package ui :: Module utils

Module utils

source code

Functions
 
tree_view_get_toplevel_node_count(treeview)
Get node count number of TreeView.
source code
 
tree_view_get_selected_path(treeview)
Get selected path of TreeView.
source code
 
tree_view_focus_first_toplevel_node(treeview)
Focus first toplevel node of TreeView.
source code
 
tree_view_focus_last_toplevel_node(treeview)
Focus last toplevel node of TreeView.
source code
 
tree_view_scroll_vertical(treeview, scroll_up=True)
Scroll TreeView vertically.
source code
 
tree_view_focus_next_toplevel_node(treeview)
Focus next toplevel node of TreeView.
source code
 
tree_view_focus_prev_toplevel_node(treeview)
Focus previous toplevel node of TreeView.
source code
 
get_entry_text(entry)
Get text of entry.
source code
 
set_cursor(cursor_widget, cursor_type=None)
Set cursor type with given widget.
source code
 
set_clickable_cursor(widget)
Show gtk.gdk.HAND2 cursor when mouse hover widget.
source code
 
set_hover_cursor(widget, cursor_type)
Set cursor type when mouse hover widget.
source code
 
get_widget_root_coordinate(widget, pos_type=WIDGET_POS_BOTTOM_CENTER)
Get root coordinate with given widget.
source code
 
get_event_root_coords(event)
Get root coordinate with given event.
source code
 
get_event_coords(event)
Get coordinate with given event.
source code
 
propagate_expose(widget, event)
Propagate expose to children.
source code
 
move_window(widget, event, window)
Move window with given widget and event.
source code
 
resize_window(widget, event, window, edge)
Resize window with given widget and event.
source code
 
add_in_scrolled_window(scrolled_window, widget, shadow_type=gtk.SHADOW_NONE)
Add widget in scrolled_window.
source code
 
is_single_click(event)
Whether an event is single click event.
source code
 
is_double_click(event)
Whether an event is double click event.
source code
 
is_left_button(event)
Whether event is left button event.
source code
 
is_right_button(event)
Whehter event is right button event.
source code
 
is_middle_button(event)
Whehter event is middle button event.
source code
 
foreach_container(widget, callback)
Make callback call for all children of widget.
source code
 
foreach_recursive(container, callback)
Helper function for foreach_container.
source code
 
container_remove_all(container)
Handy function to remove all children widget from container.
source code
 
get_screen_size(widget)
Get screen size from the toplevel window associated with widget.
source code
 
is_in_rect((tx, ty), (x, y, w, h))
Whether target coordinate in given rectangle.
source code
 
scroll_to_top(scrolled_window)
Scroll scrolled_window to top position.
source code
 
scroll_to_bottom(scrolled_window)
Scroll scrolled_window to bottom position.
source code
 
get_content_size(text, text_size=DEFAULT_FONT_SIZE, text_font=DEFAULT_FONT, wrap_width=None)
Get text size, in pixel.
source code
 
create_directory(directory, remove_first=False)
Create directory.
source code
 
remove_file(path)
Remove file if file exist.
source code
 
remove_directory(path)
Remove directory recursively, equivalent to command `rm -rf path`.
source code
 
touch_file(filepath)
Touch file, equivalent to command `touch filepath`.
source code
 
read_file(filepath, check_exists=False)
Read file content.
source code
 
read_first_line(filepath, check_exists=False)
Read first line of file.
source code
 
eval_file(filepath, check_exists=False)
Eval file content.
source code
 
write_file(filepath, content)
Write file with given content.
source code
 
kill_process(proc)
Kill process.
source code
 
get_command_output_first_line(commands)
Run command and return first line of output.
source code
 
get_command_output(commands)
Run command and return output.
source code
 
run_command(command)
Run command silencely.
source code
 
get_os_version()
Get OS version with command `lsb_release -i`.
source code
 
get_current_time(time_format="%Y-%m-%d %H:%M:%S")
Get current time with given time format.
source code
 
add_in_list(e_list, element)
Add element in list, don't add if element has in list.
source code
 
remove_from_list(e_list, element)
Try remove element from list, do nothing if element not in list.
source code
 
sort_alpha(e_list)
Sort list with alpha order.
source code
 
get_dir_size(dirname)
Get size of given directory.
source code
 
print_env()
Print environment variable.
source code
 
print_exec_time(func)
Print execute time of function.
source code
 
get_font_families()
Get all font families in system.
source code
 
format_file_size(bytes, precision=2)
Returns a humanized string for a given amount of bytes.
source code
 
add_color_stop_rgba(pat, pos, color_info)
Add color stop as rgba format.
source code
 
alpha_color_hex_to_cairo((color, alpha))
Convert alpha color (color, alpha) to cairo color (r, g, b, alpha).
source code
 
color_hex_to_rgb(color)
Convert hex color to cairo color (r, g, b).
source code
 
color_hex_to_cairo(color)
Convert a html (hex) RGB value to cairo color.
source code
 
color_rgb_to_hex(rgb_color)
Convert cairo color to hex color.
source code
 
color_rgb_to_cairo(color)
Convert a 8 bit RGB value to cairo color.
source code
 
get_match_parent(widget, match_types)
Get parent widget match given type.
source code
 
widget_fix_cycle_destroy_bug(widget)
Fix bug that PyGtk destroys cycle too early.
source code
 
map_value(value_list, get_value_callback)
Return value with map list.
source code
 
get_same_level_widgets(widget)
Get same type widgets that in same hierarchy level.
source code
 
mix_list_max(list_a, list_b)
Return new list that element is max value between list_a and list_b.
source code
 
unzip(unzip_list)
Unzip [(1, 'a'), (2, 'b'), (3, 'c')] to ([1, 2, 3], ['a', 'b', 'c']).
source code
 
is_seriate_list(test_list)
Whether is seriate list.
source code
 
get_disperse_index(disperse_list, value)
Get index in disperse list.
source code
 
window_is_max(widget)
Whether window is maximized.
source code
 
last_index(test_list)
Return last index of list.
source code
 
cairo_state(cr)
Protected cairo context state for operate cairo safety.
source code
 
cairo_disable_antialias(cr)
Disable cairo antialias temporary.
source code
 
exec_time()
Print execute time with given code block.
source code
 
remove_timeout_id(callback_id)
Remove callback id.
source code
 
remove_signal_id(signal_id)
Remove signal id.
source code
 
print_callback_args(*args)
Print callback arguments.
source code
 
enable_shadow(widget)
Whether widget is support composited.
source code
 
rgb2hsb(r_value, g_value, b_value)
Convert color from RGB to HSB format.
source code
 
find_similar_color(search_color)
Find simliar color match search_color.
source code
 
end_with_suffixs(filepath, suffixs)
Whether file endswith given suffixs.
source code
 
place_center(refer_window, place_window)
Place place_window in center of refer_window.
source code
 
get_pixbuf_support_foramts()
Get formats that support by pixbuf.
source code
 
get_parent_dir(filepath, level=1)
Get parent directory with given return level.
source code
 
gdkcolor_to_string(gdkcolor)
Gdk color to string.
source code
 
is_long(string)
Is string can convert to long type.
source code
 
is_int(string)
Is string can convert to int type.
source code
 
is_float(string)
Is string can convert to float type.
source code
 
is_hex_color(string)
Is string can convert to hex color type.
source code
 
get_window_shadow_size(window)
Get window shadow size.
source code
 
layout_set_markup(layout, markup)
Set layout markup.
source code
 
get_optimum_pixbuf_from_file(filepath, expect_width, expect_height, cut_middle_area=True)
Get optimum size pixbuf from file.
source code
 
unique_print(text)
Unique print, generic for test code.
source code
 
check_connect_by_port(port, retry_times=6, sleep_time=0.5)
Check connect has active with given port.
source code
 
is_network_connected()
Is network connected, if nothing in file `/proc/net/arp`, network is disconnected.
source code
Function Details

tree_view_get_toplevel_node_count(treeview)

source code 

Get node count number of TreeView.

Parameters:
  • treeview - Gtk.TreeView instance.
Returns:
Return number of node.

Return 0 if treeview haven't model.

tree_view_get_selected_path(treeview)

source code 

Get selected path of TreeView.

Parameters:
  • treeview - Gtk.TreeView instance.
Returns:
Return selected path of treeview.

Return None if haven't any path selected.

tree_view_focus_first_toplevel_node(treeview)

source code 

Focus first toplevel node of TreeView.

Parameters:
  • treeview - Gtk.TreeView instance.

tree_view_focus_last_toplevel_node(treeview)

source code 

Focus last toplevel node of TreeView.

Parameters:
  • treeview - Gtk.TreeView instance.

tree_view_scroll_vertical(treeview, scroll_up=True)

source code 

Scroll TreeView vertically.

Parameters:
  • treeview - Gtk.TreeView instance.
  • scroll_up - Defalut value is True, set as False if you want scroll down.

tree_view_focus_next_toplevel_node(treeview)

source code 

Focus next toplevel node of TreeView.

Parameters:
  • treeview - Gtk.TreeView instance.

tree_view_focus_prev_toplevel_node(treeview)

source code 

Focus previous toplevel node of TreeView.

Parameters:
  • treeview - Gtk.TreeView instance.

get_entry_text(entry)

source code 

Get text of entry.

Parameters:
  • entry - Gtk.Entry instance.
Returns:
Return text of entry.

set_cursor(cursor_widget, cursor_type=None)

source code 

Set cursor type with given widget.

Parameters:
  • cursor_widget - Gtk.Widget or Gdk.Window instance.
  • cursor_type - The cursor type of gtk.gdk.Cursor, please set with None if you want reset widget's cursor as default.
Returns:
Always return False

set_clickable_cursor(widget)

source code 

Show gtk.gdk.HAND2 cursor when mouse hover widget.

Parameters:
  • widget - Gtk.Widget instance.

set_hover_cursor(widget, cursor_type)

source code 

Set cursor type when mouse hover widget.

Parameters:
  • widget - Gtk.Widget instance.
  • cursor_type - The cursor type of gtk.gdk.Cursor.

get_widget_root_coordinate(widget, pos_type=WIDGET_POS_BOTTOM_CENTER)

source code 

Get root coordinate with given widget.

Parameters:
  • widget - Gtk.Widget instance.
  • pos_type - The position of widget's area, you can set with below constants:
    • WIDGET_POS_TOP_LEFT
    • WIDGET_POS_TOP_RIGHT
    • WIDGET_POS_TOP_CENTER
    • WIDGET_POS_BOTTOM_LEFT
    • WIDGET_POS_BOTTOM_RIGHT
    • WIDGET_POS_BOTTOM_CENTER
    • WIDGET_POS_LEFT_CENTER
    • WIDGET_POS_RIGHT_CENTER
    • WIDGET_POS_CENTER
Returns:
Return (x, y) as root coordination.

get_event_root_coords(event)

source code 

Get root coordinate with given event.

Parameters:
  • event - Gdk.Event instance, general, we get event instance from gtk signal callback.
Returns:
Return (x, y) as event's root coordination.

get_event_coords(event)

source code 

Get coordinate with given event.

Parameters:
  • event - Gdk.Event instance, general, we get event instance from gtk signal callback.
Returns:
Return (x, y) as event's coordination.

propagate_expose(widget, event)

source code 

Propagate expose to children.

General, this function use at last position of `expose_event` callback to make child redraw after parent widget.

And you must put "return True" after "propagate_expose(widget, event)".

Example:

>>> def expose_event_callback(widget, event):
>>>     # Do something.
>>>     
>>>     propagate_expose(widget, event)
>>>     return True
Parameters:
  • widget - Gtk.Container instance.

    This function do nothing if widget is not Gtk.Container instance or haven't any child widget.

  • event - Gdk.Event instance.

move_window(widget, event, window)

source code 

Move window with given widget and event.

This function generic use for move window when mouse drag on target widget.

Parameters:
  • widget - Gtk.Widget instance to drag.
  • event - Gdk.Event instance, generic, event come from gtk signal callback.
  • window - Gtk.Window instance.

resize_window(widget, event, window, edge)

source code 

Resize window with given widget and event.

This function generic use for resize window when mouse drag on target widget.

Parameters:
  • widget - Gtk.Widget instance to drag.
  • event - Gdk.Event instance, generic, event come from gtk signal callback.
  • window - Gtk.Window instance.

add_in_scrolled_window(scrolled_window, widget, shadow_type=gtk.SHADOW_NONE)

source code 

Add widget in scrolled_window.

Wrap function `add_with_viewport` with shadow type of Gtk.Viewport.

Parameters:
  • scrolled_window - Gtk.ScrolledWindow instance.
  • widget - Gtk.Widget instance.
  • shadow_type - Shadow type of Viewport, default is gtk.SHADOW_NONE.

is_single_click(event)

source code 

Whether an event is single click event.

Parameters:
  • event - gtk.gdk.BUTTON_PRESS event.
Returns:
Return True if event is single click event.

is_double_click(event)

source code 

Whether an event is double click event.

Parameters:
  • event - gtk.gdk.BUTTON_PRESS event.
Returns:
Return True if event is double click event.

is_left_button(event)

source code 

Whether event is left button event.

Parameters:
  • event - gtk.gdk.BUTTON_PRESS event.
Returns:
Return True if event is left button event.

is_right_button(event)

source code 

Whehter event is right button event.

Parameters:
  • event - gtk.gdk.BUTTON_PRESS event.
Returns:
Return True if event is right button event.

is_middle_button(event)

source code 

Whehter event is middle button event.

Parameters:
  • event - gtk.gdk.BUTTON_PRESS event.
Returns:
Return True if event is middle button event.

foreach_container(widget, callback)

source code 

Make callback call for all children of widget.

Parameters:
  • widget - Gtk.Container instance.
  • callback - Callback.

foreach_recursive(container, callback)

source code 

Helper function for foreach_container.

Parameters:
  • container - Gtk.Container instance.
  • callback - Callback.

container_remove_all(container)

source code 

Handy function to remove all children widget from container.

Parameters:
  • container - Gtk.Container instance.

get_screen_size(widget)

source code 

Get screen size from the toplevel window associated with widget.

Parameters:
  • widget - Gtk.Widget instance.
Returns:
Return screen size as (screen_width, screen_height)

is_in_rect((tx, ty), (x, y, w, h))

source code 

Whether target coordinate in given rectangle.

Parameters:
  • tx - Target x coordinate.
  • ty - Target y coordinate.
  • x - X coordinate of rectangle area.
  • y - X coordinate of rectangle area.
  • w - Width of rectangle area.
  • h - Height of rectangle area.
Returns:
Return True if target coordinate in given rectangle.

scroll_to_top(scrolled_window)

source code 

Scroll scrolled_window to top position.

Parameters:
  • scrolled_window - Gtk.ScrolledWindow instance.

scroll_to_bottom(scrolled_window)

source code 

Scroll scrolled_window to bottom position.

Parameters:
  • scrolled_window - Gtk.ScrolledWindow instance.

get_content_size(text, text_size=DEFAULT_FONT_SIZE, text_font=DEFAULT_FONT, wrap_width=None)

source code 

Get text size, in pixel.

Parameters:
  • text - String or markup string.
  • text_size - Text size, in pixel.
  • text_font - Text font.
  • wrap_width - The width of wrap rule, default don't wrap.
Returns:
Return text size as (text_width, text_height), return (0, 0) if occur error.

create_directory(directory, remove_first=False)

source code 

Create directory.

Parameters:
  • directory - Target directory to create.
  • remove_first - If you want remove directory when directory has exist, set it as True.

remove_file(path)

source code 

Remove file if file exist.

Parameters:
  • path - Target path to remove.

remove_directory(path)

source code 

Remove directory recursively, equivalent to command `rm -rf path`.

Parameters:
  • path - Target directory to remove.

touch_file(filepath)

source code 

Touch file, equivalent to command `touch filepath`.

If filepath's parent directory is not exist, this function will create parent directory first.

Parameters:
  • filepath - Target path to touch.

read_file(filepath, check_exists=False)

source code 

Read file content.

Parameters:
  • filepath - Target filepath.
  • check_exists - Whether check file is exist, default is False.
Returns:
Return "" if check_exists is True and filepath not exist.

Otherwise return file's content.

read_first_line(filepath, check_exists=False)

source code 

Read first line of file.

Parameters:
  • filepath - Target filepath.
  • check_exists - Whether check file is exist, default is False.
Returns:
Return "" if check_exists is True and filepath not exist.

Otherwise return file's first line.

eval_file(filepath, check_exists=False)

source code 

Eval file content.

Parameters:
  • filepath - Target filepath.
  • check_exists - Whether check file is exist, default is False.
Returns:
Return None if check_exists is True and file not exist.

Return None if occur error when eval file.

Otherwise return file content as python structure.

write_file(filepath, content)

source code 

Write file with given content.

Parameters:
  • filepath - Target filepath to write.
  • content - File content to write.

kill_process(proc)

source code 

Kill process.

Parameters:
  • proc - Subprocess instance.

get_command_output_first_line(commands)

source code 

Run command and return first line of output.

Parameters:
  • commands - Input commands.
Returns:
Return first line of command output.

get_command_output(commands)

source code 

Run command and return output.

Parameters:
  • commands - Input commands.
Returns:
Return command output.

run_command(command)

source code 

Run command silencely.

Parameters:
  • command - Input command.

get_os_version()

source code 

Get OS version with command `lsb_release -i`.

Returns:
Return OS version string.

get_current_time(time_format="%Y-%m-%d %H:%M:%S")

source code 

Get current time with given time format.

Parameters:
  • time_format - Time format, default is %Y-%m-%d %H:%M:%S
Returns:
Return current time with given time format.

add_in_list(e_list, element)

source code 

Add element in list, don't add if element has in list.

Parameters:
  • e_list - List to insert.
  • element - Element will insert to list.

remove_from_list(e_list, element)

source code 

Try remove element from list, do nothing if element not in list.

Parameters:
  • e_list - List to remove.
  • element - Element try to remove from list.

sort_alpha(e_list)

source code 

Sort list with alpha order.

Parameters:
  • e_list - List to sort.

get_dir_size(dirname)

source code 

Get size of given directory.

Parameters:
  • dirname - Directory path.
Returns:
Return total size of directory.

print_exec_time(func)

source code 

Print execute time of function.

Parameters:
  • func - Fucntion name.

    Usage:

    >>> @print_exec_time
    >>> def function_to_test():
    >>>     ...

get_font_families()

source code 

Get all font families in system.

Returns:
Return font families list in current system.

format_file_size(bytes, precision=2)

source code 

Returns a humanized string for a given amount of bytes.

Parameters:
  • bytes - Bytes number to format.
  • precision - Number precision.
Returns:
Return a humanized string for a given amount of bytes.

add_color_stop_rgba(pat, pos, color_info)

source code 

Add color stop as rgba format.

Parameters:
  • pat - Pattern.
  • pos - Stop position.
  • color_info - (color, alpha), color is hex value, alpha value range: [0, 1]

alpha_color_hex_to_cairo((color, alpha))

source code 

Convert alpha color (color, alpha) to cairo color (r, g, b, alpha).

Parameters:
  • color - Hex color.
  • alpha - Alpha value.
Returns:
Return cairo value (red, green, blue, alpha).

color_hex_to_rgb(color)

source code 

Convert hex color to cairo color (r, g, b).

Parameters:
  • color - Hex color value.
Returns:
Return cairo value, (red, green, blue)

color_hex_to_cairo(color)

source code 

Convert a html (hex) RGB value to cairo color.

Parameters:
  • color - The color to convert.
Returns:
A color in cairo format, (red, green, blue).

color_rgb_to_hex(rgb_color)

source code 

Convert cairo color to hex color.

Parameters:
  • rgb_color - (red, green, blue)
Returns:
Return hex color.

color_rgb_to_cairo(color)

source code 

Convert a 8 bit RGB value to cairo color.

Parameters:
  • color (a triple of integers between 0 and 255) - The color to convert.
Returns:
A color in cairo format.

get_match_parent(widget, match_types)

source code 

Get parent widget match given type.

Parameters:
  • widget - Gtk.Widget instance.
  • match_types - A list gtk widget types.
Returns:
Return first parent widget match with given types.

Return None if nothing match.

widget_fix_cycle_destroy_bug(widget)

source code 

Fix bug that PyGtk destroys cycle too early.

Parameters:
  • widget - Gtk.Widget instance.

map_value(value_list, get_value_callback)

source code 

Return value with map list.

Parameters:
  • value_list - A list to loop.
  • get_value_callback - Callback for element in list.
Returns:
Return a new list that every element is result of get_value_callback.

get_same_level_widgets(widget)

source code 

Get same type widgets that in same hierarchy level.

Parameters:
  • widget - Gtk.Widget instance to search.
Returns:
Return a list that type match given widget at same hierarchy level.

mix_list_max(list_a, list_b)

source code 

Return new list that element is max value between list_a and list_b.

Parameters:
  • list_a - List a.
  • list_b - List b.
Returns:
Return new list that element is max value between two list.

Return empty list if any input list is empty or two list's length is not same.

unzip(unzip_list)

source code 

Unzip [(1, 'a'), (2, 'b'), (3, 'c')] to ([1, 2, 3], ['a', 'b', 'c']).

Parameters:
  • unzip_list - List to unzip.
Returns:
Return new unzip list.

is_seriate_list(test_list)

source code 

Whether is seriate list.

Parameters:
  • test_list - Test list.
Returns:
Return True is test list is seriate list.

get_disperse_index(disperse_list, value)

source code 

Get index in disperse list.

Parameters:
  • disperse_list - Disperse list.
  • value - Match value.
Returns:
Return index in disperse list.

window_is_max(widget)

source code 

Whether window is maximized.

Parameters:
  • widget - Gtk.Widget instance.
Returns:
Return True if widget's toplevel window is maximized.

last_index(test_list)

source code 

Return last index of list.

Parameters:
  • test_list - Test list.
Returns:
Return last index of list.

cairo_state(cr)

source code 

Protected cairo context state for operate cairo safety.

Parameters:
  • cr - Cairo context.
Decorators:
  • @contextmanager

cairo_disable_antialias(cr)

source code 

Disable cairo antialias temporary.

Parameters:
  • cr - Cairo context.
Decorators:
  • @contextmanager

exec_time()

source code 

Print execute time with given code block.

Usage:

>>> with exec_time():
>>>     # Write any code at here.
>>>     # ...
Decorators:
  • @contextmanager

remove_timeout_id(callback_id)

source code 

Remove callback id.

Parameters:
  • callback_id - Callback id.

remove_signal_id(signal_id)

source code 

Remove signal id.

Parameters:
  • signal_id - Signal id that return by function gobject.connect.

print_callback_args(*args)

source code 

Print callback arguments.

Usage:

>>> some_widget.connect("signal", print_callback_args)

enable_shadow(widget)

source code 

Whether widget is support composited.

Parameters:
  • widget - Gtk.Widget instance.
Returns:
Return True if widget is support composited.

rgb2hsb(r_value, g_value, b_value)

source code 

Convert color from RGB to HSB format.

Parameters:
  • r_value - Red.
  • g_value - Green.
  • b_value - Blue.
Returns:
Return color with HSB (h, s, b) format.

find_similar_color(search_color)

source code 

Find simliar color match search_color.

Parameters:
  • search_color - Color to search.
Returns:
Return similar color name and value, (color_name, color_value).

end_with_suffixs(filepath, suffixs)

source code 

Whether file endswith given suffixs.

Parameters:
  • filepath - Filepath to test.
  • suffixs - A list suffix to match.
Returns:
Return True if filepath endswith with given suffixs.

place_center(refer_window, place_window)

source code 

Place place_window in center of refer_window.

Parameters:
  • refer_window - Reference window.
  • place_window - Place window.

get_pixbuf_support_foramts()

source code 

Get formats that support by pixbuf.

Returns:
Return formats that support by pixbuf.

get_parent_dir(filepath, level=1)

source code 

Get parent directory with given return level.

Parameters:
  • filepath - Filepath.
  • level - Return level, default is 1
Returns:
Return parent directory with given return level.

gdkcolor_to_string(gdkcolor)

source code 

Gdk color to string.

Parameters:
  • gdkcolor - Gdk.Color
Returns:
Return string of gdk color.

is_long(string)

source code 

Is string can convert to long type.

Parameters:
  • string - Test string.
Returns:
Return True if string can convert to long type.

is_int(string)

source code 

Is string can convert to int type.

Parameters:
  • string - Test string.
Returns:
Return True if string can convert to int type.

is_float(string)

source code 

Is string can convert to float type.

Parameters:
  • string - Test string.
Returns:
Return True if string can convert to float type.

is_hex_color(string)

source code 

Is string can convert to hex color type.

Parameters:
  • string - Test string.
Returns:
Return True if string can convert to hex color type.

get_window_shadow_size(window)

source code 

Get window shadow size.

Parameters:
  • window - Test window.
Returns:
Return shadow size as (width, height), or return (0, 0) if window haven't shadow.

layout_set_markup(layout, markup)

source code 

Set layout markup.

Parameters:
  • layout - Pango layout.
  • markup - Markup string.

get_optimum_pixbuf_from_file(filepath, expect_width, expect_height, cut_middle_area=True)

source code 

Get optimum size pixbuf from file.

Parameters:
  • filepath - Filepath to contain image.
  • expect_width - Expect width.
  • expect_height - Expect height.
  • cut_middle_area - Default cut image with middle area.
Returns:
Return optimum size pixbuf with expect size.

unique_print(text)

source code 

Unique print, generic for test code.

Parameters:
  • text - Test text.

check_connect_by_port(port, retry_times=6, sleep_time=0.5)

source code 

Check connect has active with given port.

Parameters:
  • port - Test port.
  • retry_times - Retry times.
  • sleep_time - Sleep time between retry, in seconds.
Returns:
Return True if given port is active.

is_network_connected()

source code 

Is network connected, if nothing in file `/proc/net/arp`, network is disconnected.

Returns:
Return True if network is connected.