本文整理汇总了Python中dtk.ui.treeview.TreeView.set_expand_column方法的典型用法代码示例。如果您正苦于以下问题:Python TreeView.set_expand_column方法的具体用法?Python TreeView.set_expand_column怎么用?Python TreeView.set_expand_column使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dtk.ui.treeview.TreeView
的用法示例。
在下文中一共展示了TreeView.set_expand_column方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init_widget
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_expand_column [as 别名]
def __init_widget(self):
self.buttonbox = gtk.VBox()
self.pack_start(self.buttonbox, False, False)
style.add_separator(self)
#self.connection_tree = EntryTreeView()
self.add_button = AddSettingItem(_("New Connection") ,self.add_new_connection)
add_setting_tree = TreeView([self.add_button])
add_setting_tree.set_expand_column(1)
self.pack_start(add_setting_tree, False, False)
self.set_size_request(160, -1)
self.show_all()
self.__init_signals()
示例2: UninstallPage
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_expand_column [as 别名]
class UninstallPage(gtk.VBox):
'''
class docs
'''
def __init__(self, bus_interface, data_manager):
'''
init docs
'''
# Init.
gtk.VBox.__init__(self)
self.bus_interface = bus_interface
self.data_manager = data_manager
self.search_flag = False
self.uninstall_change_items = {"add": [], "delete": []}
self.message_bar = MessageBar(32)
self.message_bar.search_entry.entry.connect("changed", self.search_cb)
self.message_bar.search_button.connect("clicked", self.search_cb)
self.treeview = TreeView(enable_drag_drop=False)
self.treeview.set_expand_column(0)
top_hbox = gtk.HBox()
top_hbox.pack_start(self.message_bar)
self.pack_start(top_hbox, False, False)
self.pack_start(self.treeview, True, True)
self.treeview.connect("items-change", self.update_message_bar)
self.fetch_uninstall_info()
self.treeview.draw_mask = self.draw_mask
def search_cb(self, widget, event=None):
if not self.search_flag:
self.cache_items = [item for item in self.treeview.visible_items]
results = []
keywords = self.message_bar.search_entry.get_text().strip()
if keywords != "":
self.search_flag = True
# TODO: comment this search_query api, there are many problems for this api
'''
pkg_names = self.data_manager.search_query(map(lambda word: word.encode("utf8"), keywords.split(" ")))
for item in self.cache_items:
if item.pkg_name in pkg_names:
results.append(item)
'''
for item in self.cache_items:
if keywords in item.pkg_name:
results.append(item)
self.treeview.clear()
self.treeview.add_items(results)
else:
self.treeview.clear()
self.search_flag = False
# for add items
if self.uninstall_change_items["add"] != []:
for item in self.uninstall_change_items["add"]:
self.cache_items.append(item)
self.uninstall_change_items["add"] = []
# for delete items
if self.uninstall_change_items["delete"] != []:
for item in self.uninstall_change_items["delete"]:
if item in self.cache_items:
self.cache_items.remove(item)
self.uninstall_change_items["delete"] = []
self.treeview.add_items(self.cache_items)
def normal_search_cb(self, keywords):
pass
def update_message_bar(self, treeview):
self.message_bar.set_message(_("%s applications can be uninstalled") % len(treeview.visible_items))
def draw_mask(self, cr, x, y, w, h):
'''
Draw mask interface.
@param cr: Cairo context.
@param x: X coordiante of draw area.
@param y: Y coordiante of draw area.
@param w: Width of draw area.
@param h: Height of draw area.
'''
draw_vlinear(cr, x, y, w, h,
[(0, ("#FFFFFF", 0.9)),
(1, ("#FFFFFF", 0.9)),]
)
def update_action_status(self, pkg_infos):
pkg_items = []
for (pkg_name, action_status) in pkg_infos:
pkg_item = None
for item in self.treeview.visible_items:
#.........这里部分代码省略.........
示例3: InstallPage
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_expand_column [as 别名]
class InstallPage(gtk.VBox):
'''
class docs
'''
def __init__(self, bus_interface, data_manager):
'''
init docs
'''
# Init.
gtk.VBox.__init__(self)
self.bus_interface = bus_interface
self.data_manager = data_manager
self.message_bar = MessageBar(32)
self.message_box = gtk.HBox()
self.treeview = TreeView(enable_drag_drop=False)
self.treeview.set_expand_column(0)
self.cute_message_image = gtk.VBox()
self.content_box = gtk.VBox()
self.pack_start(self.message_box, False, False)
self.pack_start(self.content_box, True, True)
self.cute_message_pixbuf = utils.get_common_locale_image_pixbuf("info", "no_download.png")
self.content_box.pack_start(self.cute_message_image, True, True)
self.treeview.draw_mask = self.draw_mask
self.cute_message_image.connect("expose-event", self.expose_cute_message_image)
self.treeview.connect("items-change", self.update_message_bar)
self.treeview.connect("items-change", lambda treeview: global_event.emit("update-install-notify-number", self.get_installing_pkgs_number()))
#self.get_action_item("deepin-webapps-baidu-map")
#self.download_failed("deepin-webapps-baidu-map")
def expose_cute_message_image(self, widget, event):
if self.cute_message_pixbuf:
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()
draw_pixbuf(
cr,
self.cute_message_pixbuf,
rect.x + (rect.width - self.cute_message_pixbuf.get_width()) / 2,
rect.y + (rect.height - self.cute_message_pixbuf.get_height()) / 2,
)
def update_install_status(self):
global_event.emit("update-install-notify-number", self.get_installing_pkgs_number())
self.update_message_bar(self.treeview)
def get_installing_pkgs_number(self):
items = []
for item in self.treeview.visible_items:
if not (item.status == item.STATUS_INSTALL_FINISH or \
item.status == item.STATUS_DOWNLOAD_FAILED):
items.append(item)
return len(items)
def get_installed_pkgs_number(self):
items = []
for item in self.treeview.visible_items:
if item.status == item.STATUS_INSTALL_FINISH:
items.append(item)
return len(items)
def delete_item_match_pkgname(self, pkg_name):
for install_item in self.treeview.visible_items:
if install_item.pkg_name == pkg_name:
self.treeview.delete_items([install_item])
break
def update_message_bar(self, treeview):
if self.get_installing_pkgs_number() == 0:
if self.get_installed_pkgs_number() == 0:
container_remove_all(self.message_box)
children = self.content_box.get_children()
if len(children) == 0 or children[0] == self.treeview:
if self.cute_message_pixbuf == None:
self.cute_message_pixbuf = utils.get_common_locale_image_pixbuf("info", "no_download.png")
container_remove_all(self.content_box)
self.content_box.pack_start(self.cute_message_image, True, True)
self.show_all()
else:
self.message_bar.set_message("")
else:
container_remove_all(self.message_box)
self.message_box.pack_start(self.message_bar, True, True)
self.message_bar.set_message(_("%s applications are being installed") % self.get_installing_pkgs_number())
children = self.content_box.get_children()
#.........这里部分代码省略.........
示例4: PreferenceDialog
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_expand_column [as 别名]
class PreferenceDialog(DialogBox):
def __init__(self):
super(PreferenceDialog, self).__init__(_("Preferences"), 575, 495,
mask_type=DIALOG_MASK_MULTIPLE_PAGE,
close_callback=self.hide_all)
self.set_position(gtk.WIN_POS_CENTER)
self.main_box = gtk.VBox()
close_button = Button(_("Close"))
close_button.connect("clicked", lambda w: self.hide_all())
# Init widget.
self.general_setting = GeneralSetting()
self.hotkey_setting = HotKeySetting()
self.desktop_lyrics_setting = DesktopLyricsSetting()
self.scroll_lyrics_setting = ScrollLyricsSetting()
self.plugins_manager = PluginsManager()
# Category bar
self.category_bar = TreeView(enable_drag_drop=False, enable_multiple_select=False)
self.category_bar.set_expand_column(0)
self.category_bar.draw_mask = self.draw_treeview_mask
self.category_bar.set_size_request(132, 516)
self.category_bar.connect("single-click-item", self.on_categorybar_single_click)
# Init catagory bar.
self.__init_category_bar()
category_box = gtk.VBox()
background_box = BackgroundBox()
background_box.set_size_request(132, 11)
background_box.draw_mask = self.draw_treeview_mask
category_box.pack_start(background_box, False, False)
category_bar_align = gtk.Alignment()
category_bar_align.set(0, 0, 1, 1,)
category_bar_align.set_padding(0, 1, 0, 0)
category_bar_align.add(self.category_bar)
category_box.pack_start(category_bar_align, True, True)
# Pack widget.
left_box = gtk.VBox()
self.right_box = gtk.VBox()
left_box.add(category_box)
self.right_box.add(self.general_setting)
right_align = gtk.Alignment()
right_align.set_padding(0, 0, 10, 0)
right_align.add(self.right_box)
body_box = gtk.HBox()
body_box.pack_start(left_box, False, False)
body_box.pack_start(right_align, False, False)
self.main_box.add(body_box)
# DialogBox code.
self.body_box.pack_start(self.main_box, True, True)
self.right_button_box.set_buttons([close_button])
def __init_category_bar(self):
general_normal_item = NormalItem(_("General"), self.general_setting)
hotkey_normal_item = NormalItem(_("Hotkeys"), self.hotkey_setting)
self.lyrics_expand_item = ExpandItem(_("Lyrics"), None)
self.lyrics_expand_item.add_childs([(_("Desktop"), self.desktop_lyrics_setting),
(_("Window"), self.scroll_lyrics_setting)])
self.plugins_expand_item = NormalItem(_("Plugins"), self.plugins_manager)
about_normal_item = NormalItem(_("About"), AboutBox())
items = [general_normal_item,
hotkey_normal_item,
self.lyrics_expand_item,
self.plugins_expand_item,
about_normal_item]
self.category_bar.add_items(items)
self.category_bar.select_items([general_normal_item])
def switch_lyrics_page(self, index=3):
self.lyrics_expand_item.try_to_expand()
show_item = self.category_bar.visible_items[index]
self.category_bar.select_items([show_item])
self.on_categorybar_single_click(self.category_bar, show_item, None, None, None)
def show_scroll_lyrics_page(self):
self.switch_lyrics_page(4)
self.show_all()
def show_desktop_lyrics_page(self):
self.switch_lyrics_page(3)
self.show_all()
def draw_treeview_mask(self, cr, x, y, width, height):
draw_alpha_mask(cr, x, y, width, height, ("#FFFFFF", 0.9))
def on_categorybar_single_click(self, widget, item, column, x, y):
if item.allocate_widget:
switch_tab(self.right_box, item.allocate_widget)
def load_plugins(self):
self.plugins_manager.flush_plugins()
示例5: MirrorsBox
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_expand_column [as 别名]
#.........这里部分代码省略.........
elif not widget_active and daemon_running:
session = dbus.SessionBus()
dbus_obj = session.get_object(DSC_UPDATE_DAEMON_NAME, DSC_UPDATE_DAEMON_PATH)
iface = dbus.Interface(dbus_obj, DSC_UPDATE_DAEMON_NAME)
iface.quit()
def select_best_mirror(self, widget):
widget.set_label(self.select_best_mirror_button_texts["wait"])
widget.set_sensitive(False)
global_event.emit("toggle-waiting-dialog", True)
utils.ThreadMethod(self.change_to_nearest_mirror_thread, (widget, )).start()
def cancel_mirror_test(self):
if self.mirror_test_obj:
self.mirror_test_obj.cancel()
self.mirror_test_obj = None
self.finish_mirror_test("")
def change_to_nearest_mirror_thread(self, widget):
from mirror_speed.ip_detect import get_nearest_mirrors
hostnames = get_nearest_mirrors()
self.mirror_test_obj = MirrorTest(hostnames)
hostname = self.mirror_test_obj.run()
for mirror in self.mirrors_list:
if mirror.hostname == hostname:
global_event.emit("mirror-test-finished", mirror)
break
def finish_mirror_test(self, mirror):
for item in self.mirror_view.visible_items:
if item.mirror == mirror:
self.mirror_view.visible_item(item)
self.select_best_mirror_button.set_sensitive(True)
self.select_best_mirror_button.set_label(self.select_best_mirror_button_texts["normal"])
def create_mirror_select_table(self):
main_table = gtk.Table(3, 2)
main_table.set_row_spacings(CONTENT_ROW_SPACING)
mirror_select_title = Label(_("Select mirror"))
self.select_best_mirror_button = Button(self.select_best_mirror_button_texts["normal"])
self.select_best_mirror_button.connect("clicked", self.select_best_mirror)
self.mirrors_dir = os.path.join(get_parent_dir(__file__, 2), 'mirrors')
self.current_mirror_hostname = utils.get_current_mirror_hostname()
self.mirror_items = self.get_mirror_items()
self.mirror_view = TreeView(self.mirror_items,
enable_drag_drop=False,
enable_multiple_select=False,
mask_bound_height=0,
)
self.mirror_view.set_expand_column(1)
self.mirror_view.set_size_request(-1, 280)
self.mirror_view.draw_mask = self.mirror_treeview_draw_mask
main_table.attach(mirror_select_title, 0, 1, 0, 1, yoptions=gtk.FILL)
main_table.attach(self.select_best_mirror_button, 1, 2, 0, 1, xoptions=gtk.FILL)
main_table.attach(create_separator_box(), 0, 2, 1, 2, xoptions=gtk.FILL)
main_table.attach(self.mirror_view, 0, 2, 2, 3, xoptions=gtk.FILL)
return main_table
def mirror_changed_handler(self, mirror):
item = None
for i in self.mirror_view.visible_items:
if i.mirror == mirror:
item = i
break
if item:
self.current_mirror_item = item
for i in self.mirror_items:
if i != item and i.radio_button.active == True:
i.radio_button.active = False
elif i == item:
i.radio_button.active = True
self.mirror_view.queue_draw()
self.mirror_view.visible_item(item)
def mirror_treeview_draw_mask(self, cr, x, y, w, h):
cr.set_source_rgba(1, 1, 1, 0.5)
cr.rectangle(x, y, w, h)
cr.fill()
def get_mirror_items(self):
items = []
self.mirrors_list = get_mirrors()
for m in self.mirrors_list:
item = MirrorItem(m, self.mirror_clicked_callback)
if m.hostname == self.current_mirror_hostname:
item.radio_button.active = True
self.current_mirror_item = item
items.append(item)
items.sort(key=lambda item:item.mirror.priority)
return items
def mirror_clicked_callback(self, item):
if item != self.current_mirror_item:
global_event.emit('start-change-mirror', item.mirror)
示例6: DscPreferenceDialog
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_expand_column [as 别名]
class DscPreferenceDialog(PreferenceDialog):
def __init__(self):
PreferenceDialog.__init__(self, 566, 488)
self.current_mirror_item = None
self.normal_settings = gtk.VBox()
self.normal_settings.set_spacing(TABLE_ROW_SPACING)
self.normal_settings.pack_start(self.create_uninstall_box(), False, True)
self.normal_settings.pack_start(self.create_download_dir_table(), False, True)
self.normal_settings_align = gtk.Alignment(0, 0, 1, 1)
self.normal_settings_align.set_padding(padding_left=5, padding_right=5, padding_top=25, padding_bottom=10)
self.normal_settings_align.add(self.normal_settings)
self.mirror_settings = gtk.VBox()
self.mirror_settings.set_app_paintable(True)
self.mirror_settings.connect("expose-event", self.mirror_settings_align_expose)
self.mirror_settings.set_spacing(TABLE_ROW_SPACING)
self.mirror_settings.pack_start(self.create_mirror_select_table(), False, True)
self.mirror_settings.pack_start(self.create_source_update_frequency_table(), False, True)
self.mirror_settings_inner_align = gtk.Alignment(0.5, 0.5, 1, 1)
self.mirror_settings_inner_align.set_padding(padding_top=25, padding_bottom=10, padding_left=0, padding_right=0)
self.mirror_settings_inner_align.add(self.mirror_settings)
self.mirror_settings_scrolled_win = ScrolledWindow()
self.mirror_settings_scrolled_win.add_child(self.mirror_settings_inner_align)
self.mirror_settings_align = gtk.Alignment(0, 0, 1, 1)
self.mirror_settings_align.set_padding(padding_left=0, padding_right=0, padding_top=0, padding_bottom=3)
self.mirror_settings_align.add(self.mirror_settings_scrolled_win)
self.set_preference_items([
(_("General"), self.normal_settings_align),
(_("Mirrors"), self.mirror_settings_align),
(_("About"), AboutBox()),
])
def mirror_settings_align_expose(self, widget, event=None):
cr = widget.window.cairo_create()
rect = widget.allocation
# draw backgound
cr.rectangle(*rect)
#cr.set_source_rgb(*color_hex_to_cairo("#ff0000"))
cr.set_source_rgba(1, 1, 1, 0)
cr.fill()
def mirror_select_action(self, repo_urls):
self.data_manager.change_source_list(repo_urls, reply_handler=handle_dbus_reply, error_handler=handle_dbus_error)
def create_mirror_select_table(self):
vbox = gtk.VBox()
vbox.set_size_request(423, -1)
main_table = gtk.Table(2, 2)
main_table.set_row_spacings(CONTENT_ROW_SPACING)
dir_title_label = Label(_("Select mirror"))
dir_title_label.set_size_request(423, 12)
label_align = gtk.Alignment()
label_align.set_padding(0, 0, 10, 0)
label_align.add(dir_title_label)
self.mirrors_dir = os.path.join(get_parent_dir(__file__, 2), 'mirrors')
self.current_mirror_hostname = utils.get_current_mirror_hostname()
self.mirror_items = self.get_mirror_items()
self.mirror_view = TreeView(self.mirror_items,
enable_drag_drop=False,
enable_multiple_select=False,
#mask_bound_height=0,
)
self.mirror_view.set_expand_column(1)
self.mirror_view.set_size_request(-1, len(self.mirror_view.visible_items) * self.mirror_view.visible_items[0].get_height())
self.mirror_view.draw_mask = self.mirror_treeview_draw_mask
#self.display_current_mirror()
self.mirror_test_progressbar = ProgressBar()
main_table.attach(label_align, 0, 2, 0, 1, yoptions=gtk.FILL, xpadding=8)
main_table.attach(create_separator_box(), 0, 2, 1, 2, yoptions=gtk.FILL)
title = _("Select best mirror")
info_message = _("Please wait. The process will take 30 seconds or more depending on your network connection")
self.select_best_mirror_dialog = WaitingDialog(title, info_message, self.cancel_mirror_test)
global_event.register_event("mirror-changed", self.mirror_changed_handler)
global_event.register_event("update-list-finish", self.update_list_finish_handler)
vbox.pack_start(main_table, False, False)
vbox.pack_start(self.mirror_view, False, False)
return vbox
def cancel_mirror_test(self, widget):
try:
self.mirror_test.terminated = True
gobject.source_remove(self.update_status_id)
except:
pass
self.select_best_mirror_dialog.hide_all()
#.........这里部分代码省略.........
示例7: UninstallPage
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_expand_column [as 别名]
class UninstallPage(gtk.VBox):
'''
class docs
'''
def __init__(self, bus_interface, data_manager):
'''
init docs
'''
# Init.
gtk.VBox.__init__(self)
self.bus_interface = bus_interface
self.data_manager = data_manager
self.search_flag = False
self.uninstall_change_items = {"add": [], "delete": []}
self.message_bar = MessageBar(32)
self.message_bar.search_entry.entry.connect("changed", self.search_cb)
self.message_bar.search_button.connect("clicked", self.search_cb)
self.treeview = TreeView(enable_drag_drop=False)
self.treeview.set_expand_column(0)
top_hbox = gtk.HBox()
top_hbox.pack_start(self.message_bar)
self.pack_start(top_hbox, False, False)
self.pack_start(self.treeview, True, True)
self.treeview.connect("items-change", self.update_message_bar)
self.white_kernel_pkg_names = self.get_white_kernel_pkg_names()
self.fetch_uninstall_info()
self.treeview.draw_mask = self.draw_mask
def search_cb(self, widget, event=None):
if not self.search_flag:
self.cache_items = [item for item in self.treeview.visible_items]
results = []
keywords = self.message_bar.search_entry.get_text().strip()
if keywords != "":
self.search_flag = True
# TODO: comment this search_query api, there are many problems for this api
'''
pkg_names = self.data_manager.search_query(map(lambda word: word.encode("utf8"), keywords.split(" ")))
for item in self.cache_items:
if item.pkg_name in pkg_names:
results.append(item)
'''
for item in self.cache_items:
if keywords in item.pkg_name:
results.append(item)
self.treeview.clear()
self.treeview.add_items(results)
else:
self.treeview.clear()
self.search_flag = False
# for add items
if self.uninstall_change_items["add"] != []:
for item in self.uninstall_change_items["add"]:
self.cache_items.append(item)
self.uninstall_change_items["add"] = []
# for delete items
if self.uninstall_change_items["delete"] != []:
for item in self.uninstall_change_items["delete"]:
if item in self.cache_items:
self.cache_items.remove(item)
self.uninstall_change_items["delete"] = []
self.treeview.add_items(self.cache_items)
def normal_search_cb(self, keywords):
pass
def update_message_bar(self, treeview):
self.message_bar.set_message(_("%s applications can be uninstalled") % len(treeview.visible_items))
def draw_mask(self, cr, x, y, w, h):
'''
Draw mask interface.
@param cr: Cairo context.
@param x: X coordiante of draw area.
@param y: Y coordiante of draw area.
@param w: Width of draw area.
@param h: Height of draw area.
'''
draw_vlinear(cr, x, y, w, h,
[(0, ("#FFFFFF", 0.9)),
(1, ("#FFFFFF", 0.9)),]
)
def update_action_status(self, pkg_infos):
pkg_items = []
for (pkg_name, action_status) in pkg_infos:
pkg_item = None
#.........这里部分代码省略.........
示例8: PluginsManager
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_expand_column [as 别名]
class PluginsManager(gtk.VBox):
def __init__(self):
gtk.VBox.__init__(self)
self.set_spacing(5)
self.plugins = utils.get_main_window().plugins
self.plugins_view = TreeView()
self.plugins_view.set_expand_column(0)
self.plugins_view.draw_mask = self.plugins_view_draw_mask
self.plugins_view.set_size_request(420, 330)
self.plugins_view.connect("single-click-item", self.on_plugins_view_single_click)
self.plugins_view.set_column_titles([_("Add-on"), _("Version"), _("Enable"), ""],
(self.sort_by_title, self.sort_by_title,
self.sort_by_title, self.sort_by_title))
plugins_view_align = set_widget_gravity(self.plugins_view, gravity=(1, 1, 1, 1),
paddings=(10, 0, 0, 0))
self.plugin_infos = PluginInfos()
self.plugin_infos.set_size_request(420, 90)
# plugin info
self.pack_start(plugins_view_align, False, True)
self.pack_start(self.plugin_infos, False, True)
def sort_by_title(self, items, reverse):
return sorted(items, key=lambda item: item.plugin, reverse=reverse)
def plugins_view_draw_mask(self, cr, x, y, width, height):
draw_alpha_mask(cr, x, y, width, height, "layoutLeft")
def flush_plugins(self):
self.__load_plugin_list()
def __load_plugin_list(self):
# clear plugins_view items.
self.plugins_view.clear()
plugins = self.plugins.list_installed_plugins()
plugins_list = []
failed_list = []
for plugin in plugins:
try:
info = self.plugins.get_plugin_info(plugin)
except Exception:
failed_list.append(plugin)
continue
enabled = plugin in self.plugins.enabled_plugins
plugins_list.append((plugin, info, enabled))
plugins_list.sort(key=lambda x: locale.strxfrm(x[1]["Name"]))
plugins_items = [PluginItem(*args) for args in plugins_list]
self.plugins_view.add_items(plugins_items)
def on_plugins_view_single_click(self, widget, item, column, x, y):
if column == 2:
plugin = item.plugin
will_enable = not item.enabled
if will_enable:
try:
self.plugins.enable_plugin(plugin)
except Exception, e:
print e
return
else:
try:
self.plugins.disable_plugin(plugin)
except Exception, e:
print e
return
item.toggle_enabled()
示例9: ListviewFactory
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_expand_column [as 别名]
class ListviewFactory(object):
'''
class docs
'''
def __init__(self, items, owner):
'''
init docs
'''
self.items = [ListViewItem(x, owner) for x in items]
self.owner = owner
self.count_per_page = 10 if self.owner == "brief" else 20
self.listview = None
self.page_count = 0
self.page_index = 0
self.paged_items = self.get_paged_items()
self.init_listview()
def prepend_item(self, item):
if self.listview:
self.listview.add_items([ListViewItem(item, self.owner)], insert_pos=0)
def append_item(self, item):
if self.listview:
self.listview.add_items([ListViewItem(item, self.owner)])
def on_listview_button_pressed(self, widget, event, listview):
x = event.x
y = event.y
if event.button == 1:
for item in listview.get_items():
for index, rect in enumerate(item.pointer_hand_rectangles):
if is_in_rect((x, y), rect):
action = item.message["hints"]["x-deepin-hyperlinks"][index]
if action.has_key("href"):
webbrowser.open_new_tab(action.get("href"))
return
def on_listview_motion_notify(self, widget, event, listview):
x = event.x
y = event.y
flag = False
for item in listview.get_items():
if flag:
break
for rect in item.pointer_hand_rectangles:
if is_in_rect((x, y), rect):
flag = True
break
if flag:
widget.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND1))
else:
widget.window.set_cursor(None)
def init_listview(self):
'''
docs
'''
items = self.paged_items[self.page_index]
self.listview = TreeView(items)
self.listview.draw_mask = self.on_listview_draw_mask
self.listview.set_expand_column(0)
if self.owner == "detail":
self.listview.set_column_titles([_("Content of messages"), _("Time")],
[self.sort_by_content, self.sort_by_time])
self.listview.draw_area.connect_after("button-press-event", self.on_listview_button_pressed, self.listview)
self.listview.draw_area.connect_after("motion-notify-event", self.on_listview_motion_notify, self.listview)
self.listview.connect("right-press-items", self.on_listview_right_press_items)
self.listview.scrolled_window.connect("vscrollbar-state-changed", self.update_listview)
event_manager.emit("listview-items-added", items)
def update_listview(self, widget, state):
if state == "bottom":
if self.page_index < self.page_count - 1:
self.page_index = self.page_index + 1
items = self.paged_items[self.page_index]
self.listview.add_items(items)
event_manager.emit("listview-items-added", items)
def on_listview_draw_mask(self, cr, x, y, w, h):
cr.set_source_rgb(1, 1, 1)
cr.rectangle(x, y, w, h)
cr.fill()
def on_listview_right_press_items(self, widget, root_x, root_y, current_item, select_items):
if self.owner == "detail":
#.........这里部分代码省略.........
示例10: SearchUI
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_expand_column [as 别名]
class SearchUI(DialogBox):
def __init__(self):
DialogBox.__init__(
self, _("Lyrics search"), 460, 300, DIALOG_MASK_MULTIPLE_PAGE, close_callback=self.hide_all,
modal=False, window_hint=None, skip_taskbar_hint=False, window_pos=gtk.WIN_POS_CENTER)
self.artist_entry = InputEntry()
self.artist_entry.set_size(130, 23)
self.title_entry = InputEntry()
self.title_entry.set_size(130, 23)
artist_label = Label(_("Artist:"))
title_label = Label(_("Title:"))
right_align = gtk.Alignment()
right_align.set(0, 0, 0, 1)
self.search_button = Button(_("Search"))
self.search_button.connect("clicked", self.search_lyric_cb)
self.process_id = 0
info_box = gtk.HBox(spacing=25)
control_box = gtk.HBox(spacing=5)
title_box = gtk.HBox(spacing=5)
title_box.pack_start(title_label, False, False)
title_box.pack_start(self.title_entry)
artist_box = gtk.HBox(spacing=5)
artist_box.pack_start(artist_label, False, False)
artist_box.pack_start(self.artist_entry)
control_box.pack_start(title_box, False, False)
control_box.pack_start(artist_box, False, False)
info_box.pack_start(control_box, False, False)
info_box.pack_start(self.search_button, False, False)
sort_items = [ lambda items, reverse : self.sort_by_key(items, reverse, "title"),
lambda items, reverse : self.sort_by_key(items, reverse, "artist")]
self.result_view = TreeView()
self.result_view.set_expand_column(0)
self.result_view.connect("double-click-item", self.double_click_cb)
self.result_view.set_column_titles([_("Title"), _("Artist")], sort_items)
self.result_view.draw_mask = self.draw_view_mask
self.prompt_label = Label("")
download_button = Button(_("Download"))
download_button.connect("clicked", self.download_lyric_cb)
cancel_button = Button(_("Close"))
cancel_button.connect("clicked", lambda w: self.hide_all())
info_box_align = gtk.Alignment()
info_box_align.set_padding(5, 0, 5, 0)
info_box_align.add(info_box)
self.body_box.set_spacing(5)
self.body_box.pack_start(info_box_align, False, False)
self.body_box.pack_start(self.result_view, True, True)
self.left_button_box.set_buttons([self.prompt_label])
self.right_button_box.set_buttons([download_button, cancel_button])
self.lrc_manager = LrcManager()
def show_window(self):
DialogBox.show_window(self)
self.present()
def draw_view_mask(self, cr, x, y, width, height):
draw_alpha_mask(cr, x, y, width, height, "layoutMiddle")
def sort_by_key(self, items, sort_reverse, sort_key):
return sorted(items, reverse=sort_reverse, key=lambda item: getattr(item, sort_key))
def double_click_cb(self, widget, item, colume, x, y):
self.download_lyric_cb(widget)
def search_engine(self, artist, title, pid):
ting_result = poster.query_lrc_info(artist, title)
self.render_lyrics(ting_result, pid=pid)
ttplayer_result = TTPlayer().request(artist, title)
self.render_lyrics(ttplayer_result, pid=pid)
ttpod_result = TTPod().request(artist, title)
self.render_lyrics(ttpod_result, pid=pid)
duomi_result = DUOMI().request(artist, title)
self.render_lyrics(duomi_result, pid=pid, last=True)
def search_lyric_cb(self, widget):
self.result_view.clear()
artist = self.artist_entry.entry.get_text()
title = self.title_entry.entry.get_text()
# widget.set_sensitive(False)
self.prompt_label.set_text(_("Now searching..."))
if artist == "" and title == "":
self.prompt_label.set_text(_("Not found!"))
return
self.process_id += 1
utils.ThreadLoad(self.search_engine, artist, title, self.process_id).start()
@post_gui
#.........这里部分代码省略.........
示例11: Region
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_expand_column [as 别名]
class Region(gtk.Alignment):
def __init__(self, connection=None):
gtk.Alignment.__init__(self, 0, 0, 0, 0)
#################
self.provider_select = None
self.connect('expose-event', self.expose_event)
self.prop_dict = {}
main_table = gtk.Table(2, 2, False)
main_table.set_row_spacing(1, 10)
main_table.set_col_spacings(4)
self.add(main_table)
self.country_tree = TreeView(enable_multiple_select=False,
enable_drag_drop=False,
)
self.country_tree.set_expand_column(1)
self.country_tree.set_size_request(365, 380)
self.country_tree.draw_mask = self.draw_mask
self.country_tree.connect("button-press-item", self.country_selected)
left_box_align = gtk.Alignment(0, 0, 0, 0)
left_box_align.set_padding(1,1,1,1)
left_box_align.add(self.country_tree)
left_box_align.show_all()
left_box = gtk.VBox()
# wrap title
country_title = TitleBar(app_theme.get_pixbuf("network/globe-green.png"),
_("Country or Region:"),
has_separator=False)
left_box.pack_start(country_title, False, False)
left_box.pack_start(left_box_align, False, False)
self.provider_tree = TreeView(enable_multiple_select=False,
enable_drag_drop=False,
)
self.provider_tree.set_expand_column(0)
self.provider_tree.set_size_request(365, 380)
self.provider_tree.draw_mask = self.draw_mask
self.provider_tree.connect("button-press-item", self.provider_selected)
right_box_align = gtk.Alignment(0, 0, 0, 0)
right_box_align.set_padding(1,1,1,1)
right_box_align.add(self.provider_tree)
right_box = gtk.VBox()
# wrap title
provider_title = TitleBar(app_theme.get_pixbuf("network/building.png"),
_("Provider:"),
has_separator=False)
right_box.pack_start(provider_title, False, False)
right_box.pack_start(right_box_align, False, False)
main_left_align = gtk.Alignment(0, 0, 0, 0)
main_left_align.set_padding(15, 0, 20, 0)
main_left_align.add(left_box)
main_table.attach(main_left_align, 0, 1, 0, 1)
main_right_align = gtk.Alignment(0, 0, 0, 0)
main_right_align.set_padding(15, 0, 0, 20)
main_right_align.add(right_box)
main_table.attach(main_right_align, 1, 2, 0, 1)
hints = _("Tips:This assistant helps you easily set up a mobile broadband connection to a cellular network.")
left_box_align.connect("expose-event", self.expose_outline)
right_box_align.connect("expose-event", self.expose_outline)
next_button = Button("Next")
next_button.connect("clicked", self.next_button_clicked)
self.foot_box = FootBox()
self.foot_box.set_buttons([next_button])
self.foot_box.set_tip(hints)
main_table.attach(self.foot_box, 0, 2, 1, 2)
self.show_all()
#self.init()
def expose_outline(self, widget, event):
cr = widget.window.cairo_create()
rect = widget.allocation
with cairo_disable_antialias(cr):
cr.set_line_width(1)
cr.set_source_rgb(*BORDER_COLOR)
cr.rectangle(rect.x, rect.y, rect.width , rect.height )
cr.stroke()
def draw_mask(self, cr, x, y, w, h):
cr.set_source_rgb(1, 1, 1)
cr.rectangle(x, y, w, h)
cr.fill()
def expose_event(self, widget, event):
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()
#.........这里部分代码省略.........
示例12: Section
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_expand_column [as 别名]
class Section(gtk.VBox):
# Section prototype
def __init__(self):
gtk.VBox.__init__(self)
self.timer = Timer(200, self.action_after_toggle)
def load(self, toggle, content=[]):
self.toggle = toggle
self.content_box = gtk.VBox(spacing=0)
self.pack_start(self.toggle, False, False)
self.toggle.switch.connect("toggled", self.toggle_callback)
self.tree = TreeView([])
self.tree.set_expand_column(1)
self.tree.draw_mask = self.draw_mask
content.insert(0, self.tree)
for c in content:
self.content_box.pack_start(c, False, False)
self.align = self._set_align()
self.pack_start(self.align, False, False)
self.show_all()
def init_state(self):
pass
def set_active(self, state):
self.toggle.set_active(state)
def draw_mask(self, cr, x, y, w, h):
cr.set_source_rgb(1, 1, 1)
cr.rectangle(x, y, w, h)
cr.fill()
def _set_align(self):
align = gtk.Alignment(0,0,1,0)
align.set_padding(0, 0, PADDING, 11 + 11)
return align
def toggle_callback(self, widget):
if self.timer.alive():
self.timer.restart()
else:
self.timer.start()
def action_after_toggle(self):
is_active = self.toggle.get_active()
if is_active:
if self.content_box not in self.align.get_children():
self.align.add(self.content_box)
self.show_all()
self.td = ToggleThread(self.get_list, self.tree, self.toggle_on_after)
self.td.start()
else:
self.align.remove(self.content_box)
self.td.stop_run()
self.toggle_off()
def toggle_on(self):
'''
method cb when toggle on
'''
pass
def toggle_on_after(self):
pass
def toggle_off(self):
pass
def get_list(self):
pass
def section_show(self):
self.set_no_show_all(False)
self.show_all()
def section_hide(self):
self.set_no_show_all(True)
self.hide()
def space_box(self):
space = gtk.VBox()
space.set_size_request(-1, 15)
return space
示例13: WirelessSection
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_expand_column [as 别名]
class WirelessSection(Section, WirelessDevice):
def __init__(self):
Section.__init__(self)
WirelessDevice.__init__(self)
self.wireless = Contain(app_theme.get_pixbuf("network/wifi.png"), _("Wireless"), lambda w:w)
self.label = Label(_("Set up a hidden wireless connection"),
LABEL_COLOR,
underline=True,
enable_select=False,
enable_double_click=False)
space = gtk.VBox()
space.set_size_request(-1, 15)
self.load(self.wireless, [space, self.label])
self.content_box.set_spacing(0)
self.selected_item = None
self.device_tree = None
self.focused_device = None
self.wireless_devices = None
def add_switcher(self):
if self.device_tree == None:
self.device_tree = TreeView([DeviceToggleItem(self.wireless_devices, 0)])
self.device_tree.set_expand_column(1)
self.content_box.pack_start(self.device_tree, False, True)
self.content_box.reorder_child(self.device_tree, 0)
net_manager.emit_wifi_switch(0)
def remove_switcher(self):
if self.device_tree\
and self.device_tree in self.content_box.get_children():
self.content_box.remove(self.device_tree)
self.device_tree = None
try:
self.focused_device = self.wireless_devices[0]
except:
log.error("get no wireless devices but try to index")
self.focused_device = None
self.wireless_redraw(None)
@classmethod
def show_or_hide(self):
if net_manager.device_manager.get_wireless_devices():
self.wireless_devices = net_manager.device_manager.get_wireless_devices()
return True
else:
self.wireless_devices = []
return False
def init_state(self):
self.ap_list = []
self.wireless_devices = net_manager.device_manager.get_wireless_devices()
if self.wireless_devices:
#self.device_dict = dict()
self.focused_device = self.wireless_devices[0]
if len(self.wireless_devices) > 1:
self.add_switcher()
self.tree.connect("single-click-item", self.set_selected_item)
## check state
if self.get_state(self.wireless_devices):
self.wireless.set_active(True)
else:
pass
self.init_signals()
def init_signals(self):
self._init_signals()
Dispatcher.connect("switch-device", self.switch_devices)
Dispatcher.connect("wireless-device-add", self.device_added)
Dispatcher.connect("ap-added", self.ap_added_callback)
Dispatcher.connect("ap-removed", self.ap_removed_callback)
Dispatcher.connect("wireless-redraw", self.wireless_redraw)
self.label.connect("button-release-event", self.create_a_hidden_network)
event_manager.add_callback('hidden-connection-removed', self.on_delete_redraw)
def switch_devices(self, widget, device):
self.focused_device = device
if self.device_tree:
self.device_tree.visible_items[0].set_index(device)
self.wireless_redraw(None)
def on_delete_redraw(self, name, event, data):
self.wireless_redraw(None)
def wireless_redraw(self, widget):
log.debug()
if self.wireless.get_active():
self.wireless.set_active(True, emit=True)
self.show_all()
def device_added(self, widget, device):
self.wireless_devices = net_manager.device_manager.get_wireless_devices()
self._init_signals()
if len(self.wireless_devices) > 1:
#.........这里部分代码省略.........
示例14: TreeView
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_expand_column [as 别名]
application.set_skin_preview(os.path.join(get_current_dir(__file__), "frame.png"))
# Add titlebar.
application.add_titlebar(
["theme", "max", "min", "close"],
os.path.join(get_current_dir(__file__), "logo.png"),
"TreeView demo",
"TreeView demo",
)
# Add TreeView.
print os.path.expanduser("~")
treeview = TreeView(get_dir_items(os.path.expanduser("~")))
# expand column.
treeview.set_expand_column(3)
# hide column
treeview.set_hide_columns([1, 2])
#treeview.set_highlight_item(treeview.get_items()[35])
treeview.connect("delete-select-items", m_delete_select_items)
treeview.connect("button-press-item", m_button_press_item)
treeview.connect("double-click-item", m_double_click_item)
treeview.connect("right-press-items", m_right_press_items)
treeview.connect("single-click-item", m_single_click_item)
# treeview = TreeView(get_dir_items("/"))
treeview_align = gtk.Alignment()
treeview_align.set(0.5, 0.5, 1, 1)
treeview_align.set_padding(0, 2, 2, 2)
示例15: SessionView
# 需要导入模块: from dtk.ui.treeview import TreeView [as 别名]
# 或者: from dtk.ui.treeview.TreeView import set_expand_column [as 别名]
class SessionView(gtk.VBox):
def __init__(self):
gtk.VBox.__init__(self)
self.open_dialog = False
self.tmp_editing_session = None
# UI style
style.draw_background_color(self)
self.tree = TreeView([],enable_drag_drop=False,
enable_hover=True,
enable_multiple_select=False,
)
self.tree.set_expand_column(3)
self.tree.set_column_titles((_("Active"), _("Application"), _("Description"), _("Exec")),)
self.tree.set_size_request(800, -1)
self.tree.connect("right-press-items", self.right_press_item)
self.tree.draw_mask = self.draw_mask
self.tree.add_items(self.get_list())
align = gtk.Alignment(0, 0, 0, 1)
align.set_padding(15, 0, 20, 20)
align.add(self.tree)
align.connect("expose-event", self.expose_line)
add_button = Button(_("New"))
self.delete_button = Button(_("Delete"))
add_button.connect("clicked", self.add_autostart)
self.delete_button.connect("clicked", self.delete_autostart)
self.delete_button.set_sensitive(False)
foot_box = FootBox(adjustment=15)
foot_box.set_buttons([add_button, self.delete_button])
self.pack_start(align, True, True)
self.pack_end(foot_box, False, False)
#self.pack_end(self.new_box, False, False)
self.show_all()
self._init_monitor()
def disable_delete_button(self, value):
self.delete_button.set_sensitive(not value)
def _init_monitor(self):
self.library_monitor = LibraryMonitor(get_user_config_dir())
self.library_monitor.set_property("monitored", True)
self.library_monitor.connect("file-added", self.refresh_list)
self.library_monitor.connect("location-removed", self.refresh_list)
def right_press_item(self, widget, x_root, y_root, current_item, select_items):
self.tmp_editing_session = current_item.item
for item in select_items:
item.unselect()
if current_item != None:
current_item.select()
if self.open_dialog == False:
dialog = NewSessionDialog(confirm_callback = self.edit_done, cancel_callback = self.cancel_callback)
dialog.name_entry.set_text(current_item.item.name)
dialog.exec_entry.set_text(current_item.item.exec_)
dialog.desc_entry.set_text(current_item.item.comment)
dialog.place_center()
dialog.show_all()
self.open_dialog = True
def create_session_item(self, dialog):
name = dialog.name_entry.get_text()
exec_ = dialog.exec_entry.get_text()
comment = dialog.desc_entry.get_text()
session_manager.add(name, exec_, comment)
self.open_dialog = 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"])
def sort_method(self):
pass
def add_autostart(self, widget):
if self.open_dialog == False:
dialog = NewSessionDialog(confirm_callback= self.create_session_item, cancel_callback = self.cancel_callback)
dialog.show_all()
self.open_dialog = True
def delete_autostart(self, widget):
items = map(lambda row: self.tree.visible_items[row], self.tree.select_rows)
item = items[0].item
item.delete()
self.tree.delete_select_items()
if self.tree.visible_items == []:
self.tree.add_items([NothingItem()])
def edit_done(self, dialog):
self.tmp_editing_session.set_name(dialog.name_entry.get_text())
self.tmp_editing_session.set_exec(dialog.exec_entry.get_text())
self.tmp_editing_session.set_comment(dialog.desc_entry.get_text())
#.........这里部分代码省略.........