本文整理汇总了Python中dtk.ui.treeview.TreeView.select_first_item方法的典型用法代码示例。如果您正苦于以下问题:Python TreeView.select_first_item方法的具体用法?Python TreeView.select_first_item怎么用?Python TreeView.select_first_item使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dtk.ui.treeview.TreeView
的用法示例。
在下文中一共展示了TreeView.select_first_item方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CompletionWindow
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import select_first_item [as 别名]
class CompletionWindow(Window):
'''
class docs
'''
def __init__(self, window_width, window_height):
'''
init docs
'''
# Init.
Window.__init__(
self,
shadow_visible=False,
shadow_radius = 0,
shape_frame_function=self.shape_completion_window_frame,
expose_frame_function=self.expose_completion_window_frame,
# window_type=gtk.WINDOW_POPUP,
)
self.window_width = window_width
self.window_height = window_height
self.window_offset_x = 0
self.window_offset_y = 0
self.align_size = 2
self.treeview = TreeView(
enable_highlight=False,
enable_multiple_select=False,
enable_drag_drop=False,)
self.treeview.draw_mask = self.treeview_draw_mask
self.treeview.scrolled_window.tag_by_popup_grab_window = True
self.treeview_align = gtk.Alignment()
self.treeview_align.set(0.5, 0.5, 1, 1)
self.treeview_align.set_padding(self.align_size, self.align_size, self.align_size, self.align_size)
self.treeview_align.add(self.treeview)
self.window_frame.pack_start(self.treeview_align, True, True)
self.connect("realize", self.realize_completion_window)
self.get_scrolledwindow = self.get_scrolledwindow
wrap_grab_window(completion_grab_window, self)
def get_scrolledwindow(self):
return self.treeview.scrolled_window
def shape_completion_window_frame(self, widget, event):
pass
def treeview_draw_mask(self, cr, x, y, w, h):
cr.set_source_rgba(1, 1, 1, 0.95)
cr.rectangle(x, y, w, h)
cr.fill()
def expose_completion_window_frame(self, widget, event):
cr = widget.window.cairo_create()
rect = widget.allocation
cr = widget.window.cairo_create()
rect = widget.allocation
cr.set_source_rgb(1,1,1)
cr.rectangle(rect.x, rect.y, rect.width, rect.height)
cr.fill()
cr.set_line_width(1)
cr.set_source_rgb(*color_hex_to_cairo("#c7c7c7"))
cr.rectangle(*rect)
cr.stroke()
def show(self, keyword):
self.treeview.delete_all_items()
self.treeview.add_items([TextItem(key) for key in ["linux", "deepin", "word", keyword]])
self.treeview.select_first_item()
# self.treeview.grab_focus()
(x, y) = get_widget_root_coordinate(search_entry, WIDGET_POS_BOTTOM_LEFT, True)
self.move(x + self.window_offset_x, y + self.window_offset_y)
self.show_all()
def realize_completion_window(self, widget):
self.set_default_size(self.window_width, self.window_height)
self.set_geometry_hints(
None,
self.window_width, # minimum width
self.window_height, # minimum height
self.window_width,
self.window_height,
-1, -1, -1, -1, -1, -1
)