Package dtk :: Package ui :: Module menu :: Class Menu

Class Menu

source code


Menu.

Instance Methods
 
__init__(self, items, is_root_menu=False, select_scale=False, x_align=ALIGN_START, y_align=ALIGN_START, font_size=DEFAULT_FONT_SIZE, padding_x=3, padding_y=3, item_padding_x=6, item_padding_y=3, shadow_visible=True, menu_min_width=130)
Initialize Menu class.
source code
 
draw_menu_mask(self, cr, x, y, w, h)
Draw mask interface.
source code
 
show(self, (x, y), (offset_x, offset_y)=(0,0))
Show menu with given position.
source code
 
hide(self)
Hide menu.
source code

Inherited from window.Window: add_move_event, add_toggle_event, close_window, draw_mask, get_edge, get_shadow_size, hide_shadow, is_disable_window_maximized, min_window, resize_window, show_shadow, show_window, toggle_fullscreen_window, toggle_max_window

Method Details

__init__(self, items, is_root_menu=False, select_scale=False, x_align=ALIGN_START, y_align=ALIGN_START, font_size=DEFAULT_FONT_SIZE, padding_x=3, padding_y=3, item_padding_x=6, item_padding_y=3, shadow_visible=True, menu_min_width=130)
(Constructor)

source code 

Initialize Menu class.

Parameters:
  • items - A list of item, item format: (item_icon, itemName, item_node).
  • is_root_menu - Default is False for submenu, you should set it as True if you build root menu.
  • select_scale - Default is False, it will use parant's width if it set True.
  • x_align - Horizontal alignment value.
  • y_align - Vertical alignment value.
  • font_size - Menu font size, default is DEFAULT_FONT_SIZE
  • padding_x - Horizontal padding value, default is 3 pixel.
  • padding_y - Vertical padding value, default is 3 pixel.
  • item_padding_x - Horizontal item padding value, default is 6 pixel.
  • item_padding_y - Vertical item padding value, default is 3 pixel.
  • shadow_visible - Whether show window shadow, default is True.
  • menu_min_width - Minimum width of menu.
Overrides: window.Window.__init__

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

source code 

Draw mask interface.

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

show(self, (x, y), (offset_x, offset_y)=(0,0))

source code 

Show menu with given position.

Parameters:
  • x - X coordinate of menu.
  • y - Y coordinate of menu.
  • offset_x - Offset x when haven't enough space to show menu, default is 0.
  • offset_y - Offset y when haven't enough space to show menu, default is 0.