当前位置: 首页>>代码示例>>Python>>正文


Python IconView.connect方法代码示例

本文整理汇总了Python中dtk.ui.iconview.IconView.connect方法的典型用法代码示例。如果您正苦于以下问题:Python IconView.connect方法的具体用法?Python IconView.connect怎么用?Python IconView.connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dtk.ui.iconview.IconView的用法示例。


在下文中一共展示了IconView.connect方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: DeviceIconView

# 需要导入模块: from dtk.ui.iconview import IconView [as 别名]
# 或者: from dtk.ui.iconview.IconView import connect [as 别名]
class DeviceIconView(ScrolledWindow):
    def __init__(self, items=None):
        ScrolledWindow.__init__(self, 0, 0)

        self.device_iconview = IconView()
        self.device_iconview.connect("right-click-item", self.__on_right_click_item)
        self.device_iconview.draw_mask = self.draw_mask

        if items:
            self.device_iconview.add_items(items)

        self.device_scrolledwindow = ScrolledWindow()
        self.device_scrolledwindow.add_child(self.device_iconview)

        self.add_child(self.device_scrolledwindow)

        event_manager.add_callback("text", self.__on_text)
        event_manager.add_callback("hide-text", self.__on_hide_text)
        
    def __on_text(self, name, obj, argv):
        disable(self, False)
        text(self, argv)

    def __on_hide_text(self, name, obj, argv):
        disable(self, True)

    def __do_remove_item(self, item):
        item.do_remove()
        self.device_iconview.delete_items([item])

    def __on_right_click_item(self, widget, item, x, y):
        menu_items = [(None, _("Pair"), lambda : item.do_pair())]
        if item.is_paired:
            menu_items = []
            menu_items.extend(item.menu_items)
            menu_items.append(None)
            menu_items.append((None, _("Remove Device"), lambda : self.__do_remove_item(item)))

        Menu(menu_items, True).show((int(x), int(y)))
        
    def clear(self):
        self.device_iconview.clear()

    def draw_mask(self, cr, x, y, w, h):
        cr.set_source_rgb(*color_hex_to_cairo("#FFFFFF"))
        cr.rectangle(x, y, w, h)
        cr.fill()

        cr.set_source_rgb(*color_hex_to_cairo("#AEAEAE"))
        cr.rectangle(x, y, w, h)
        cr.stroke()

    def add_items(self, items, clear=False):
        if clear:
            self.device_iconview.clear()

        self.device_iconview.add_items(items)
开发者ID:electricface,项目名称:deepin-system-settings,代码行数:59,代码来源:bluetooth_view.py

示例2: get_icon_view

# 需要导入模块: from dtk.ui.iconview import IconView [as 别名]
# 或者: from dtk.ui.iconview.IconView import connect [as 别名]
 def get_icon_view(self, padding_x=0, padding_y=10):    
     ''' Draggable IconView '''
     icon_view = IconView(padding_x, padding_y)
     targets = [("text/deepin-songs", gtk.TARGET_SAME_APP, 1), ("text/uri-list", 0, 2)]
     icon_view.drag_source_set(gtk.gdk.BUTTON1_MASK, targets, gtk.gdk.ACTION_COPY)
     icon_view.connect("drag-data-get", self.__on_drag_data_get) 
     icon_view.connect("double-click-item", self.__on_double_click_item)
     icon_view.connect("single-click-item", self.__on_single_click_item)
     icon_view.connect("right-click-item", self.__on_right_click_item)
     
     icon_view.draw_mask  = self.on_iconview_draw_mask
     scrolled_window = ScrolledWindow()
     scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
     scrolled_window.add_child(icon_view)
     return icon_view, scrolled_window
开发者ID:WilliamRen,项目名称:deepin-music-player,代码行数:17,代码来源:local_browser.py

示例3: SecondCategoryItem

