Python gtk 模块,ICON_SIZE_MENU 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用gtk.ICON_SIZE_MENU

项目:lfde    作者:mv-code    | 项目源码 | 文件源码
def gui_add_task(self, task):
        label = gtk.Label(task.name)
        label.set_alignment(0.0, 0.0)
        row = self.task_count + 1
        col = 0  
        # col_left_attach, col_right_attach, row_top_attach, row_bottom_attach
        self.tbl_tasks.attach(label, col, col + 1, row, row + 1)
        label.show()

        col = 1 
        image = gtk.Image() 
        image.set_from_stock(gtk.STOCK_APPLY, gtk.ICON_SIZE_MENU)
        image.set_alignment(0.0, 0.0)
        self.tbl_tasks.attach(image, col, col + 1, row, row + 1)
        self.task_images.append(image)

        self.task_count += 1
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def make_label(self):
        self.label = gtk.HBox(False, 0)

        self.text_label = gtk.Label("")
        self.text_label.show()
        self.label.pack_start(self.text_label, 1, 1, 1)

        button = gtk.Button()
        button.set_relief(gtk.RELIEF_NONE)
        button.set_focus_on_click(False)

        icon = gtk.image_new_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU)
        icon.show()
        button.add(icon)

        button.connect("clicked", lambda x: self.emit("want-close"))
        button.show()
        self.label.pack_start(button, 0, 0, 0)

        self.label.show()
项目:Micro-Pi    作者:Bottersnike    | 项目源码 | 文件源码
def refreshTree(self):
        folderIcon = gtk.Image().render_icon(gtk.STOCK_DIRECTORY, gtk.ICON_SIZE_MENU)
        fileIcon = gtk.Image().render_icon(gtk.STOCK_FILE, gtk.ICON_SIZE_MENU)

        def load(dic, parent=None):
            for i, j in dic.items():
                isFile = j[0]
                if isFile:
                    self.treeStore.append(parent, [fileIcon, i, True])
                else:
                    p = self.treeStore.append(parent, [folderIcon, i, False])
                    load(j[1], p)
        self.treeStore.clear()
        load(self.files)
项目:gnome-connection-manager    作者:mjun    | 项目源码 | 文件源码
def __init__(self, title, owner_, widget_, popup_):
        gtk.HBox.__init__(self, False, 0)

        self.title = title
        self.owner = owner_
        self.eb = gtk.EventBox()
        label = self.label = gtk.Label()
        self.eb.connect('button-press-event', self.popupmenu, label)
        label.set_alignment(0.0, 0.5)
        label.set_text(title)
        self.eb.add(label)        
        self.pack_start(self.eb)        
        label.show()        
        self.eb.show()                
        close_image = gtk.image_new_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU)
        image_w, image_h = gtk.icon_size_lookup(gtk.ICON_SIZE_MENU)
        self.widget=widget_
        self.popup = popup_        
        close_btn = gtk.Button()
        close_btn.set_relief(gtk.RELIEF_NONE)
        close_btn.connect('clicked', self.on_close_tab, owner_)
        close_btn.set_size_request(image_w+7, image_h+6)
        close_btn.add(close_image)
        style = close_btn.get_style();
        self.eb2 = gtk.EventBox()
        self.eb2.add(close_btn)        
        self.pack_start(self.eb2, False, False)
        self.eb2.show()
        close_btn.show_all()  
        self.is_active = True
        self.show()
项目:wahcade    作者:sairuk    | 项目源码 | 文件源码
def setup_menu(self, mnu_items, mnu_pixmaps, activate_cb):
        """returns a gtk menu object
        Parameters:
            mnu_items   : List of menu item names (either a string, a gtk stock item or '_sep_' for a separator)
            mnu_pixmaps : List of pixmaps (filename, a gtk stock icon or None)
            activate_cb : Callback function for menu activation
        Returns:
            Reference to the constructed gtk.Menu
        """
        mnu = gtk.Menu()
        for i in range(len(mnu_items)):
            #separator or menu item?
            if mnu_items[i] != '_sep_':
                #menu item
                mnuItem = gtk.ImageMenuItem(stock_id=mnu_items[i])
                img = gtk.Image()
                if mnu_pixmaps[i]:
                    if mnu_pixmaps[i][:4] == 'gtk-' and '.' not in mnu_pixmaps[i]:
                        #stock icon
                        img.set_from_stock(mnu_pixmaps[i], gtk.ICON_SIZE_MENU)
                    else:
                        #file icon
                        img.set_from_pixbuf(self.get_pixbuf(mnu_pixmaps[i], gtk.ICON_SIZE_MENU))
                    img.show()
                    mnuItem.set_image(img)
                mnuItem.connect('activate', activate_cb)
                mnuItem.set_name(mnu_items[i])
            else:
                #separator
                mnuItem = gtk.SeparatorMenuItem()
            #add item to menu
            mnuItem.show()
            mnu.append(mnuItem)
        #done
        return mnu
