本文整理汇总了Python中dtk.ui.scrolled_window.ScrolledWindow.add_with_viewport方法的典型用法代码示例。如果您正苦于以下问题:Python ScrolledWindow.add_with_viewport方法的具体用法?Python ScrolledWindow.add_with_viewport怎么用?Python ScrolledWindow.add_with_viewport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dtk.ui.scrolled_window.ScrolledWindow
的用法示例。
在下文中一共展示了ScrolledWindow.add_with_viewport方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init_ui
# 需要导入模块: from dtk.ui.scrolled_window import ScrolledWindow [as 别名]
# 或者: from dtk.ui.scrolled_window.ScrolledWindow import add_with_viewport [as 别名]
def __init_ui(self):
self.vbox = gtk.VBox(False, BETWEEN_SPACING)
self.__init_sections( -1)
self.vbox.set_size_request(WINDOW_WIDTH - 2 * TEXT_WINDOW_LEFT_PADDING, -1)
scroll_win = ScrolledWindow(right_space=0, top_bottom_space=0)
#scroll_win.connect("event", self.test)
scroll_win.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
# FIXME UI a align to adjust ui
ui_align = gtk.Alignment(0, 0, 0, 0)
ui_align.set_padding(TEXT_WINDOW_TOP_PADDING,
TEXT_WINDOW_TOP_PADDING,
TEXT_WINDOW_LEFT_PADDING,
TEXT_WINDOW_LEFT_PADDING)
ui_align.add(self.vbox)
scroll_win.add_with_viewport(ui_align)
self.eventbox = gtk.EventBox()
self.eventbox.set_above_child(False)
self.eventbox.add(scroll_win)
self.vbox.connect("expose-event", self.expose_callback)
ui_align.connect("expose-event", self.expose_callback)
示例2: SettingUI
# 需要导入模块: from dtk.ui.scrolled_window import ScrolledWindow [as 别名]
# 或者: from dtk.ui.scrolled_window.ScrolledWindow import add_with_viewport [as 别名]
class SettingUI(gtk.Alignment):
def __init__(self, slide_back_cb, change_crumb_cb):
gtk.Alignment.__init__(self, 0, 0, 0, 0)
self.slide_back = slide_back_cb
self.change_crumb = change_crumb_cb
self.scroll_win = ScrolledWindow()
self.scroll_win.set_can_focus(False)
self.scroll_win.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
main_vbox = gtk.VBox()
self.foot_box = FootBox()
self.hbox = gtk.HBox()
self.scroll_win.add_with_viewport(self.hbox)
self.scroll_align = gtk.Alignment()
self.scroll_win.set_size_request(800, 435)
self.scroll_align.set(0, 0, 0, 0)
self.scroll_align.set_padding(0, 0, 30, 0)
self.scroll_align.add(self.scroll_win)
padding_align = gtk.Alignment(0, 0, 0, 0)
padding_align.set_padding(15, 0, 0, 0)
self.sidebar = SideBar( None)
padding_align.add(self.sidebar)
self.hpaned = MyPaned()
self.hpaned.set_size_request(800, -1)
self.hpaned.connect("expose-event",self.expose_line)
#self.hpaned.do_enter_notify_event = self.enter_notify_event
self.hpaned.add1(padding_align)
self.hpaned.add2(self.scroll_align)
self.connect_after("show", self.__init_paned)
main_vbox.pack_start(self.hpaned, True, True)
main_vbox.pack_start(self.foot_box, False, False)
self.add(main_vbox)
self.__init_signals()
def enter_notify_event(self, e):
pass
def __init_paned(self, widget):
log.debug("")
self.hpaned.saved_position = 160
self.hpaned.set_position(1)
self.hpaned.animation_position_frames = [0]
self.hpaned.update_position()
def __init_signals(self):
Dispatcher.connect("connection-change", self.switch_content)
Dispatcher.connect("setting-saved", self.save_connection_setting)
Dispatcher.connect("setting-appled", self.apply_connection_setting)
Dispatcher.connect("request_redraw", lambda w: self.scroll_win.show_all())
def load_module(self, module_obj, hide_left):
# create a reference
self.setting_group = module_obj
# init paned
self.__init_paned(None)
log.info("dss start load module", module_obj)
self.hpaned.set_button_show(hide_left)
# init foot_box
self.foot_box.set_setting(module_obj)
# init sidebar
self.sidebar.load_list(module_obj)
self.apply_method = module_obj.apply_changes
self.save_method = module_obj.save_changes
def switch_content(self, widget, connection):
container_remove_all(self.hbox)
self.set_tab_content(connection)
self.set_foot_bar_button(connection)
self.focus_connection = connection
def set_foot_bar_button(self, connection):
if type(connection) == NMRemoteConnection:
self.foot_box.show_delete(connection)
else:
self.foot_box.hide_delete()
states = self.setting_group.get_button_state(connection)
if states:
Dispatcher.set_button(*states)
def set_tab_content(self, connection):
log.debug("set tab content", connection)
setting = self.setting_group.init_items(connection)
self.hbox.add(setting)
self.hbox.show_all()
self.foot_box.set_lock(False)
def expose_line(self, widget, event):
cr = widget.window.cairo_create()
rect = widget.allocation
style.draw_out_line(cr, rect, exclude=["left", "right", "top"])
#.........这里部分代码省略.........
示例3: PlayListView
# 需要导入模块: from dtk.ui.scrolled_window import ScrolledWindow [as 别名]
# 或者: from dtk.ui.scrolled_window.ScrolledWindow import add_with_viewport [as 别名]
class PlayListView(object):
def __init__(self):
self.one_close = app_theme.get_pixbuf("treeview/1-close.png")
self.one_open = app_theme.get_pixbuf("treeview/1-open.png")
self.two_close = app_theme.get_pixbuf("treeview/2-close.png")
self.two_open = app_theme.get_pixbuf("treeview/2-open.png")
self.three_close = app_theme.get_pixbuf("treeview/3-close.png")
self.three_open = app_theme.get_pixbuf("treeview/3-open.png")
#
self.tree_view_open = app_theme.get_pixbuf("treeview/open.png")
self.tree_view_close = app_theme.get_pixbuf("treeview/close.png")
self.tree_view_right = app_theme.get_pixbuf("treeview/right.png")
self.tree_view_bottom = app_theme.get_pixbuf("treeview/bottom.png")
#
self.listview_color = ui_theme.get_color("scrolledbar")
self.play_list_vbox = gtk.VBox()
#
self.list_view_vbox = gtk.VBox()
self.list_scroll_win = ScrolledWindow(0, 0)
self.list_scroll_win.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
self.list_view = ListView()
#
self.play_list_con = PlayListControl()
#
self.list_view_vbox.pack_start(self.list_scroll_win, True, True)
self.list_view_vbox.pack_start(self.play_list_con, False, False)
# 网络列表,搜索框.
self.tree_scroll_win = ScrolledWindow(0, 0)
self.tree_scroll_win.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
self.tree_view_vbox = gtk.VBox()
self.tree_view = TreeViewBase()
self.search_ali = gtk.Alignment(0, 0, 1, 1)
self.search = Search()
self.search_ali.add(self.search)
#
self.search_ali.set_padding(7, 5, 12, 12)
self.tree_view_vbox.pack_start(self.search_ali, False, False)
self.tree_view_vbox.pack_start(self.tree_scroll_win, True, True)
self.search_ali.connect("expose-event", self.search_ali_expose_event)
#
self.note_book = NoteBook()
#
self.list_view.on_draw_sub_item = self.__listview_on_draw_sub_item
self.list_view.columns.add_range(["filename", "time"])
self.list_view.columns[0].width = 120
self.list_view.columns[1].width = 95
#
self.note_book.hide_title()
self.tree_view.paint_nodes_event = self.__treeview_paint_nodes_event
#
self.list_scroll_win.add_with_viewport(self.list_view)
self.tree_scroll_win.add_with_viewport(self.tree_view)
#self.note_book.add_layout1(self.list_scroll_win)
self.note_book.add_layout1(self.list_view_vbox)
self.note_book.add_layout2(self.tree_view_vbox)
#self.play_list_vbox.pack_start(self.scroll_win, True, True)
self.play_list_vbox.pack_start(self.note_book, True, True)
def __listview_on_draw_sub_item(self, e):
color = self.listview_color.get_color()
if e.double_items == e.item:
e.text_color = "#000000"
text_size=9
color_info = [(0, (color, 0.8)), (1, (color, 0.8))]
draw_vlinear(e.cr,
e.x, e.y, e.w, e.h,
color_info
)
elif e.item in e.single_items:
e.text_color = "#FFFFFF"
text_size=9
color_info = [(0, (color, 0.5)), (1, (color, 0.5))]
draw_vlinear(e.cr,
e.x, e.y, e.w, e.h,
color_info
)
elif e.motion_items == e.item:
e.text_color = "#FFFFFF"
text_size=9
color_info = [(0, (color, 0.2)), (1, (color, 0.2))]
draw_vlinear(e.cr,
e.x, e.y, e.w, e.h,
color_info
)
else:
e.text_color = "#FFFFFF"
text_size=9
#
text = e.text.decode("utf-8")
one_width = self.list_view.columns[0].width
two_width = self.list_view.columns[1].width
#if e.w == one_width: # 显示播放名字的第一列.
if e.column_index == 0:
#
t_width = 0
t_index = 0
add_point = False
for t in text:
t_width += get_text_size(t, text_size=text_size)[0]
if t_width > one_width - 20:
#.........这里部分代码省略.........
示例4: PlayListView
# 需要导入模块: from dtk.ui.scrolled_window import ScrolledWindow [as 别名]
# 或者: from dtk.ui.scrolled_window.ScrolledWindow import add_with_viewport [as 别名]
class PlayListView(object):
def __init__(self):
self.tree_view_open = app_theme.get_pixbuf("treeview/open.png")
self.tree_view_close = app_theme.get_pixbuf("treeview/close.png")
self.tree_view_right = app_theme.get_pixbuf("treeview/right.png")
self.tree_view_bottom = app_theme.get_pixbuf("treeview/bottom.png")
#
self.listview_color = ui_theme.get_color("scrolledbar")
self.play_list_vbox = gtk.VBox()
#
self.list_scroll_win = ScrolledWindow(0, 0)
self.list_scroll_win.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
self.list_view = ListView()
#
self.tree_scroll_win = ScrolledWindow(0, 0)
self.tree_scroll_win.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
self.tree_view = TreeViewBase()
self.note_book = NoteBook()
#
self.list_view.on_draw_sub_item = self.__listview_on_draw_sub_item
self.list_view.columns.add_range(["filename", "time"])
self.list_view.columns[0].width = 120
self.list_view.columns[1].width = 95
#
self.note_book.hide_title()
self.tree_view.paint_nodes_event = self.__treeview_paint_nodes_event
#
self.list_scroll_win.add_with_viewport(self.list_view)
self.tree_scroll_win.add_with_viewport(self.tree_view)
self.note_book.add_layout1(self.list_scroll_win)
self.note_book.add_layout2(self.tree_scroll_win)
#self.play_list_vbox.pack_start(self.scroll_win, True, True)
self.play_list_vbox.pack_start(self.note_book, True, True)
def __listview_on_draw_sub_item(self, e):
color = self.listview_color.get_color()
if e.double_items == e.item:
e.text_color = "#000000"
text_size=9
color_info = [(0, (color, 0.8)), (1, (color, 0.8))]
draw_vlinear(e.cr,
e.x, e.y, e.w, e.h,
color_info
)
elif e.item in e.single_items:
e.text_color = "#FFFFFF"
text_size=9
color_info = [(0, (color, 0.5)), (1, (color, 0.5))]
draw_vlinear(e.cr,
e.x, e.y, e.w, e.h,
color_info
)
elif e.motion_items == e.item:
e.text_color = "#FFFFFF"
text_size=9
color_info = [(0, (color, 0.2)), (1, (color, 0.2))]
draw_vlinear(e.cr,
e.x, e.y, e.w, e.h,
color_info
)
else:
e.text_color = "#FFFFFF"
text_size=9
text = e.text.decode("utf-8")
one_width = self.list_view.columns[0].width
two_width = self.list_view.columns[1].width
if e.w == one_width: # 显示播放名字的第一列.
#
t_width = 0
t_index = 0
add_point = False
for t in text:
t_width += get_text_size(t, text_size=text_size)[0]
if t_width > one_width:
add_point = True
break
t_index += 1
if add_point:
text = text[:t_index] + "..."
#
alignment = Text.LEFT
x = e.x + 15
elif e.w == two_width:
alignment = Text.RIGHT
x = e.x - 15
e.draw_text(e.cr,
str(text),
x, e.y, e.w, e.h,
text_color=e.text_color,
text_size=text_size,
alignment=alignment)
def __treeview_paint_nodes_event(self, node_event):
leave_width = 20
color = self.listview_color.get_color()
text_color = "#FFFFFF"
#
#.........这里部分代码省略.........