# 需要导入模块: from dtk.ui.iconview import IconView [as 别名]
# 或者: from dtk.ui.iconview.IconView import connect [as 别名]

#.........这里部分代码省略.........
    def hover(self, column, offset_x, offset_y):
        self.is_hover = True
        if self.redraw_request_callback:
            self.redraw_request_callback(self)
        
    def unhover(self, column, offset_x, offset_y):
        self.is_hover = False
        if self.redraw_request_callback:
            self.redraw_request_callback(self)
    
    def select(self):
        self.is_select = True
        if self.redraw_request_callback:
            self.redraw_request_callback(self)
        
    def unselect(self):
        self.is_select = False
        if self.redraw_request_callback:
            self.redraw_request_callback(self)
    
    def scrolled_window_vscrollbar_handler(self, widget, state):
        if state == "bottom":
            current_item_number = len(self.pkg_icon_view.items)
            all_pkgs_number = len(self.all_pkg_names)
            start = current_item_number
            if current_item_number < all_pkgs_number and (current_item_number+LOAD_ITEMS_NUMBER) < all_pkgs_number:
                end = current_item_number+LOAD_ITEMS_NUMBER
            elif current_item_number < all_pkgs_number and (current_item_number+LOAD_ITEMS_NUMBER) >= all_pkgs_number:
                end = all_pkgs_number
            else:
                return
            self.load_new_items(self.all_pkg_names[start:end])

    def load_new_items(self, pkg_names):
        items = []
        for pkg_name in pkg_names:
            info = self.data_manager.get_item_pkg_info(pkg_name)
            items.append(PkgIconItem(info[0], info[1], info[2], self.data_manager))
        self.pkg_icon_view.add_items(items)
        global_event.emit("show-pkg-view", self.page_box)

    def handle_pkg_install_status_request(self, status, items):
        for (index, state) in enumerate(status):
            items[index].is_installed = state
            items[index].emit_redraw_request()

    def button_press(self, column, offset_x, offset_y):
        # init Loading widget
        loading_box = LoadingBox()

        global_event.emit("show-pkg-view", loading_box)

        self.page_box = gtk.VBox()    
            
        self.all_pkg_names = self.data_manager.get_second_category_packages(self.second_category_name)
        self.message_bar = MessageBar(18)
        self.message_bar.set_message(_("%s > %s : %s applications") % (
                get_category_name(self.first_category_name), 
                get_category_name(self.second_category_name), 
                len(self.all_pkg_names),
                ))
        
        self.pkg_icon_view = IconView() 
        self.pkg_icon_view.connect("motion-notify-item", tooltip_aciton)
        if len(self.all_pkg_names) > LOAD_ITEMS_NUMBER:
            self.load_new_items(self.all_pkg_names[:LOAD_ITEMS_NUMBER])
        else:
            self.load_new_items(self.all_pkg_names)

        self.pkg_icon_scrolled_window = ScrolledWindow()
        self.pkg_icon_scrolled_window.connect("vscrollbar-state-changed", self.scrolled_window_vscrollbar_handler)
        self.pkg_icon_scrolled_window.add_child(self.pkg_icon_view)
        self.pkg_icon_view.draw_mask = self.draw_mask
        self.pkg_icon_view.draw_row_mask = self.draw_row_mask
        
        self.page_box.pack_start(self.message_bar, False, False)
        self.page_box.pack_start(self.pkg_icon_scrolled_window, True, True)
        
        global_event.emit("update-current-status-pkg-page", self.pkg_icon_view)
        
    def draw_row_mask(self, cr, rect, row):
        if row % 2 == 1:
            cr.set_source_rgba(1, 1, 1, 0.5)
            cr.rectangle(rect.x, rect.y, rect.width, rect.height)
            cr.fill()
    
    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)),]
                     )
开发者ID:electricface,项目名称:deepin-software-center,代码行数:104,代码来源:home_page.py

示例4: CategoryItem