项目:Micro-Pi    作者:Bottersnike    | 项目源码 | 文件源码
def addNotebookPage(self, title, content, path):
        area = gtk.ScrolledWindow()
        area.set_policy(gtk.POLICY_ALWAYS, gtk.POLICY_ALWAYS)
        area.show()

        txtB = gtkSourceView.Buffer()
        txtB.begin_not_undoable_action()
        txtB.set_style_scheme(self.style_scheme)

        language = self.getLanguage(title)

        txtB.set_highlight_matching_brackets(True)
        if language is not None:
            txtB.set_highlight_syntax(True)
            txtB.set_language(language)

        txtB.set_text(content)
        txtB.place_cursor(txtB.get_start_iter())
        txtB.set_modified(False)
        txtB.end_not_undoable_action()

        text = SourceView(txtB)
        text.set_tab_width(self.tabWidth)
        text.set_insert_spaces_instead_of_tabs(False)
        text.set_show_right_margin(True)
        text.set_show_line_marks(True)
        text.set_auto_indent(self.autoIndent)
        text.set_show_line_numbers(self.lineNumbers)
        text.show()
        text.modify_font(pango.FontDescription('Monospace 10'))
        area.add(text)


        top = gtk.HBox()

        title = gtk.Label(title)
        title.show()
        top.set_tooltip_text(path)


        top.pack_start(title, True, True, 0)
        butt = gtk.Button()
        img = gtk.Image()
        img.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU)
        img.show()
        butt.set_image(img)
        butt.connect_object("clicked", self.closePage, area)
        top.pack_end(butt, False, False, 0)

        butt.show()
        top.show()

        self.notebook.insert_page(area, top, 0)

        pages = self.notebook.get_n_pages()
        self.notebook.set_current_page(0)
项目:gnome-connection-manager    作者:mjun    | 项目源码 | 文件源码
def updateTree(self):
        for grupo in dict(groups):
            if len(groups[grupo])==0:
                del groups[grupo]

        if conf.COLLAPSED_FOLDERS == None:
            conf.COLLAPSED_FOLDERS = ','.join(self.get_collapsed_nodes())

        self.menuServers.foreach(self.menuServers.remove)
        self.treeModel.clear()

        iconHost = self.treeServers.render_icon("gtk-network", size=gtk.ICON_SIZE_BUTTON, detail=None)
        iconDir = self.treeServers.render_icon("gtk-directory", size=gtk.ICON_SIZE_BUTTON, detail=None)             

        grupos = groups.keys()
        grupos.sort(lambda x,y: cmp(y,x))

        for grupo in grupos:
            group = None
            path = ""
            menuNode = self.menuServers

            for folder in grupo.split("/"):
                path = path + '/' + folder
                row = self.get_folder(self.treeModel, '', path)
                if row == None:
                    group = self.treeModel.prepend(group, [folder, None, iconDir])
                else:
                    group = row.iter

                menu = self.get_folder_menu(self.menuServers, '', path)
                if menu == None:
                    menu = gtk.ImageMenuItem(folder)
                    #menu.set_image(gtk.image_new_from_stock(gtk.STOCK_DIRECTORY, gtk.ICON_SIZE_MENU))
                    menuNode.prepend(menu)
                    menuNode = gtk.Menu()
                    menu.set_submenu(menuNode)
                    menu.show()
                else:
                    menuNode = menu

            groups[grupo].sort(key=operator.attrgetter('name'))
            for host in groups[grupo]:
                self.treeModel.append(group, [host.name, host, iconHost])
                mnuItem = gtk.ImageMenuItem(host.name)
                mnuItem.set_image(gtk.image_new_from_stock(gtk.STOCK_NETWORK, gtk.ICON_SIZE_MENU))
                mnuItem.show()
                mnuItem.connect("activate", lambda arg, nb, h: self.addTab(nb, h), self.nbConsole, host) 
                menuNode.append(mnuItem)

        self.set_collapsed_nodes()
        conf.COLLAPSED_FOLDERS = None
项目:linux-pentest-util    作者:fikr4n    | 项目源码 | 文件源码
def _create_legend(self):
        icons = (
            (gtk.STOCK_FILE, 'Class'),
            (gtk.STOCK_EXECUTE, 'Method'),
            (gtk.STOCK_SELECT_FONT, 'Field'),
            (gtk.STOCK_DELETE, 'Declaration not found'),
            (gtk.STOCK_INFO, 'Miscellaneous (info)'),
            (u'?', 'Direct call – e.g. static, private, etc'),
            (u'?', 'Virtual call (? + ?)'),
            (u'?', 'Virtual call (indirect) which could be performed because '
                'of polymorphism'),
            (u'?', 'Virtual call (direct only) which does not actually '
                'performed – e.g. interface method'),
            (u'?', 'Super call (? + ?)'),
            (u'?', 'Super call (indirect) because direct super does not '
                'declare the method'),
            (u'?', 'Super call (direct only) which does not actually '
                'performed – e.g. not declared here'),
        )
        table = gtk.Table(7, 5)
        table.set_border_width(8)
        table.set_row_spacings(8)
        table.set_col_spacings(8)
        separator = gtk.VSeparator()
        table.attach(separator, 2, 3, 0, 7, 0)
        x, y = 0, 0
        for icon, desc in icons:
            if len(icon) == 1:
                image = gtk.Label(icon)
            else:
                image = gtk.Image()
                image.set_from_stock(icon, gtk.ICON_SIZE_MENU)
            image.set_alignment(1, 0.5)
            label = gtk.Label(desc)
            label.set_alignment(0, 0.5)
            table.attach(image, x + 0, x + 1, y, y + 1, gtk.FILL)
            table.attach(label, x + 1, x + 2, y, y + 1, gtk.FILL)
            y += 1
            if y == 5 and x == 0:
                x, y = 3, 0
        frame = gtk.Frame('Legend')
        frame.add(table)
        return frame