# 需要导入模块: from dtk.ui.iconview import IconView [as 别名]
# 或者: from dtk.ui.iconview.IconView import connect [as 别名]

#.........这里部分代码省略.........
            self.load_new_items(self.all_pkg_names[start:end])
            
    def load_new_items(self, pkg_names):
        items = []
        for pkg_name in pkg_names:
            info = self.data_manager.get_item_pkg_info(pkg_name)
            items.append(PkgIconItem(info[0], info[1], info[2], self.data_manager))
        self.pkg_icon_view.add_items(items)
        global_event.emit("show-pkg-view", self.page_box)

    def handle_pkg_install_status_request(self, status, items):
        for (index, state) in enumerate(status):
            items[index].is_installed = state
            items[index].emit_redraw_request()

    def single_click(self, column, offset_x, offset_y):
        # init Loading widget
        loading_box = LoadingBox()
        global_event.emit("show-pkg-view", loading_box)

        self.page_box = gtk.VBox()    

        self.all_pkg_names = []
        self.all_desktop_infos = {}
        self.all_pkg_names = self.data_manager.get_first_category_packages(self.first_category_name)
            
        self.message_bar = MessageBar(18)
        self.message_bar.set_message(_("%s: %s applications") % (
                    get_category_name(self.first_category_name), 
                    len(self.all_pkg_names),
                    ))
        
        self.pkg_icon_view = IconView() 
        self.pkg_icon_view.connect("motion-notify-item", tooltip_aciton)
        if len(self.all_pkg_names) > LOAD_ITEMS_NUMBER:
            self.load_new_items(self.all_pkg_names[:LOAD_ITEMS_NUMBER])
        else:
            self.load_new_items(self.all_pkg_names)

        self.pkg_icon_view.draw_mask = self.draw_mask
        self.pkg_icon_view.draw_row_mask = self.draw_row_mask
        self.pkg_icon_scrolled_window = ScrolledWindow()
        self.pkg_icon_scrolled_window.connect("vscrollbar-state-changed", self.scrolled_window_vscrollbar_handler)
        self.pkg_icon_scrolled_window.add_child(self.pkg_icon_view)
        
        self.page_box.pack_start(self.message_bar, False, False)
        self.page_box.pack_start(self.pkg_icon_scrolled_window, True, True)
        global_event.emit("update-current-status-pkg-page", self.pkg_icon_view)
        
    def draw_row_mask(self, cr, rect, row):
        if row % 2 == 1:
            cr.set_source_rgba(1, 1, 1, 0.5)
            cr.rectangle(rect.x, rect.y, rect.width, rect.height)
            cr.fill()
    
    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,
开发者ID:electricface,项目名称:deepin-software-center,代码行数:70,代码来源:home_page.py

示例5: Browser

# 需要导入模块: from dtk.ui.iconview import IconView [as 别名]
# 或者: from dtk.ui.iconview.IconView import connect [as 别名]
class Browser(gtk.VBox, SignalContainer):
    
    def __init__(self, db_query):
        
        gtk.VBox.__init__(self)
        SignalContainer.__init__(self)
        
        self.__db_query = db_query
        self._tree = {}
        self.__selected_tag = {"album": [], "artist": [], "genre": []}
        self.view_mode = ICON_VIEW_MODE
        self.__search_flag = False
        self.__song_cache_items = []
        self.__cover_cache_items = []
        
        # init widget.
        self.entry_box = SearchEntry("")
        self.entry_box.set_size(155, 22)
        self.entry_box.entry.connect("changed", self.__search_cb)
        
        # upper box.
        self.back_button = self.__create_simple_button("back", self.__switch_to_filter_view)
        self.back_button.set_no_show_all(True)
        back_align = gtk.Alignment()
        back_align.set(0.5, 0.5, 0, 0)
        back_align.set_padding(0, 0, 0, 10)
        back_align.add(self.back_button)
        
        # path control
        self.path_combo_box = ComboMenuButton()
        self.path_combo_box.connect("list-actived", lambda w: self.update_path_list_view())
        self.path_combo_box.connect("combo-actived", lambda w, k : self.update_path_filter_view(k))
        path_combo_align = gtk.Alignment()
        path_combo_align.set_padding(0, 0, 10, 0)
        path_combo_align.add(self.path_combo_box)
        self.path_combo_box.set_no_show_all(True)
        
        upper_box = gtk.HBox(spacing=5)
        upper_box.pack_start(path_combo_align, False, False)
        upper_box.pack_start(create_right_align(), True, True)
        upper_box.pack_start(back_align, False, False)
        entry_box_align = gtk.Alignment()
        entry_box_align.set(0.5, 0.5, 0, 0)
        entry_box_align.set_padding(1, 0, 0, 0)
        entry_box_align.add(self.entry_box)
        upper_box.pack_start(entry_box_align, False, False)
        
        upper_box_align = gtk.Alignment()
        upper_box_align.set_padding(0, 10, 0, 10)
        upper_box_align.set(0.5, 0.5, 1, 1)
        upper_box_align.connect("expose-event", self.expose_upper_box_mask)
        upper_box_align.add(upper_box)
        
        self.categorybar_status = "artist"
        self.filter_categorybar = OptionBar(
            [(app_theme.get_pixbuf("filter/artist_normal.png"), app_theme.get_pixbuf("filter/artist_press.png"),
              _("By artist"), lambda : self.reload_filter_view("artist", True)),
             (app_theme.get_pixbuf("filter/album_normal.png"), app_theme.get_pixbuf("filter/album_press.png"),
              _("By album"), lambda : self.reload_filter_view("album", True)),
             (app_theme.get_pixbuf("filter/genre_normal.png"), app_theme.get_pixbuf("filter/genre_press.png"),
              _("By genre"), lambda : self.reload_filter_view("genre", True)),]
                                            )
        
        # Song path bar.
        self.__current_path = None
        self.current_icon_item = None
        self.reload_path_flag = True
        self.path_categorybar = SongPathBar(_("Local"))
        self.path_categorybar.set_size_request(-1, 205)
        
        # Song import bar.
        self.import_categorybar = SongImportBar()
        self.import_categorybar.reload_items(
            [
             (_("Scan Home dir"), lambda : ImportFolderJob([os.path.expanduser("~")])),                
             (_("Select dir to scan"), lambda : ImportFolderJob()),
             (_("Refresh library"), lambda : ReloadDBJob())]
            )
        
        # iconview.
        self.filter_view = IconView(10, 10)
        targets = [("text/deepin-songs", gtk.TARGET_SAME_APP, 1), ("text/uri-list", 0, 2)]
        self.filter_view.drag_source_set(gtk.gdk.BUTTON1_MASK, targets, gtk.gdk.ACTION_COPY)
        self.filter_view.connect("drag-data-get", self.__on_drag_data_get) 
        self.filter_view.connect("double-click-item", self.__on_double_click_item)
        self.filter_view.connect("single-click-item", self.__on_single_click_item)
        self.filter_view.draw_mask  = self.draw_filter_view_mask
        self.filter_scrolled_window = ScrolledWindow()
        self.filter_scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        self.filter_scrolled_window.add_child(self.filter_view)
        
        # songs_view
        self.songs_view = MultiDragSongView()
        self.songs_view.add_titles([_("Title"), _("Artist"), _("Album"), _("Added time")])
        self.songs_scrolled_window = ScrolledWindow(0, 0)
        self.songs_scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        self.songs_scrolled_window.add_child(self.songs_view)
        
        # left_vbox
        align = gtk.Alignment()
#.........这里部分代码省略.........
开发者ID:andy071001,项目名称:deepin-music-player,代码行数:103,代码来源:browser.py


注:本文中的dtk.ui.iconview.IconView.connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。